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
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
-- ignored, as FlagSet flags=[\Seen] is sent anyway too
@ -217,16 +217,25 @@ function dovecot_lua_notify_event_flags_set(ctx, event)
end
return;
end
table.insert(ctx.messages, {
local msg = {
user = ctx.meta,
["imap-uidvalidity"] = event.uid_validity,
["imap-uid"] = event.uid,
folder = event.mailbox,
event = event.name,
flags = event.flags,
keywords = event.keywords,
unseen = status.unseen
})
keywords = event.keywords
}
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
function arrayEqual(t1, t2)
@ -242,21 +251,7 @@ function arrayEqual(t1, t2)
end
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)
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
})
dovecot_lua_notify_event_flags_set(ctx, event)
end
function dovecot_lua_notify_end_txn(ctx)