ejabberd-18.12: разобрать пакет внутри крючка - PullRequest
0 голосов
/ 01 февраля 2019

Код хука:

user_receive_packet({Packet, #{jid := JID} = C2SState}) ->
    ?INFO_MSG("~p.", [Packet]),
    {Packet, C2SState}.

Выход:

{message,<<"49a85099-6fa6-4aa5-84ab-bced89adf847">>,groupchat,<<"en">>,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<"localhost">>},{jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},[],[{text,<<>>,<<"{\"type\":\"text\",\"payload\":{\"body\":\"a beautiful\"}}">>}],undefined,[{mam_archived,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>},{stanza_id,{jid,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>,<<"sgj279_59f990094dd64c4846cc38c5_59fa99bbfdbd1ab22e59df29">>,<<"conference.localhost">>,<<>>},<<"1549043294480251">>}],#{ip => {0,0,0,0,0,0,0,1},mam_archived => true,muc_sender_real_jid => {jid,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>,<<"test1">>,<<"localhost">>,<<"49921480726720246332274">>},stanza_id => 1549043294480251}}.

Я хочу прочитать значение поля stanza_id и метку времени, указанную в mam_archived

Каков синтаксис для разбора любого поля?

1 Ответ

0 голосов
/ 04 февраля 2019

Попробуйте:

?INFO_MSG("Stanza ID: ~p", [ maps:get(stanza_id, Packet#message.meta) ]),
...