mod_presence - Presence on the Web

Name: mod_presence
Purpose: Allow user to show presence in the web
Author: Igor Goryachev
Type: Module
Requirements: ejabberd SVN
Download: ejabberd-modules

This module has evolved into mod_webpresence, which includes a lot more features. The upgrade should be easy, since the database table is updated automatically and the URL scheme is compatible.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Docs?

I don't see any documentation on how this module works. Looking at the comments here, I've installed the module, set the PIXMAPS environment variable (what about putting that in as an option to the module?), registered via Discovery, then browsed to localhost:5280/presence/user/host/image/, but I get a 404. Anything I can do to fix this issue, or to help, please advise.

Bug?

So I think I've found a bug in mod_presence (at least 0.0.4) that took me all day to realize. I was trying to automatically register all users for mod_presence using a PHP script against "Jabber Client Library". FYI - the script simply logs in as each user, and then makes the appropriate register request to mod_presence.

For simplicity, I was simply attempting to use the same icon set and xml setting for every user. But that didn't work. Every time, the first user would succeed, and then I'd get a "cancel" error ("Specified presence is already registered"). After many hours of work, I narrowed the problem down not to my script, but to a server-side problem.

I then tried to duplicate the problem through the Exodus client. If I attempted to register multiple users against mod_presence with the same icon set and xml setting combination, the registration failed as above. But if I chose a different icon set or xml setting, it would succeed.

FYI, I'm using ejabberd 1.1.2.

Any thoughts about what might be the problem would be greatly appreciated. If you need any additional debugging on my side, please let me know. Thanks!

I can reproduce the problem

I can reproduce the problem and found the problematic code. This patch seems to solve the problem, but since I didn't write mod_presence and didn't test this patch, I cannot guarantee it is completely safe.

Note that I removed a lot of code that I consider unnecesary. I've reported this patch to the author, and he will decide.

Save as file.diff on ejabberd/src and apply with: patch -p0<file.diff

--- mod_presence.erl	2006-10-15 12:48:19.000000000 +0200
+++ mod_presence.erl	2006-10-15 12:34:08.000000000 +0200
@@ -269,7 +269,7 @@
     [{xmlelement, "identity",
       [{"category", "presence"},
        {"type", "text"},
-       {"name", "ejabberd/mod_presence"}], []},
+       {"name", "Web Presence"}], []},
      {xmlelement, "feature", [{"var", ?NS_REGISTER}], []},
      {xmlelement, "feature", [{"var", ?NS_VCARD}], []}].
 
@@ -315,47 +315,18 @@
             ] ++ available_themes(xdata)},
 	   ?XFIELD("boolean", "Raw XML", "xml", XML)]}].
 
-iq_set_register_info(Host, From, XML, Icon, Lang) ->
+iq_set_register_info(Host, From, XML, Icon, _Lang) ->
     {LUser, LServer, _} = jlib:jid_tolower(From),
     LUS = {LUser, LServer},
     F = fun() ->
-		case XML of
-		    "" ->
-			mnesia:delete({presence_registered, {LUS, Host}}),
-			ok;
-		    _ ->
-			Allow =
-			    case mnesia:select(
-				   presence_registered,
-				   [{#presence_registered{us_host = '$1',
-						     xml = XML,
-                                                     icon = Icon,
-						     _ = '_'},
-				     [{'==', {element, 2, '$1'}, Host}],
-				     ['$_']}]) of
-				[] ->
-				    true;
-				[#presence_registered{us_host = {U, _Host}}] ->
-				    U == LUS
-			    end,
-			if
-			    Allow ->
-				mnesia:write(
-				  #presence_registered{us_host = {LUS, Host},
-						  xml = XML,
-                                                  icon = Icon}),
-				ok;
-			    true ->
-				false
-			end
-		end
-	end,
+	mnesia:write(
+	  #presence_registered{us_host = {LUS, Host},
+		  xml = XML,
+                  icon = Icon})
+    end,
     case mnesia:transaction(F) of
 	{atomic, ok} ->
 	    {result, []};
-	{atomic, false} ->
-	    ErrText = "Specified presence is already registered",
-	    {error, ?ERRT_CONFLICT(Lang, ErrText)};
 	_ ->
 	    {error, ?ERR_INTERNAL_SERVER_ERROR}
     end.

Looks good!

badlop wrote:

I can reproduce the problem and found the problematic code. This patch seems to solve the problem, but since I didn't write the original code and didn't test it, I cannot guarantee it is completely safe.

Just applied the patch, and it looks like it's working correctly. I'll test it out more later today. Thanks very much for your prompt response! :-)

Location of pixmaps directory

Where is the pixmaps directory supposed to end up when all is finished? The module is working, but instead of a list of themes, I'm simply getting "disabled"... which, by looking at the code indicates that it can't find the pixmaps directory.

To answer my own question...

To answer my own question, which should have been an obvious answer, but apparently I was dense at the moment... the pixmaps directory is supposed to be within your HOME directory. Personally mine is specified in my init.d file (on Gentoo as /var/run/jabber). Thanks.

Problems accessing /presence

Hi there,
I am trying to get this module functioning. It is being loaded because I am able to browse it via DISCO, once I have "registered" with the presence agent I try and access /presence/dan/f-box.org/image/ and get a 404.

Am I missing some configuration step?

I have only this line in my ejabberd.cfd
{mod_presence, []},

Cheers,
Dan.

Found; quick fix

You are right. The problem is that the register form on mod_presence.erl stores on the database "1" or "0", but the web code on ejabberd_web.erl expects true or false. Since I don't know what is more efficient, or what will be the definitive solution, I tell you the easier way to fix it. Note that if the final solution is not the same, your users will need to reregister on the service once you update.

On ejabberd/src/web/ejabberd_web.erl line 142 and following, the patch added some code. Replace those lines with the later code:

  • Replace
      case XML of
        true ->
    with
      case XML of
        '1' ->
  • And
      case Icon of
        true ->
    with
      case Icon of
        '1' ->
  • And again
      case Icon of
        true ->
    with
      case Icon of
        '1' ->

Syndicate content