Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMPP support notification in conference #202

Closed
gituser opened this issue Nov 28, 2013 · 18 comments
Closed

XMPP support notification in conference #202

gituser opened this issue Nov 28, 2013 · 18 comments
Labels

Comments

@gituser
Copy link

gituser commented Nov 28, 2013

hi, we've installed livehelperchat it seems to be very nice and working.

is there any chance to implement conference notification mode?

e.g.

somechat@conference.server.org

so bot comes there and messages with a link that someone is waiting for support (maybe just give regular link where all chats are).

currently i was able to get notifications through our own jabber server but it was bit complicated because i had to specify in my account (in livehelperchat) as an e-mail my jabber ID (notifications field in the XMPP settings seems to be ignored).

would be good if bot could stay on the server and just wait for an event and message into the room, actually making such bot is not a huge deal i think.

anyways, would love to hear your thoughts..

@remdex
Copy link
Contributor

remdex commented Nov 29, 2013

At the moment using gtalk i noticed that messages are not delivered in gtal mobile app, just gtalk does not support messages to self, so perhaps same situation in your case. As for conference you ca setup it by your own if you know how to do it :)

@gituser
Copy link
Author

gituser commented Nov 29, 2013

We're using our own ejabberd server instance.

I will try to look into the code and understand how can I message chat room instead of the selected people. There is also a slight problem, because when it messages someone on the Jabber it gives specific secret URL with session key to immediately login into the system, this can be avoided I guess?

@remdex
Copy link
Contributor

remdex commented Nov 29, 2013

This url is valid just for one click and expires I ques in 24 hours or so.

@gituser
Copy link
Author

gituser commented Nov 29, 2013

OK, thanks for the info.

Don't you think it would be useful for operators to specify separate Jabber ID (GTalk ID) rather than e-mail?

It might be different in most cases. E-mail is used for password recovery I guess whilst jabber ID couldn't be used for this.

I don't think it's hard to code, just alter users table, add jabber field (just like email field) and add logic to XMPP sender.

On the other note I spotted a bug:

if you specify for department an e-mail it would send to that e-mail and when you click on the generated link you get:

[29-Nov-2013 13:51:46 Europe/Moscow] PHP Fatal error:  Uncaught exception 'ezcPersistentQueryException' with message 'A query failed internally in Persistent Object: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null Query: 'INSERT INTO `lh_users_setting` ( `user_id`, `identifier`, `value` ) VALUES ( :ezcValue1, :ezcValue2, :ezcValue3 )'' in /livechat.domain.com/htdocs/lhc/ezcomponents/PersistentObject/src/persistent_session.php:799
Stack trace:
#0 /livechat.domain.com/htdocs/lhc/ezcomponents/PersistentObject/src/handlers/save_handler.php(315): ezcPersistentSession->performQuery(Object(ezcQueryInsert))
#1 /livechat.domain.com/htdocs/lhc/ezcomponents/PersistentObject/src/handlers/save_handler.php(103): ezcPersistentSaveHandler->saveInternal(Object(erLhcoreClassModelUserSetting), false, Object(ezcPersistentNativeGenerator))
#2 /livechat.domain.com/htdocs/lhc/ezcomponents/PersistentObject/src/persistent_session.php(436): ezcPersistentSaveHandler->saveOrUpdate(Object(erLhcoreClassModelUserSetting))
#3 /livechat.d in /livechat.domain.com/htdocs/lhc/ezcomponents/PersistentObject/src/persistent_session.php on line 799

and after this system is unusable at all (everywhere is a blank page).

So as I said before it would be good just to give a direct link and redirect user if he is not authorized, it would help a lot.

Also, I've figured out how to add room support (I did quick hack just to test it out, so there is a plenty of room to optimize the code):

--- lhc_full/lhc_web/lib/core/lhxmp/lhxmp.php   2013-11-28 20:46:57.526293764 +0400
+++ lhc/lib/core/lhxmp/lhxmp.php    2013-11-29 13:49:41.896904523 +0400
@@ -146,10 +146,10 @@
            if  ( (isset($data['use_standard_xmp']) && $data['use_standard_xmp'] == '0') || !isset($data['use_standard_xmp']) ) {           
                $conn = new XMPPHP_XMPP($data['host'], $data['port'], $data['username'], $data['password'], $data['resource'], $data['server'], $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
                try {
+
                    $conn->connect();
                    $conn->processUntil('session_start');
-                   $conn->presence();
-                   
+
                    $emailRecipient = array();
                    if ($chat->department !== false && $chat->department->email != '') { // Perhaps department has assigned email
                        $emailRecipient = explode(',',$chat->department->email);
@@ -160,7 +160,16 @@
                        $user = array_pop($list);
                        $emailRecipient = array($user->email);
                    }
-                   
+
+
+                   foreach($emailRecipient as $tmpEmail)
+                       if (preg_match('/^([A-Za-z0-9_\-]+)@conference\./',$tmpEmail)) {
+                         $conn->presence(NULL, "available", $tmpEmail.'/LiveChat');
+                       }
+
+
+//                 $conn->presence();
+
                    $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 5,'sort' => 'id DESC','filter' => array('chat_id' => $chat->id))));
                    $messagesContent = '';

@@ -177,9 +186,22 @@

                    foreach ($emailRecipient as $email) {           
                        $veryfyEmail =  sha1(sha1($email.$secretHash).$secretHash);
-                       $conn->message($email,str_replace(array('{messages}','{url_accept}'), array($messagesContent,'http://' . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('chat/accept').'/'.erLhcoreClassModelChatAccept::generateAcceptLink($chat).'/'.$veryfyEmail.'/'.$email),$data['xmp_message']));
+                       
+                       $MessageData = str_replace(array('{messages}','{url_accept}'), array($messagesContent,'https://' . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('chat/accept').'/'.erLhcoreClassModelChatAccept::generateAcceptLink($chat).'/'.$veryfyEmail.'/'.$email),$data['xmp_message']);
+                       if (preg_match('/^([A-Za-z0-9_\-]+)@conference\./',$email)) {
+                           $conn->message($email,$MessageData,"groupchat");
+                       }
+                       else {
+                           $conn->message($email,$MessageData);
+                       }
                    }

+
+                                        foreach($emailRecipient as $tmpEmail)
+                                                if (preg_match('/^([A-Za-z0-9_\-]+)@conference\./',$tmpEmail)) {
+                                                  $conn->presence(NULL, "unavailable", $tmpEmail.'/LiveChat');
+                                        }
+
                    $conn->disconnect();
                    return true;
                } catch (Exception $e) {
@@ -241,4 +263,4 @@

 }

-?>
\ No newline at end of file
+?>

@remdex
Copy link
Contributor

remdex commented Nov 29, 2013

Thank you for this "hack" I'll implement it in proper way :)

@remdex
Copy link
Contributor

remdex commented Nov 29, 2013

Actually, could you attach your modified file. Like in general I'm not very familiar with this xmpp stuff :), so your help is really appreciated :)

@gituser
Copy link
Author

gituser commented Nov 29, 2013

sure, here is my modified file (dunno how to attach here, so I'm posting to pastebin):

the file is lib/core/lhxmp/lhxmp.php:

http://pastebin.com/pVjXc3nS

@remdex
Copy link
Contributor

remdex commented Nov 30, 2013

Implemented.
http://livehelperchat.com/new-version-1.69v-drag-drop-xmpp-group-messages-index.php-remove-and-some-other-changes-228a.html

In general now you should not have to change core at all. Let me know how it goes or just create another issue :)

@remdex remdex closed this as completed Nov 30, 2013
@gituser
Copy link
Author

gituser commented Dec 13, 2013

hi, after testing it seems its not working how it should.

bot joins the conference but is not sending the link, could you look into it?

@remdex
Copy link
Contributor

remdex commented Dec 13, 2013

Sorry, but i tested standard mesasge send and it worked. You will have to help me to debug in that case what i missed there. I just do not have an environment to test.

@remdex remdex reopened this Dec 13, 2013
@remdex
Copy link
Contributor

remdex commented Dec 13, 2013

Ok,
I have installed openfire will update during a weekend :)

@remdex
Copy link
Contributor

remdex commented Dec 14, 2013

Fixed group part.
7c1334e

@remdex remdex closed this as completed Dec 14, 2013
@gituser
Copy link
Author

gituser commented Dec 16, 2013

Seems to be working fine and pasting the link when there is assigned group for department in the conference.

I'm sorry that I didn't help you to debug this, been busy a bit.

The only thing I noticed that Save button on XMPP settings no longer working for some reason, I had to alter via database (e.g. change a template of message for example).

Can you check this?

Many thanks.

@remdex
Copy link
Contributor

remdex commented Dec 16, 2013

Sorry, but on my enviroment all works. Perhaps you forgot to click "Use standard XMPP service"

@gituser
Copy link
Author

gituser commented Dec 16, 2013

it's set of course.

I'm on the latest revision.

What it could be ? After clicking save it brings back the old settings for some reason. No errors in php_errors.log

@remdex
Copy link
Contributor

remdex commented Dec 16, 2013

No idea,
But try to do the same on demo.livehelperchat.com

@remdex
Copy link
Contributor

remdex commented Dec 17, 2013

Just one idea,

  1. Make sure you have replaced not only tempalte files but also modules
  2. Make sure you have cleared cache from back office

@gituser
Copy link
Author

gituser commented Dec 17, 2013

there was missing design/defaulttheme/tpl/lhkernel/ directory in my branch for some reason..

thats why it didnt work out, now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants