I am observing that from attribute of delay element in MUC history message has JID of the occupant instead of room.
As per xmpp.org/extensions/xep-0045.html#enter-history:
Discussion history messages MUST be stamped with Delayed Delivery (XEP-0203) [14] information qualified by the 'urn:xmpp:delay' namespace to indicate that they are sent with delayed delivery and to specify the times at which they were originally sent.
The 'from' attribute MUST be set to the JID of the room itself.
RoomJID = [email protected]
Occupant 1 = [email protected]/desktop
Occupant 2 = [email protected]/desktop
<?xml version="1.0" encoding="UTF-8"?>
<message xmlns="jabber:client" from="[email protected]/cyrus" to="[email protected]/desktop" type="groupchat">
<body>Hi</body>
<thread>B9D31734-606D-43CD-B613-D5FF8DF7CAA3</thread>
<subject />
<active xmlns="http://jabber.org/protocol/chatstates" />
<delay xmlns="urn:xmpp:delay" from="[email protected]/desktop" stamp="2015-03-08T21:02:42.481Z" />
<x xmlns="jabber:x:delay" from="[email protected]/desktop" stamp="20150308T21:02:42" />
</message>
Why is it set to the JID of occupant instead of JID of room? Please help me understand.
It depends if you configured your room as anonymous or not. Configure that room as anonymous and it will behave as you expect.
The behaviour you mention is from XEP-0045 v1.25. For non-anonymous room the original from field should be defined with Extended Stanza Addressing.
Changes are not yet supported, but there are work in progress: https://github.com/processone/ejabberd/issues/465