How to access mailbox metadata in Lua push driver

Aki Tuomi aki.tuomi at open-xchange.com
Mon Aug 3 12:40:10 EEST 2020


> On 03/08/2020 12:31 Ralf Becker <rb at egroupware.org> wrote:
> 
>  
> We're currently using the OX push driver, which is straight forward
> (simple web hook) and allows to store (multiple) push tokens of our
> webmailer direct in mailbox metadata.
> 
> Only drawback is that it only supports new arriving mails in the INBOX,
> even mails moved via Sieve to other folders are NOT reported.
> 
> Therefore we updated now to Dovecot 2.3(.10.1) to also get mails moved
> by user or Sieve scripts, deleted mails or flag changes.
> 
> As far as I read the example Lua scripts and (a little) the Dovecot C
> code, the nice indirection of using mailbox metadata to a) enable push
> and b) store push tokens (modify reported user attribute with them) does
> NOT exist in the Lua driver by default.
> 
> So my questions is: how can I access mailbox metadata from within the
> Lua script, to make eg. the example script behave like the OX driver
> with user_from_metadata set?
> 
> I'm happy to update the Lua examples, if that's any help ...
> 
> Ralf
> 
> -- 
> Ralf Becker
> EGroupware GmbH [www.egroupware.org]
> Handelsregister HRB Kaiserslautern 3587
> Geschäftsführer Birgit und Ralf Becker
> Leibnizstr. 17, 67663 Kaiserslautern, Germany
> Telefon +49 631 31657-0

Actually it does exist:

https://doc.dovecot.org/admin_manual/lua/#mail_user.metadata_get

or

https://doc.dovecot.org/admin_manual/lua/#object-mailbox

mailbox:metadata_get()

You get both of these objects from the push notification data, you just have to keep them in the context state. (See the example scripts)

function dovecot_lua_notify_begin_txn(user)
   local meta = user:metadata_get("/private/key")
   return {messages={}, ep=user:plugin_getenv("push_lua_url"), username=user.username, meta=meta}
end

Aki


More information about the dovecot mailing list