FlagsClear need unseen too

Ralf Becker 2020-08-05 11:16:40 +02:00
parent 98fa6a5474
commit efdf992066

@ -139,7 +139,7 @@ function dovecot_lua_notify_event_message_new(ctx, event)
end end
function dovecot_lua_notify_event_message_append(ctx, event) function dovecot_lua_notify_event_message_append(ctx, event)
dovecot_lua_notify_event_message_new(ctx, event) dovecot_lua_notify_event_message_new(ctx, event)
end end
-- ignored, as FlagSet flags=[\Seen] is sent anyway too -- ignored, as FlagSet flags=[\Seen] is sent anyway too
@ -217,16 +217,25 @@ function dovecot_lua_notify_event_flags_set(ctx, event)
end end
return; return;
end end
table.insert(ctx.messages, { local msg = {
user = ctx.meta, user = ctx.meta,
["imap-uidvalidity"] = event.uid_validity, ["imap-uidvalidity"] = event.uid_validity,
["imap-uid"] = event.uid, ["imap-uid"] = event.uid,
folder = event.mailbox, folder = event.mailbox,
event = event.name, event = event.name,
flags = event.flags, flags = event.flags,
keywords = event.keywords, keywords = event.keywords
unseen = status.unseen }
}) if (status ~= nil)
then
msg.unseen = status.unseen
end
if (event.name == "FlagsClear")
then
msg["flags-old"] = event.flags_old
msg["keywords-old"] = event.keywords_old
end
table.insert(ctx.messages, msg)
end end
function arrayEqual(t1, t2) function arrayEqual(t1, t2)
@ -242,21 +251,7 @@ function arrayEqual(t1, t2)
end end
function dovecot_lua_notify_event_flags_clear(ctx, event) function dovecot_lua_notify_event_flags_clear(ctx, event)
-- check if there is a push token registered AND something to clear (TB sends it empty) dovecot_lua_notify_event_flags_set(ctx, event)
if (ctx.meta == nil or (#event.flags == 0 and #event.keywords == 0)) then
return
end
table.insert(ctx.messages, {
user = ctx.meta,
["imap-uidvalidity"] = event.uid_validity,
["imap-uid"] = event.uid,
folder = event.mailbox,
event = event.name,
flags = event.flags,
["flags-old"] = event.flags_old,
keywords = event.keywords,
["keywords-old"] = event.keywords_old
})
end end
function dovecot_lua_notify_end_txn(ctx) function dovecot_lua_notify_end_txn(ctx)