65 Commits

Author SHA1 Message Date
Kévin Commaille
e5705e74c0
Add support for reopened GitLab MR (#935)
* Add support for reopened GitLab MR

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

* Add changelog

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-05-22 11:05:14 +00:00
Will Hunt
cf689919a4
Fix tokens encrypted with Node crypto implementation being undecryptable in new Rust implementation. (#930)
* Encrypt with new padding algo when possible.

* formatting

* changelog
2024-04-17 10:00:00 +00:00
Will Hunt
ff200114a6
Fix PKCS1 handling (#929)
* Support pkcs1 format keys.

* Test pkcs1 support.

* changelog

* rust formatting
2024-04-16 21:05:36 +00:00
Will Hunt
6482c7ed55
Handle RSA token handling in Rust (#915)
* Split out queue and cache config

* Update usages of cache config,

* Update default

* Cleanup

* Make queue optional.

* config updates.

* changelog

* update spec config

* Update tests

* tweak import

* Update default config.

* fixup test

* Update config.sample.yml

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* Update encryption.md

Signed-off-by: Will Hunt <will@half-shot.uk>

* Clear up worker config

Signed-off-by: Will Hunt <will@half-shot.uk>

* Update src/config/Config.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* update helm config

* move UserTokenStore.ts

* Port all the imports to new path.

* Port RSA handling to rust.

* Add tests.

* linting

* lint rust

* Remove unwraps / panics

* fix build script

* Ensure we store and check with algorithm and key was used.

* quieten false deadcode warnings

* changelog

* fix test imports

* lazy mock out UTS

* Refactor so that UserTokenStore is initiated by the time Bridge is created.

* update defaults

* replace if with match

* Use the magic of ?

* fmt

---------

Signed-off-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2024-04-08 15:22:57 +01:00
Will Hunt
082a61f802
Split cache config from queue config. (#902)
* Split out queue and cache config

* Update usages of cache config,

* Update default

* Cleanup

* Make queue optional.

* config updates.

* changelog

* update spec config

* Update tests

* tweak import

* Update default config.

* fixup test

* Update config.sample.yml

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* Update encryption.md

Signed-off-by: Will Hunt <will@half-shot.uk>

* Clear up worker config

Signed-off-by: Will Hunt <will@half-shot.uk>

* Update src/config/Config.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
Signed-off-by: Will Hunt <will@half-shot.uk>

* update helm config

* lint

* fix meta

* tidy tidy

* revert logging change

* lint rust

---------

Signed-off-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2024-03-19 16:45:52 +00:00
Will Hunt
c09f00e2a3
Fix Atom feed hashing format. (#901)
* Ensure atom feeds hash and prefix

* Add some fixing code for this.

* Remove feed fixer

* Refactor RSS feed tests a bit

* Add tests to ensure hashes do not change

* changelog
2024-02-21 16:13:36 +00:00
Will Hunt
387f7c1ce9
Backoff failing RSS feeds (#890)
* Backoff RSS requests if a url repeatedly fails.

* Increase max backoff time to a day

* Add backoff for failing feeds.

* Remove unused finally

* Add this.feedLastBackoff

* Rewrite in rust.

* linting

* pop

* Optimise backoff function further

* Drop only!

* fix test

* lint

* lint further

* Better comments

* Fix urls calculation

* Remove testing URL

* Add some variance to speed up while loop

* correct comment

* Follow the advice and use a VecDeque as it's slightly faster.

* Vastly better shuffle method

* Speed up checking for previous guids.

* fix hasher function

* lint

* Content doesn't need to be calculated twice.

* Slightly more efficient iteration

* Improve performance of backoff insertion

* Configure feed reader

* lint

* Ensure appending and removing from the queue works as expected.

* Ensure we do keep urls that have been removed.

* lint

* Inc/dec metrics as queue items are added/deleted.

* Add comment

* tidy up
2024-02-20 22:21:19 +00:00
Will Hunt
90927a71f4
Add support for mentioning multiple assignees on GitHub issues (#889)
* Add support for multiple assignees on issues

* changelog
2024-02-06 10:09:21 +00:00
Will Hunt
8e115b40ab
Add End to End testing (#868)
* Ensure connection state always explicitly states all keys, even if some are undefined.

* changelog

* Fix type

* fix test types

* Add support for E2E testing

* Add CI job for e2e test

* Ensure integration test only runs when regular tests complete

* Add homerunner image

* Disallow concurrent runs

* Add concurrency to other expensive steps

* changelog

* Fix mq test

* Cache rust deps

* Drop only

* Use a shared key
2023-12-28 15:04:03 +00:00
Will Hunt
46d198c2c0
Fix feeds template / notify state not reflecting in the UI (#866)
* Ensure connection state always explicitly states all keys, even if some are undefined.

* changelog

* Fix type

* fix test types
2023-12-28 14:27:47 +00:00
Will Hunt
c3cb131e4d
Fix top level return incompatibility (#818)
* Run transformation functions at top level

* changelog
2023-09-26 12:56:11 +00:00
Will Hunt
dc126afa6a
Replace vm2 with quickjs (#817)
* quickjs test

* Replace vm2 with quickjs

* initalise -> initialise

* Remove unused transformation timeout time

* Don't assume quickModule is set

Also use whether it's set as the indicator of whether transformation
functions are allowed, instead of checking the config

* Refactor GenericHookConnectionState validation

- Do it in the constructor instead of in callers
- Make hookId mandatory so as to not drop it on some state updates
- Conflate a state event's state key with a connection state's name,
  which was already the case in practice

* Refactor validateState

* Drop explicit any

Better to infer the type instead

* Always validate transformation fn

* Fix test

* Add changelog

* Fix disposal, validation, and printing

* Fix transformation error string formatting

Also refactor similar code

* Let invalid transformations run & fail

instead of pretending that one was never set

* Restore transformation timeout time

* Don't execute transformation fn when validating it

Instead, only compile it

* Revert unrelated changes

---------

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-09-25 14:55:15 +00:00
Tadeusz Sośnierz
a64a561698
Bridge Gitlab comment replies as Matrix threads (#758)
* Bridge Gitlab comment replies as Matrix threads

* Persistently store Gitlab Discussion-Thread mapping

* Remove leftover debug line

* Denoise comment descriptions when they happen in Matrix threads

* Make comment debouncing time configurable

* Add some tests for Gitlab comments

* De-only Gitlab comment tests

* Linting

* Changelog

* Map multiple Gitlab discussions to a single Matrix thread

We debounce Gitlab comments, so multiple discussions can end up in one thread.
This ensures that replies to *any* of these discussions end up in the same thread.

* Add tests for the many-to-one reply case

* Move SerializedGitlabDiscussionThreads to Types

* Update changelog.d/758.feature

Co-authored-by: Will Hunt <will@half-shot.uk>

* Fix instructions for validating your config using Docker (#794)

* Fix instructions for validating your config using Docker

Fixes GH-787

* Changelog

---------

Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>

* Add more icons to GitHub messages (#795)

* Add more icons to GitHub messages

* Add merged icon

* Lint

* Add changelog

* Bump word-wrap from 1.2.3 to 1.2.4 (#799)

* Bump word-wrap from 1.2.3 to 1.2.4

Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add changelog

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>

* Update matrix-appservice-bridge to 9.0.1 (#800)

* Bump semver from 5.7.1 to 5.7.2 (#797)

Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Will Hunt <will@half-shot.uk>

* 4.4.0

* 4.4.1

* Set the default commentDebouncMs for Gitlab in its Config

* Rename `approvalState` to something more fitting

* Update sample config

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Co-authored-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Connor Davis <mail@connordav.is>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-08-14 12:58:21 +00:00
Will Hunt
3217b9eecf
Performance improvements to Feeds (#786)
* Various smaller changes

* Drop account data entirely

* Use max feed items

* Commit known working improvements

* Better status handlingh

* changelog

* Update changelog

* Add a note on Redis.

* Add proper HTTP tests

* Linty lint

* Tweaks

* New metrics woah

* Tweaks
2023-06-28 15:29:54 +00:00
Will Hunt
466ab6d5e3
Allow sanitized HTML from feed summaries (#738)
* Add a function to sanitize html output

* Allow some HTML in feed messages

* Update cargo

* changelog

* lint

* Saved a ton of code by just using ruma.

* Reverse order of rs:apply

* Lint

* Update src/Connections/FeedConnection.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>

* Apply suggestions from code review

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>

* Add a test for partial html

---------

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2023-05-18 18:59:58 +00:00
Will Hunt
d772a4050c
Run Clippy in CI (#753)
* Clippy fixes

* Refactor to make rust linter happy

* Enable warnings since we have none

* Tidy up tests

* changelog
2023-05-18 11:38:59 +01:00
Will Hunt
7223a86b2b
Fix message format for feed items with no title or link (#737)
* Allow empty title on feed item

* Allow bare URL

* Add tests for new format.

* changelog
2023-05-04 09:34:25 +01:00
Will Hunt
43176adf7a
Fallback to parsing feeds as atom format if rss format fails. (#721)
* Support atom feeds in rust parser

* Add an apply linting command

* Add changelog

* Fixup

* Add tests for atom feeds + remove redundant code

* Remove unused rss-parser

* Tests for all formats.

* Move hashing logic into rust to save cross-context calls

* lint my rust

* Use a String::from

* Ensure guids are not repeated
2023-04-25 15:45:55 +00:00
Will Hunt
a9537c7961
Add option to enable/disable feed failure notices. (#716)
* Add new notifyOnFailure option

* Disable state buttons when updating is set

* Linting
2023-04-21 10:47:29 +00:00
Tadeusz Sośnierz
bc57dbbc83
Don't process feed/item titles that aren't actually strings (#708)
* Don't process feed/item titles that aren't actually strings

Another case of empty-tag with attributes, these would occasionally parse
into non-string objects and make us crash when trying to stripHtml on them.

* Changelog

* Add tests for not-quite-empty <title> tags in feeds

---------

Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>
2023-04-12 17:52:10 +02:00
Will Hunt
6345ad2347
Add support for templating feed messages (#702)
* Add support for specifying a template for feeds

* Remove unused params

* use the correct url

* make URL visible.

It was annoying me

* Update src/Connections/FeedConnection.ts

Co-authored-by: Tadeusz Sośnierz <tadzik@tadzik.net>

* Support migrations

* Hopefully support migrations now

* lint

---------

Co-authored-by: Tadeusz Sośnierz <tadzik@tadzik.net>
2023-04-11 15:24:00 +00:00
Will Hunt
6233aa19c9
Refactor hookshot to include permission grant system (#655)
* Add support for checking connection grants

* Make this less noisy

* Remove import

* Trying to generic-ize the grant system

* Implement for Figma

* More grant reformatting

* Add tests

* changelog

* Fix todo

* Refactor grants

* Add logging to grant checkers

* Ensure we provide a sender
2023-03-17 16:38:39 +00:00
Will Hunt
55529d7128
Add support for OAuth login to GitHub via widget (including adding new installations) (#661)
* WIP

* Update vite

* Add oauth landing page

* Add API support for GitHub oauthing

* Remove console.logs

* Add support for logging and and out of GitHub

* Add bridge API methods

* Add base link styling

* Sugar syntax main get

* Update vite

* changelog

* Review changes

* Use instance to match UI

* lint

---------

Co-authored-by: Justin Carlson <justinc@element.io>
2023-03-14 10:50:46 +00:00
Michael Weimann
1b51189db1
Fix generic webhook 'user is already in the room error' (#627)
* Fix generic webhook 'user is already in the room error'

* Add changelog

* Cleanup to support usecases without slamming the homeserver.

* Fix fallthrough

* Add some tests

* Add tests for intentutils

* Refactor the rest of the app

Co-authored-by: Half-Shot <will@half-shot.uk>
2023-01-16 14:58:23 +00:00
Justin Carlson
9a7839ce42
Implement separate bot users per service (#573)
* Add service bots config

* Add joined rooms manager and keep track of joined rooms

* Add bot users manager and ensure registration and profiles

* Improve joined rooms manager and set up already joined rooms

* Handle invites with service bots

* Handle messages with service bots

* Use service bots for connections

* Use service bots in widget and provisioning APIs

* Use service bots in setup connections

* Use service bots for feed connections

* Handle admin rooms for service bots

* Fix confused event type and service type in provisioning and widget APIs

* Fix generic webhooks service name

* Fix enabled services config

* Handle power level change

* Create widgets with service scope

* Use service bots for gitlab repo connections

* Use service bots for gitlab issue connections

* Use service bots for generic webhook connections

* Use service bots for figma file connections

* Use service bots when verifying state events

* Use service bots for github repo connections

* Use service bots for github discussion connections

* Use service bots for github discussion space connections

* Use service bots for github project connections

* Use service bots for github issue connections

* Use service bots for github user space connections

* Use service bots for jira connections

* Make sure ghost users are invited for gitlab issue comments

* Configure one service per service bot

* Add changelog

* Update tests

* Fix up following rebase

* Fix comment

* Use getter for enabled services

* Ensure homeserver can be reached before registering bots

* Add intent getter on bot user

* Update config comment

* Merge joined rooms manager with bot users manager

* Remove unused localpart from bot user class

* Refactor to pass in bot users manager

* Improve priority sort function

Co-authored-by: Christian Paul <christianp@matrix.org>

* Fix priority sort

Higher priority should come first

* Add debug log when invites are rejected

* Use different state key for scoped setup widgets

* Use different subtitles to differentiate service bots setup widgets

* Refactor bot user setup into bot users manager

* Refactor to reduce duplication in widget API

* Consistent room ID and intent args order

* Add docs and update changelog

* Add overrideUserId deprecation warning

* Add service bots link

Co-authored-by: Christian Paul <christianp@matrix.org>
Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-13 15:32:09 +00:00
Will Hunt
1e8a112a28
Drop ignoreHooks configuration. (#592)
* Refactor HookFilter to only support enabledEvents (and add a function to convert)

* Convert connections to deprecate ignoreHooks

* Update documentation

* Split out EventHookCheckbox

* Refactor frontend to support enableHooks only mode

* drop old field name

* changelog

* Fix enabledHooks for widgets

* Fixes across the board

* Update test description

* Cleanup

* Fix HookFilter

* Fixup checkboxes

* Cleanup
2023-01-10 17:08:50 +00:00
Will Hunt
0c9bbf6410 Disable GitHub workflow events by default (#528)
* Add a HookFilter class

* Use the HookFilter class

* Support default hooks in the web UI

* Update documentation

* changelog

* Allow all GitLab events by default

* bits of cleanup
2022-10-21 11:30:16 -04:00
Will Hunt
db3caeae03 Use matrix-appservice-bridge logging (#488)
* Use matrix-appservice-bridge logger

* Update to be in line with bridge sdk

* Update packages

* changelog

* nits
2022-10-06 09:30:31 +01:00
Will Hunt
d85f2fd540
Add Logger tests (#478)
* More json logger safety

* Don't log undefined

* typo

* Split out the static logger to it's own class for testing

* Refactor logger usage slightly

* Add a test for the logger wrapper

* changelog

* Update LogWrapper.ts

* Drop ?
2022-09-14 11:26:34 +00:00
Will Hunt
00e5bfe332
Fix markdown paragraphs not rendering properly (#443)
* Fix markdown paragraphs not rendering properly

* changelog
2022-08-18 15:41:07 +01:00
Will Hunt
ff1079aa3b
Fix floating values breaking generic webhooks (#396)
* Convert floats to strings for generic webhook payloads

* document the change

* Create 396.bugfix
2022-07-07 17:44:11 +01:00
Will Hunt
c36a5e7d60
Fix oauth login urls for GitHub cloud having the wrong domain (#377)
* Ensure we use a single function for generating oauth urls

* Add tests

* changelog

* Fix test
2022-06-27 15:17:01 +01:00
Tadeusz Sośnierz
86b9a83b97
Add Admin command from listing and disconnecting connections (#367)
* Add Admin command from listing and disconnecting connections

(Only lists Github for now).

* Require connectionManager permissions to manipulate connections

Gives connection management its own config section and switches
AdminRoom categories to be enums.

* Fail more descriptively if connectionManager is not up in time for adminRoom

* Fix Github API URLs (#366)

* Fix Github API URLs

* Add changelog entry

* Fixes

* Tidyup

Co-authored-by: Will Hunt <will@half-shot.uk>
Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>

* Fix URLs *again*

* Block private repos from being publically bridged

* Ensure check looks at service type

* Finish up deleting connections impl

Co-authored-by: Tadeusz Sośnierz <tadeusz@sosnierz.com>
Co-authored-by: Will Hunt <will@half-shot.uk>
2022-06-08 15:50:09 +00:00
Will Hunt
21b6d79c3f
Support GitHub Enterprise (#364)
* Support GitHub Enterprise

* Add default config

* Fixes

* Hide enterprise key
2022-05-25 11:07:07 +01:00
Will Hunt
9b216afd2b
Fix GitHub/GitLab state config not being honoured (#346)
* 1.6.1

* Add new error type for validation errors

* Validate state for GitHubRepo properly

* Add tests to check labels

* Also check GitLab repo

* changelog

* add mock store

* remove nullable

* Be less strict for existing state

* Improve test coverage

* Improve expect error text

* ValidationApiError now takes falsey objects and errors on them

* Remove UserTokenMockStore

* Actually commit the new tests

* Whoops we need to include github
2022-05-12 11:28:55 +01:00
Will Hunt
b23e516aa5
Statically define connection creation and provisioing (#330)
* Statically define connection creation and provisioing

* Tidy up

* Drop JIRA

* Convert other connections to new system

* Small linting fixes

* Fixes

* changelog

* Fix bridge

* Fix JIRA instance naming

* Fix JIRA config

* Drop unnessacery check
2022-05-06 13:58:39 +00:00
Half-Shot
3a766190f5 fix a test 2022-04-08 16:35:55 +01:00
Will Hunt
aa9e066530
Add Generic Webhooks Widget interface (#140)
* Start work on improved widget interface for admin room

* Add changes needed for InviteView

* More widget bits

* Lots more work to support setup widgets

* Redesign work

* Fix build order for web

* Remove unused invite code

* Update configs

* Cleanup

* Support widget branding

* Tidy up web app

* Support generic service config lookup

* Stronger typings for configuration

* Improve error text

* fix patch

* changelog

* First pass on documentation

* Fix tests

* fixes

* Don't require room state / admin rooms for room config requests

* Fix no render when secrets isn't provided

* rework if logic

* Fixes after feedback

* more review fixes

* Cleanup unused code

* fix indent

* Update matrix-appservice-bridge to 4.0.1

* Update widget API
2022-04-08 16:16:12 +01:00
Will Hunt
7837cbb0f2
Refactor JIRA to support on-prem (#187)
* JIRA refactors

* Support JIRA onprem

* Fix webhooks

* More JIRA docs --- PLEASE REWRITE MEEEE ---

* Drop manifest code for now

* Add on-prem instructions

* Remove incomplete command

* Update sample config

* Remove null url
2022-03-04 14:34:44 +00:00
Will Hunt
f6cbc9481e
Prettify JSON output of generic hooks (#224)
* Pretty print JSON output from webhooks

* Fixup supported body encodings

* changelog

* Fix tests
2022-03-04 13:36:08 +00:00
Will Hunt
01d3d96f12
Add support for a "v2" webhook transformation API (#223)
* Add support for a "v2" webhook transformation API

* changelog
2022-03-03 19:16:17 +00:00
Half-Shot
7e2ffdd2df Argh permissions bug 2022-01-17 10:04:23 +00:00
Will Hunt
5b294bc05f
Add support for a tiered permission system (#167)
* Add basic permission model

* Add permission mapping implementation

* Start integrating config checks

* Add permission checking for commands

* Add warnings for legacy behaviour

* changelog

* Linting

* Fix config build step

* Tests

* Add documentation

* Add complete tests

* Add documentation

* Add room for room membership permissions

* Fixup error

* Update sampleConfig
2022-01-14 17:44:15 +00:00
Will Hunt
0c4b911a70
Support categorising bot commands (#143)
* Support categorising bot commands

* changelog

* Fix tests
2022-01-10 21:41:54 +00:00
Will Hunt
5e497d7371
Support html key on generic webhooks (#130)
* Add support for `html` key on generic webhooks

* Document key

* changelog

* Add tests
2022-01-06 13:20:29 +00:00
Will Hunt
9030581de2
Port getPartialBodyForGithubIssue to rust (#126)
* Port getPartialBodyForGithubIssue to rust

* Port repo function too

* Improve safety

* changelog
2022-01-05 10:54:32 +00:00
Will Hunt
d575e5fb2f
Add documentation on various things (#90)
* Add details on webhooks

* More doc things

* More docs

* More documentation changes

* Tidy tidy

* Lots more documentation

* Support defaults for all GitHub configuration options

* Add metrics changes

* s/Added/Add
2021-12-21 16:41:19 +00:00
Will Hunt
e8525e7431 Add some tests for GenericHook 2021-12-18 16:58:23 +00:00
Will Hunt
68ea138d63 Fix tests 2021-12-02 13:37:46 +00:00
Will Hunt
b6e37947bd Refactor code to use BaseConnection and make the connectionIds simpler 2021-12-02 12:34:43 +00:00