Reputation: 1503
I changed 'Subject' of a chat room but I am not getting this latest subject name. I am using 'disco#info' to get the room info. In response, I am getting room title that was set initially while creating the room but not the latest room subject. How can I get the latest room subject ?
Upvotes: 1
Views: 816
Reputation: 1503
Had to customize the Erlang module mod_muc_room.erl
.
Did these changes in iq_disco_info_extras
:
get_subject
which gets the room subject from StateData
.iq_disco_info_extras
to get room subject and called the function RoomSubject = get_subject(StateData)
.RFIELD
as ?RFIELD(<<"Room subject">>,
<<"muc#roominfo_subject">>, RoomSubject)
,mod_muc_room.erl
, which updated the mod_muc_room.beam
file.Tada...that worked like a piece of cake!
Now getting subject name in roominfo
.
Upvotes: 6
Reputation: 350
In case anyone is still looking for this, here's a quick way to do this from something like an ejabberd plugin/module:
{ok,Room_PID} = mod_muc:find_online_room(<<"my_muc_room_name">>, <<"conference.my.server.com">>),
{ok,Room_State} = p1_fsm:sync_send_all_state_event(Room_PID, get_state),
Room_Subject_List = Room_State#state.subject,
Room_Subject = hd(Room_Subject_List),
Subject = Room_Subject#text.data,
io:format("~ts~n", [Subject]).
If you're trying this from an erlang shell you brought up via "ejabberdctl debug", then you'll also want to pull in the record definitions for "state" and "text". To do that, create a textfile called something like "my_record_includes.hrl" with content something like the following (of course, you'll have to adjust the filepaths based on your ejabberd installation).
-include("/opt/ejabberd-19.05/lib/xmpp-1.3.4/include/jid.hrl").
-include("/opt/ejabberd-19.05/lib/xmpp-1.3.4/include/xmpp_codec.hrl").
-include("/opt/ejabberd-19.05/lib/ejabberd-19.05/include/mod_muc_room.hrl").
Once you have "my_record_includes.hrl" created, then use the shell "rr" command to import it like this:
> rr("my_record_includes.hrl").
[activity,address,addresses,adhoc_actions,adhoc_command,
adhoc_note,avatar_data,avatar_info,avatar_meta,
avatar_pointer,bind,block,block_item,block_list,bob_data,
bookmark_conference,bookmark_storage,bookmark_url,
bytestreams,caps,carbons_disable,carbons_enable,
carbons_private,carbons_received,carbons_sent,chatstate,
compress,compress_failure,compressed|...]
If you're doing this in an erlang shell, make sure you import those record definitions BEFORE you try executing the code to grab the room state and subject!
Also, be careful about doing this from a callback that is executed by the muc room's process itself. The call to p1_fsm:sync_send_all_state_event( ) sends a message to the room process, and that will time out if you're sending it to your own process and blocking. Do the query for the room state from another process!
Upvotes: 1
Reputation: 9055
In XMPP MUC protocol, Subject and title are two different things. The title is set via configuration form and can be displayed in service discovery. Subject is a dynamic topic that is send to participant when he joins the room. Subject is not send back in disco#info query. Only name and room_description are send back in discovery info.
Upvotes: 2