[ejabberd] mod_roster hook (in_subscription) not being called

Stephan Maihöfer sma at turtle-entertainment.de
Tue Dec 9 14:37:27 MSK 2008


hi,
 
after some more fiddling, i found that the presence reaches it's goal only
when i give it the according resource...so this won't get through:
 
<presence type="subscribe" to="user2 at example.com" > 
<nick xmlns="http://jabber.org/protocol/nick">user</nick>
</presence>
 
this will:
 
<presence type="subscribe" to="user2 at example.com/resource" > 
<nick xmlns="http://jabber.org/protocol/nick">user</nick>
</presence>

i do not think i am sending these presence-messages anywhere
manually...so why is there any difference in handling? i guess
it must be in one of my hooks...any ideas?
 
thanks,
stephan

________________________________

	Von: ejabberd-bounces at jabber.ru [mailto:ejabberd-bounces at jabber.ru] Im Auftrag von Stephan Maihöfer
	Gesendet: Montag, 8. Dezember 2008 19:27
	An: ejabberd at jabber.ru
	Betreff: [ejabberd] mod_roster hook (in_subscription) not being called
	
	
	hi,
	 
	since I am currently writing a new mod_roster to authenticate against
	out api-server and handling it's JSON repsonses, I am reading through
	all the sourcecode and documentation I can get. It's been quite "ok"
	up until now, but now I have a problem.
	 
	I have hooks registered for process_iq and process_local_iq that handle
	invitations and then push items to the connected clients, this seems
	to be working fine, but i have problems with the hooks for in_subscription
	and out_subscription.
	 
	-export([start/2, stop/1,
	   process_iq/3,
	   process_sm_iq/3,
	   process_local_iq/3,
	   get_user_roster/2,
	   in_subscription/6,
	   out_subscription/4,
	   get_in_pending_subscriptions/3,
	   get_subscription_lists/3]).
	
	start(Host, Opts) ->
	    ?INFO_MSG("mod_roster_wire starting...", []),
	    IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
	    ejabberd_hooks:add(roster_get, Host,
	      ?MODULE, get_user_roster, 50),
	    ejabberd_hooks:add(roster_in_subscription, Host,
	      ?MODULE, in_subscription, 50),
	    ejabberd_hooks:add(roster_out_subscription, Host,
	      ?MODULE, out_subscription, 50),
	    ejabberd_hooks:add(roster_get_subscription_lists, Host,
	      ?MODULE, get_subscription_lists, 50),
	%%  ejabberd_hooks:add(roster_get_jid_info, Host,
	%%    ?MODULE, get_jid_info, 50),
	%%    ejabberd_hooks:add(remove_user, Host,
	%%    ?MODULE, remove_user, 50),
	    ejabberd_hooks:add(resend_subscription_requests_hook, Host,
	      ?MODULE, get_in_pending_subscriptions, 50),
	    gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
	      ?MODULE, process_iq, IQDisc).
	
	after the initial iq-set when adding a new contact, I am sending my presence
	with type="subscribe" to the entity i want to subscribe to. In the logfiles
	I see that the hook for out_subscription is called and everything seems
	to be running fine (no exceptions or something like that). Then i see
	this:
	
	=INFO REPORT==== 2008-12-08 19:18:15 ===
	D(<0.308.0>:ejabberd_router:301) : route
	  from {jid,"user1","example.com",[],"user1","example.com",[]}
	  to {jid,"user2","example.com",[],"user2","example.com",[]}
	  packet {xmlelement,"presence",
	                           [{"xml:lang","en"},
	                            {"type","subscribe"},
	                            {"to","user2 at example.com <mailto:user2 at example.com> "}],
	                           [{xmlcdata,<<"\n">>},
	                            {xmlelement,
	                                "nick",
	                                [{"xmlns","http://jabber.org/protocol/nick <http://jabber.org/protocol/nick> "}],
	                                [{xmlcdata,<<"friend">>}]},
	                            {xmlcdata,<<"\n">>}]}
	 

	=INFO REPORT==== 2008-12-08 19:18:15 ===
	D(<0.308.0>:ejabberd_local:279) : local route
	  from {jid,"user1","example.com",[],"user1","example.com",[]}
	  to {jid,"user2","example.com",[],"user2","example.com",[]}
	  packet {xmlelement,"presence",
	                           [{"xml:lang","en"},{"type"|...},{...}],
	                           [{xmlcdata|...},{...}|...]}
	 

	=INFO REPORT==== 2008-12-08 19:18:15 ===
	D(<0.308.0>:ejabberd_sm:372) : session manager
	  from {jid,"user1","example.com",[],"user1","example.com",[]}
	  to {jid,"user2","example.com",[],"user2","example.com",[]}
	  packet {xmlelement,"presence",
	                           [{"xml:lang","en"},{"type"|...},{...}],
	                           [{xmlcdata|...},{...}|...]}
		 
	But the presence packet does not reach the other user, nor is the in_subscription
	hook being called. What am I doing wrong? Do I need to manually "relay" the
	presence? Why doesn't the session manager actually call it, how to make the
	hook being called?
	 
	thanks in advance,
	stephan



More information about the ejabberd mailing list