• Hi Kopano Community,

    as part of a customer project, we developed a Kopano WebApp Rocket.Chat plugin, which takes on four tasks:

    1. Integration in the Kopano WebApp as a separate plugin
    2. Username and password are taked from the WebApp login (no separate entry for login and password necessary)
    3. Desktop notification is included
    4. At the Rocket.Chat tab there is a message counter

    You can download the plugin from:
    https://cloud.siedl.net/nextcloud/index.php/s/yoTpCJ6dSs3gre2
    https://cloud.siedl.net/nextcloud/index.php/s/3yKYARgGwfSZe2c
    download and install on your server.

    System requirements:
    KC 8.7.12
    WebApp 3.5.14
    Rocket.Chat 3.1

    Installation (.deb) on the Kopano server:
    dpkg -i kopano-rocketchat-1.0-1.deb
    Adjust /etc/kopano/webapp/config-rchat.php
    Activate the Rocket.Chat plugin for the user in the WebApp
    Rocket.Chat -> Administrator -> Iframe integration -> Allow sending

    Finished

    Have fun testing :-)

    Robert


  • Hi,

    just to clarify:
    Configuring the iframe-Integration needs to be done in Rocket.Chat (as admin), not the WebApp plugin.
    (Under Administration -> General -> iframe-Integration)
    Without the ‘Allow Sending’ set, neither notifications for messages nor the message-counter in the tab-title will work.

    Also there is a known bug, where in DeskApp the message-counter is not loaded correctly on the initial frame load every now and then, but it will correctly update on receiving a message.

    Regards Geri


  • Update:
    Version 1.0.1: https://cloud.siedl.net/nextcloud/index.php/s/MeoZE86QZNGEt5e

    • Added config option for Rocket.Chat installations that are not accessible on the http-root of the configured hostname.
    • Also added some descriptions in the config file.

    Thanks for any feedback.

    Regards, Geri


  • Hi @geri
    Thanks for this! We are big fans of Rocketchat in my organization.
    I however do struggle with getting this plugin to work.
    The plugin does not appear in the plugins list unless i perform a chmod -R 777 /usr/share/kopano-webapp/plugins/rchat
    Also, when I update the config-rchat.php file with my own host, clicking on the menu item does nothing, and actually limits the ability to save any options in the webclient there after unless I perform a webpage reload. I can’t tell anything in the Dev console or logs that there is anything happening.

    Has anyone else experienced such issue?


  • Hi @tiredofit
    My guess would be a connection error between the kopano and Rocket.Chat server (which i missed to handle in my code, hence the update).
    Keep in mind, the kopano-server connects to the Rocket.Chat server directly, so the configured hostname/path needs to accessible from the kopano-server (https, for authentication purposes) and the browser on the client-pc.
    Regarding the chmod issue, did you install the deb file directly on manually unpack it?
    The permissions in the file are set to 755, which should be enough for it to work, since the plugin does not write anything to disk.
    Generally speaking, the user that is running the webserver needs to be able to read the files, no writing is required.
    Also, i case that may explain the permission thing: WebApp plugins are cached in the session, so for them to appear, you need to logout/login again into WebApp, reloading is not enough.

    Also:
    Update 1.0.2: https://cloud.siedl.net/nextcloud/index.php/s/3yKYARgGwfSZe2c

    • Added error handling for connection issues between kopano-server and Rocket.Chat - You should now receive a (more ore less) meaningful error message when clicking the menu entry, instead of nothing happening.

    @kopano staff
    Would it be possible to update the download link in the initial post, i now added a folder link, where new updates will be posted?

  • Kopano

    @geri link updated


  • @fbartels
    Thank you


  • Your plugin ist not working for me. When i click on the RocketChat link i get an error 400: Rocket.Chat - Serverside Error
    Received non-JSON response from https://rocketchat.xxx.local/api/v1/login

    With curl on the same machine API Login works and returns a valid JSON.

    On the rocketchat server i just see the fowllowing in the nging log:

    [23/Jun/2020:10:00:56 +0000] "POST /api/v1/login HTTP/1.0" 400 182 "-" "-"
    [23/Jun/2020:10:01:26 +0000] "POST /api/v1/login HTTP/1.0" 400 182 "-" "-"
    [23/Jun/2020:10:01:33 +0000] "POST /api/v1/login HTTP/1.0" 400 182 "-" "-"
    

    Any ideas? Rocketchat is running with NGINX reverse proxy.


  • I think i found the error. I always set PLUGIN_RCHAT_HOST to https://my.chat.server instead of my.chat.server. But in module.rchat.php i found this line:

    $res = $this->sendPost('https://' . PLUGIN_RCHAT_HOST . '/' . (defined('PLUGIN_RCHAT_PATH') ? PLUGIN_RCHAT_PATH : '') . 'api/v1/login', array('user' => $this->username, 'password' => $this->password));
    

    So i removed https:// in my plugin config. Still not working. So i checked plugin.rchat.php and there https:// was missing.

    function injectPluginSettings(&$data) {
    
        $defaultIcon = PATH_PLUGIN_DIR . '/rchat/resources/icons/icon_default.png';
        $pluginData = array(
          'enable' => PLUGIN_RCHAT_USER_DEFAULT_ENABLE,
          'button-title' => PLUGIN_RCHAT_BUTTON_TITLE,
    -      'url' => 'PLUGIN_RCHAT_HOST . '/' . (defined('PLUGIN_RCHAT_PATH') ? PLUGIN_RCHAT_PATH : ''),
    +      'url' => 'https://'.PLUGIN_RCHAT_HOST . '/' . (defined('PLUGIN_RCHAT_PATH') ? PLUGIN_RCHAT_PATH : ''),
          'autostart' => defined('PLUGIN_RCHAT_AUTOSTART') ? !!PLUGIN_RCHAT_AUTOSTART : false,
          'icon' => defined('PLUGIN_RCHAT_ICON') ? PATH_PLUGIN_DIR. '/rchat/' . PLUGIN_RCHAT_ICON : $defaultIcon
        );
    

    Maybe PLUGIN_RCHAT_HOST should contain the whole url with http(s)://


  • Also working when you set PLUGIN_RCHAT_HOST to https://my.chat.server and change

    $res = $this->sendPost('https://' . PLUGIN_RCHAT_HOST . '/' . (defined('PLUGIN_RCHAT_PATH') ? PLUGIN_RCHAT_PATH : '') . 'api/v1/login', array('user' => $this->username, 'password' => $this->password));
    

    to

    $res = $this->sendPost(PLUGIN_RCHAT_HOST . '/' . (defined('PLUGIN_RCHAT_PATH') ? PLUGIN_RCHAT_PATH : '') . 'api/v1/login', array('user' => $this->username, 'password' => $this->password));
    

    and comment out

    #        'header'  => 'Host: ' . PLUGIN_RCHAT_HOST,
    

    Also working for me.


  • Hi @TheChief79 ,

    Thanks for your detailed analysis of the problem you encountered.
    The reasons why the https:// is hardcoded, were the following:

    • If your rocket.chat installation is not reachable via https, but your WebApp is, you will not be able the open the tab anyhow, since modern browsers security policy do not permit opening insecure pages in iframes inside of secure pages.
      In DeskApp it will still work though, since its not iframes used there, but i’d still recommend SSL encryption.
      (And if WebApp is not SSL encrypted, there’s definitely something wrong tbh)
    • To make it easier on myself to add the proper host-header, which apparently is not required since it works for you even without it behind a proxy, i guess php already adds it itself.

    Also about the missing https:// in plugin.rchat.php:
    I rechecked my source, and all the .deb files available for download and nowhere is the https is missing.
    Could you maybe have removed it earlier in you debugging process and forgot?

    I’ll add the option for the chatserver hostname to work with added http(s):// protocol, and if it is not set add it.
    I’ll do some tests about the host-header beforehand though (and remove it if its really not required), and hopefully be able to implement the following planned features:

    • Cache the rocket.chat session in the WebApp settings, and reuse it if its still valid, so you don’t get a new session everytime (This apparently invalidates other sessions (in your browser for example) if they were not active in some time)
    • Make the desktop notifications when clicked automatically focus the chat-tab (and eventually even the right channel, if possible) in WebApp, instead of only the browser/DeskApp.

    Kind regards, geri


  • Thank you for your answer.

    It could be that i removed https:// by myself while debugging my problem and i understand your explanation. I re-checked your lates .deb and there in both files the “https://” is present. So it seems to be ok. I will re-test with your debs and a clean install of your plugin.

    Thanks for your help.