[ejabberd] MUC - add a JID programmatically to chat "users"

Daniel Dormont dan at greywallsoftware.com
Tue Sep 6 05:09:13 MSD 2011

Just to spur some discussion :) I thought of a few less crude ways of
doing this:

1) Still modify mod_muc_room in all the places where it's about to
broadcast a packet to the audience, but instead of hard-coding the
rule about sending to a special configured JID, I'd just add a
run_hook for a new hook, perhaps called muc_send_packet for

2) Similar to above, but add the functionality to mod_muc_log instead.
When it's logging an event, have a hook (maybe in this case I'd call
it muc_log_event or something) that could allow my own module to do
what it needs (route a packet). This has the advantage of being
asynchronous with the actual broadcast and saves me from modifying

3) Alternative to 2). Instead of a hook, add some logic to make
mod_muc_log replaceable with a different implementation that follows
the same API, much as is done for auth_module.

Which of these would be best, or is there some yet better idea?


On Thu, Sep 1, 2011 at 7:02 PM, Daniel Dormont <dan at greywallsoftware.com> wrote:
> Hi folks,
> I have a use case where I would like, every time a particular MUC
> sends out packets to all its users (for example, if a user joins or
> leaves, a groupchat message is posted, etc) to also send it to a
> particular JID that I can designate. But I want it treated more like a
> system account (in fact, it will probably be an external component). I
> don't want this JID listed among the participants so everyone can see
> it, I don't want the groupchat notified if this JID goes offline or
> anything like that. If it *is* offline, I want the messages routed to
> it to silently fail, just like any message routed to an invalid JID.
> Basically something similar to mod_service_log, except for instead of
> when the user sends the packet, I want it called with the MUC sends
> the packet. I know I could use mod_service_log itself, but that would
> be called for each packet the MUC sends to each user. That is not what
> I want. I want each packet from the MUC to reach the special JID only
> once.
> Looking at the code for mod_muc_room, the only thing I can think of is
> to somehow inject the value in to state.users and modify
> send_existing_presences to somehow exclude this special JID. But that
> seems a little tacky. Is there any better way?
> thanks,
> Dan

More information about the ejabberd mailing list