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

feat: Matrix integration #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat: Matrix integration #106

wants to merge 2 commits into from

Conversation

edwargix
Copy link

Matrix is an open, federated messaging platform: https://matrix.org

ArgoCD Notifications would benefit greatly from Matrix support because a growing number of communities use it daily. Additionally, Matrix has interoperability with many other messaging platforms via bridges, which would give ArgoCD indirect support for notifications to those platforms:

A full list of bridges can be found at https://matrix.org/bridges

Signed-off-by: David Florness [email protected]

@codecov
Copy link

codecov bot commented Sep 17, 2022

Codecov Report

Patch coverage: 7.36% and project coverage change: -1.40 ⚠️

Comparison is base (3446d4a) 53.53% compared to head (47e79a1) 52.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
- Coverage   53.53%   52.13%   -1.40%     
==========================================
  Files          34       35       +1     
  Lines        3026     3113      +87     
==========================================
+ Hits         1620     1623       +3     
- Misses       1166     1249      +83     
- Partials      240      241       +1     
Impacted Files Coverage Δ
pkg/api/config.go 47.74% <0.00%> (-3.22%) ⬇️
pkg/services/matrix.go 0.00% <0.00%> (ø)
pkg/services/services.go 26.54% <0.00%> (-0.78%) ⬇️
pkg/cmd/template.go 61.94% <63.63%> (-1.27%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pasha-codefresh
Copy link
Member

@edwargix could you please solve merge conflicts?

@edwargix
Copy link
Author

edwargix commented Nov 30, 2022

@edwargix could you please solve merge conflicts?

Sure thing; just rebased: matrix.pr-0..matrix.pr-1

@edwargix
Copy link
Author

looks like #128 was just merged; will rebase again...

@edwargix
Copy link
Author

edwargix commented Nov 30, 2022

rebased: matrix.pr-1..matrix.pr-2

@edwargix
Copy link
Author

edwargix commented Nov 30, 2022

moved indirect dependencies to correct location: matrix.pr-2..matrix.pr-3

@pasha-codefresh
Copy link
Member

Thanks @edwargix , going to review this one

docs/services/matrix.md Outdated Show resolved Hide resolved
if len(parts) > 1 {
dest.Recipient = parts[1]
var before, after string
if i := strings.Index(recipient, ":"); i >= 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please comment why you need change this ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR supports sending Matrix messages to Matrix rooms and room aliases.

A Matrix room is identified with the syntax !opaque_id:domain.tld [0] and a room alias with #room_alias:domain.tld [1].

So the code change here in pkg/api/config.go is to make it so that the domain.tld part isn't lost. Here's an example config; notice that the recipients have two :s in them:

notifications:
  notifiers:
    service.matrix: |
      accessToken: $matrix-token
      deviceID: $matrix-deviceid
      userID: $matrix-userid

  subscriptions:
    - recipients:
        - 'matrix:#my-room-alias:example.org'
        - 'matrix:!my-room-id:example.org'
      triggers:
        - on-deployed
        - on-health-degraded
        - on-sync-failed
        - on-sync-running
        - on-sync-status-unknown
        - on-sync-succeeded

Without this PR's change to pkg/api/config.go, we'd lose the example.org from the recipients and our Destinations for the Send function would be #my-room-alias and !my-room-id (which we can't send notifications to).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm hoping is that once this project upgrades to golang 1.18, we can revert this PR's 2nd commit to simplify the code a bit.

@edwargix edwargix force-pushed the matrix branch 2 times, most recently from dacdf61 to 8e7fced Compare December 1, 2022 00:56
@edwargix
Copy link
Author

edwargix commented Dec 1, 2022

rebased: matrix.pr-4..matrix.pr-5

@edwargix
Copy link
Author

edwargix commented Dec 2, 2022

rebased: matrix.pr-5..matrix.pr-6

@edwargix
Copy link
Author

edwargix commented Dec 4, 2022

rebased: matrix.pr-6..matrix.pr-7

@pasha-codefresh
Copy link
Member

Will take a look today a bit later

@edwargix
Copy link
Author

rebased: matrix.pr-7..matrix.pr-8

@edwargix
Copy link
Author

rebased: matrix.pr-8..matrix.pr-9

@edwargix
Copy link
Author

@pasha-codefresh let me know if there's anything I can do to help

@edwargix
Copy link
Author

rebased: matrix.pr-9..matrix.pr-10

@edwargix
Copy link
Author

rebased: matrix.pr-10..matrix.pr-11

@edwargix
Copy link
Author

rebased: matrix.pr-11..matrix.pr-12

@edwargix
Copy link
Author

rebased: matrix.pr-12..matrix.pr-13

edwargix added 2 commits June 24, 2023 13:14
Matrix is an open, federated messaging platform: https://matrix.org

ArgoCD Notifications would benefit greatly from Matrix support because a growing
number of communities use it daily.  Additionally, Matrix has interoperability
with many other messaging platforms via bridges, which would give ArgoCD
indirect support for notifications to those platforms:

- Rocket.Chat https://matrix.org/blog/2022/05/30/welcoming-rocket-chat-to-matrix
- Gitter https://matrix.org/blog/2020/12/07/gitter-now-speaks-matrix
- IRC https://matrix.org/bridges/#irc

A full list of bridges can be found at https://matrix.org/bridges

Signed-off-by: David Florness <[email protected]>
Looks like that function was added in go 1.18 but this project is using go 1.17

https://pkg.go.dev/[email protected]#Cut

Signed-off-by: David Florness <[email protected]>
@edwargix
Copy link
Author

rebased: matrix.pr-13..matrix.pr-14

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

Successfully merging this pull request may close these issues.

2 participants