[ejabberd] Managing Diskussion History

Badlop badlop at gmail.com
Mon Mar 2 16:45:21 MSK 2009


2009/2/27 Stephan Maihöfer <sma at turtle-entertainment.de>:
> i see that this seems to be in accordance to the standard
> but was hoping that it would still be possible to get
> the history while _in_ the channel. this woul be insanely
> useful for "idling" BOSH-Sessions that are being reattached.

Patch against ejabberd trunk SVN.

--- a/src/mod_muc/mod_muc_room.erl
+++ b/src/mod_muc/mod_muc_room.erl
@@ -360,7 +360,7 @@ normal_state({route, From, "",
     end;

 normal_state({route, From, Nick,
-             {xmlelement, "presence", _Attrs, _Els} = Packet},
+             {xmlelement, "presence", _Attrs, Els} = Packet},
             StateData) ->
     Activity = get_user_activity(From, StateData),
     Now = now_to_usec(now()),
@@ -373,6 +373,7 @@ normal_state({route, From, Nick,
        (Activity#activity.presence == undefined) ->
            NewActivity = Activity#activity{presence_time = Now},
            StateData1 = store_user_activity(From, NewActivity, StateData),
+           maybe_send_history(Els, From, Nick, StateData),
            process_presence(From, Nick, Packet, StateData1);
        true ->
            if
@@ -523,6 +524,20 @@ normal_state(_Event, StateData) ->
     {next_state, normal_state, StateData}.


+%% To get the room history, the occupant can send a presence with
+%% a history element, indicating at least the maxstanzas attribute
+%% <presence to='room at conference.localhost/occupant'>
+%%   <x xmlns='http://jabber.org/protocol/muc'>
+%%     <history maxstanzas='20'/>
+%%   </x>
+%% </presence>
+maybe_send_history(Els, From, Nick, StateData) ->
+    case extract_history(Els, "maxstanzas") of
+       false -> ok;
+       _ ->
+           Shift = count_stanza_shift(Nick, Els, StateData),
+           send_history(From, Shift, StateData)
+    end.

 %%----------------------------------------------------------------------
 %% Func: handle_event/3


---
Badlop,
ProcessOne


More information about the ejabberd mailing list