0

I've just installed ejabberd from the sources (18.04) with MySQL support and changed the configuration file respectively. Basically everything works: ejabberd starts, I can register users, users can connect and send messages. I also see all users in the database so I assume the setup is so far correct.

Now I want to use the mod mod_mam to archive all messages. For this I added to the ejabberd.yaml file the following lines:

modules:
  ...
  mod_mam:
    db_type: sql
    default: always
  ...

However, when I sent an offline message, I get the following error -- actually two similar errors for two functions using both the offline message hook:

[error] <0.541.0>@ejabberd_hooks:safe_apply:383 Hook offline_message_hook crashed when running mod_mam:offline_message/1: 
** Reason = {error,function_clause,[{mod_mam,offline_message,[{file,"src/mod_mam.erl"},{line,366}],[ok]},{ejabberd_hooks,safe_apply,[{file,"src/ejabberd_hooks.erl"},{line,380}],4},{ejabberd_hooks,run_fold1,[{file,"src/ejabberd_hooks.erl"},{line,364}],4},{ejabberd_sm,route,[{file,"src/ejabberd_sm.erl"},{line,143}],1},{ejabberd_local,route,[{file,"src/ejabberd_local.erl"},{line,73}],1},{ejabberd_router,do_route,[{file,"src/ejabberd_router.erl"},{line,368}],1},{ejabberd_router,route,[{file,"src/ejabberd_router.erl"},{line,93}],1},{ejabberd_c2s,check_privacy_then_route,[{file,"src/ejabberd_c2s.erl"},{line,823}],2}]}

With an older installation (17.01) everything worked fine. But I don't know if additional MySQL tables are required. When I look into my current database, I actually all messages (including offline message) get stored in table archive.

Christian
  • 3,239
  • 5
  • 38
  • 79
  • 2
    Do you use only the modules included in ejabberd, or did you install any of the contributed, or other custom modules? – Badlop May 21 '18 at 11:39
  • Your question steered me in the right direction. I do have mine own module that uses that hook. In case of an offline message, the function `sent_notification({Action,Packet} = Acc)` gets called. However, I returned with an `ok.` If I return with `Acc.`, everything seems to work. So I assume I have to pass the input through for the next module (just a guess, I'm not very familiar with ejabberd/erlang). I'm sure my module worked with ejabberd 17.01, when the signature had to be `sent_notification(From, To, Packet)` and returning with `ok.` worked. If you provide this as answer, I can accept it. – Christian May 22 '18 at 01:28

1 Answers1

1

Do you use only the modules included in ejabberd, or did you install any of the contributed, or other custom modules?

Notice that offline_message_hook changed in 17.03 from "run" (without accumulator) to "run_fold" (with accumulator), which means that the result of a function call is passed to the next one, until all finish or one stops the hook.

See commit: https://github.com/processone/ejabberd/commit/e564f9ae31d2c5345be4eed66e70037ba8145dc1 and hook docs: https://docs.ejabberd.im/developer/guide/#hooks

Badlop
  • 3,840
  • 1
  • 8
  • 9