Support #16887

discourse-gitter integration

Added by Peter Amstutz 4 months ago. Updated 13 days ago.

Status:
Resolved
Priority:
Normal
Assigned To:
Category:
Documentation
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Story points:
-

History

#1 Updated by Peter Amstutz 4 months ago

  • Target version changed from 2020-10-07 Sprint to 2020-10-21 Sprint

#2 Updated by Peter Amstutz 4 months ago

  • Description updated (diff)

#3 Updated by Peter Amstutz 4 months ago

  • Description updated (diff)

#4 Updated by Peter Amstutz 3 months ago

  • Target version changed from 2020-10-21 Sprint to 2020-11-04 Sprint

#5 Updated by Peter Amstutz 3 months ago

  • Target version changed from 2020-11-04 Sprint to 2020-11-18

#6 Updated by Peter Amstutz 3 months ago

  • Target version changed from 2020-11-18 to 2020-12-02 Sprint

#7 Updated by Peter Amstutz 2 months ago

  • Target version changed from 2020-12-02 Sprint to 2020-12-16 Sprint

#8 Updated by Peter Amstutz about 2 months ago

  • Category set to Documentation

#9 Updated by Peter Amstutz about 2 months ago

  • Assigned To set to Ward Vandewege

#10 Updated by Ward Vandewege about 1 month ago

Changes I made:

1) use the correct upstream repo for the plugin (https://github.com/discourse/discourse-chat-integration instead of https://github.com/JafethDC/discourse-chat-gitter.git which wasn't changed in the last 3 years). This is a salt change.

2) upgraded the discourse base docker image with

discourse-arvados-org-1:/srv/discourse# ./launcher rebuild app

3) set up a "custom integration" on the gitter side (arvados channel), cf. https://meta.discourse.org/t/set-up-gitter-notifications-using-the-discourse-chat-integration-plugin/69220. I tried the "discourse" integration, but the ping test fails with it. I also cleaned out the 5 (!) integrations that were configured there, and were not working.

4) configured a web hook on the discourse side with that URL. Enabled topic_event and post_event. Tested with a 'ping', which worked from the discourse perspective.

The integration should show up in the gitter sidebar, when a new topic is created or there is a 'post' event (reply on topic, etc).

I'll leave this ticket in 'feedback' state until something happens on the discourse forum that should generate an event in our gitter channel. Then we'll see if it works.

#11 Updated by Ward Vandewege about 1 month ago

  • Status changed from New to Feedback

#12 Updated by Peter Amstutz about 1 month ago

  • Target version changed from 2020-12-16 Sprint to 2021-01-06 Sprint

#13 Updated by Ward Vandewege 14 days ago

Well, a few things happened on the forum, but the integration didn't work. That is, discourse is showing the webhook fired, but the information didn't show up on gitter.

Maybe the 'discourse' integration on the gitter side is what we need after all, perhaps the 'ping' test is not supported?

Now that we have some old actions in the webhook that we can replay, I tested that theory. I created a new integration on the gitter side, and updated the webhook on the discourse side accordingly. I then replayed one of the 'new post' webhook calls, no dice:

Headers:

Content-Security-Policy: frame-ancestors 'self' https://gitter.im
Content-Type: application/json; charset=utf-8
Date: Tue, 05 Jan 2021 15:42:36 GMT
ETag: W/"17-i22p4FL6eG9sZYzIFCm/xvy/pHM" 
Server: nginx
set-cookie: connect.sid=s%3A3nw3Q1KQw1hSR4uB773L0NTehgi8plyt.PAtUt2m7lnwaRypSUmdgBU9v2CxWIpRGes%2F%2FRvCuS3s; Path=/; HttpOnly
Vary: X-HTTP-Method-Override
X-Frame-Options: allow-from https://gitter.im
X-Powered-By: Express
Content-Length: 23
Connection: Close

Body:

{"error":"Bad Request"}

I changed the payload type from application/json to application/x-www-form-urlencoded, no difference:

Content-Security-Policy: frame-ancestors 'self' https://gitter.im
Content-Type: application/json; charset=utf-8
Date: Tue, 05 Jan 2021 15:46:20 GMT
ETag: W/"17-i22p4FL6eG9sZYzIFCm/xvy/pHM" 
Server: nginx
set-cookie: connect.sid=s%3AUl6q3N-hSg1cv7ytxIxNw8N_IL3gPvfr.NzV0g6ZI86vKZmp9Q2mcEip1svI0a78XCECyS1Wh7i4; Path=/; HttpOnly
Vary: X-HTTP-Method-Override
X-Frame-Options: allow-from https://gitter.im
X-Powered-By: Express
Content-Length: 23
Connection: Close

Body:

{"error":"Bad Request"}

The gitter instructions for a 'custom' integration state:

Accepts form or json encoded messages to display in the activity feed.

message (required): the message that you want to be displayed (in markdown).
level (optional): what level of message. Can be info or error, but default is info. This only affects styling.

e.g simple post:
curl -d message=hello your_url

e.g error levels:
curl -d message=oops -d level=error your_url

e.g markdown:
curl --data-urlencode "message=_markdown_ is fun" your_url

I dumped the traffic, and this is what is being sent (with 'application/x-www-form-urlencoded' selected on the webhook, clearly that doesn't work, it's just sending json, but whatever):

POST /e/EDITED HTTP/1.1
Host: webhooks.gitter.im
User-Agent: Discourse/2.7.0.beta1
Accept: */*
Connection: close
Content-Length: 1013
Content-Type: application/json
X-Discourse-Instance: https://forum.arvados.org
X-Discourse-Event-Id: 7
X-Discourse-Event-Type: topic
X-Discourse-Event: topic_created

{"topic":{"id":66,"title":"Invite for CWL Virtual MiniConference, January 11-13th 2021","fancy_title":"Invite for CWL Virtual MiniConference, January 11-13th 2021","posts_count":1,"created_at":"2020-12-16T18:18:40.306Z","views":0,"reply_count":0,"like_count":0,"last_posted_at":"2020-12-16T18:18:40.663Z","visible":true,"closed":false,"archived":false,"archetype":"regular","slug":"invite-for-cwl-virtual-miniconference-january-11-13th-2021","category_id":8,"word_count":449,"deleted_at":null,"user_id":6,"featured_link":null,"pinned_globally":false,"pinned_at":null,"pinned_until":null,"unpinned":null,"pinned":false,"highest_post_number":1,"deleted_by":null,"has_deleted":false,"bookmarked":false,"participant_count":1,"thumbnails":null,"created_by":{"id":6,"username":"tetron","name":"Peter Amstutz","avatar_template":"/letter_avatar_proxy/v4/letter/t/ebca7d/{size}.png"},"last_poster":{"id":6,"username":"tetron","name":"Peter Amstutz","avatar_template":"/letter_avatar_proxy/v4/letter/t/ebca7d/{size}.png"}}}

So it's not surprising that the 'custom' integration doesn't actually work. It's not so cool that it just returns 'OK' (200) for any payload, but whatever.

So, looking at the receiving side on the gitter end, that plugin (https://gitlab.com/gitterHQ/services/-/blob/master/lib/discourse/) seems to expect something just like the custom plugin, see e.g. https://gitlab.com/gitterHQ/services/-/blob/master/lib/discourse/examples/normal.json

{
    "headers": {},
    "body": {
        "message": "[__jafeth.diazc__ - Gitter integration for Discourse - [dev]](https://meta.discourse.org/t/gitter-integration-for-discourse/65881)" 
    }
}

Well, the custom plugin also supports log levels. I'm not even sure why the discourse plugin exists on the gitter side, it seems to be a functional subset of the custom plugin.

#14 Updated by Ward Vandewege 13 days ago

  • Status changed from Feedback to Resolved

Okay, I finally figured it out, I was doing the configuration wrong on the Discourse side.

First I updated our Discourse again:

discourse-arvados-org-1:/srv/discourse# ./launcher rebuild app

Then I noticed that there is really a "Create Channel" button on the https://forum.arvados.org/admin/plugins/chat/gitter page, which the instructions at https://meta.discourse.org/t/set-up-gitter-notifications-using-the-discourse-chat-integration-plugin/69220 tell you to use to configure the Gitter integration.

So the reason the webhook didn't work, was that it's the wrong kind of integration. I deleted the web hook configuration in Discourse, and hit the 'Test' button once creating the channel, and the selected activity showed up on Gitter. Problem solved!

Also available in: Atom PDF