434 Commits

Author SHA1 Message Date
Will Hunt
b8bb51fd1f
Fix service bots not rejecting invites on incoming DMs (#659)
* Manually send a reason on a leave for now

* changelog
2023-03-14 22:35:16 +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
Will Hunt
d602c895f3
Fix hookshot showing connections as editable when the user has no permission (#660)
* Fix getConnectionsForRequest reporting canEdit=true if the user has the
default or greater PL

* changelog
2023-03-14 10:48:53 +00:00
Will Hunt
80ccb0c877
Use replace uuid package with crypto.randomUUID (#640)
* Use randomUUID over uuid

* changelog

* Fix mess
2023-02-10 11:14:21 +00:00
Will Hunt
88273a249b
New project picker component for room configs (#624)
* Implement new Dropdown component

* Apply field styling to search too

* General improvements to GitLabClient

* Add support for storing small base64 files in the storage provider

* Refactor GitLab repo to use new connection provider

* Start trying to deduplicate code

* Begin refactor to support ConnectionSearch

* Add support for GitHub searching

* Refactor GitLab/GitHub into components

* Port Jira to ConnectionSearch

* Drop unused functions

* Hide connection list if no connections are present.

* Cleanups

* Cleanup abort controller

* changelog

* Update JIRA for search powers
2023-01-20 13:16:11 +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
Michael Weimann
469e88f9ba
Add webhook name and room to admin info (#620)
* Add webhook name and room to admin info

* Add changelog

* Escape room Id in webhook admin message

Co-authored-by: Will Hunt <will@half-shot.uk>
2023-01-16 10:51:36 +00:00
Michael Weimann
e7a6cfcef4
Fix state update validation (#628)
* Fix state update validation

* Add changelog
2023-01-16 10:48:24 +00:00
Christian Paul
67fc55af93
Change URL protocol in the ocumentation and sample configs to HTTPS (#623)
* Config: Use variables for similar values
* Configs and Documentation: http -> https, except for localhost
2023-01-13 16:39:34 +01: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
4048cc8b01
Check the GitLab instance name when looking for existing connections (#617)
* Check the GitLab instance name when looking for existing connections

* changelog
2023-01-10 10:42:05 +00:00
Will Hunt
a5ea88578c
Decrease connection creation concurrency when starting up (#614)
* Add a queue system for loading connections on startup

* Retry state requests

* Add ability to retry on some matrix failures

* Add the queue

* changelog

* Add docstring
2023-01-09 17:57:24 +00:00
Will Hunt
abe4fefda4
Mark encryption as experimental (#610)
* Update config to mark encryption support as experimental

* Mention encryption as experimental in docs

* changelog

* Hide empty values from config

* transmuate snakes into camels
2023-01-05 16:25:48 +00:00
Will Hunt
2eadc1c9d7
Increase maximum size of webhook payload. (#606)
* Increase maximum size of webhook payload.

* Create 606.misc
2023-01-04 12:04:58 +00:00
Will Hunt
c962f17a91
Add support for native e2ee (#299)
* Add support for native e2ee

* Various temps to coax it into working

* Formatting nitpicks

* Include stable registration config key for msc2409

* Update default config with encryption options

* Manage admin rooms with bot-sdk DMs

This also enables encryption for new admin rooms when appropriate.

* Update config comments for encryption settings

- Add comment to clarify Redis (the `queue` section) must be configured
  in order for encryption to work
- Mention that the `encryption` section is optional, and omitting it
  will disable encryption support

* Update docs for encryption support

* Add changelog

* Add to docs some notes about encryption state

* Move all post-join logic to onRoomJoin

* Block post-join actions on crypto setup

Requires https://github.com/turt2live/matrix-bot-sdk/pull/269

* Fix linter error

* Update encryption docs and changelog

- Mention that worker mode isn't supported with encryption yet
- Mention removal of Pantalaimon-based encryption

* Update worker docs with encryption config notice

* Share main appservice config with feed bots

This is required to safely enable encryption for the bots that post
GenericHook messages.

* Make slight clarification for queue config

* Minor fixes

* Block post-join actions on feed bot crypto setup

Same as a9e6e11d but for the sub-bots that post GenericHook messages.

* Get joined rooms from intent instead of bot

This refreshes the list of known rooms for crypto events.

* Use Element fork of bot-sdk for crypto fixes

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2022-12-09 10:25:36 -05:00
Will Hunt
0eabb9e3a7
Ensure unknown keys are retained when connection state is altered via widget (#587)
* Handle enable hooks in validation too

* Allow unknown keys in provisioner updates.

* Fixup error

* Finally fix Ajv moaning about types

* changelog

* Apply changes to all connection types

* remove null
2022-12-08 16:33:56 +00:00
Will Hunt
b6ae8f9106
Split out GitHub release events into created and drafted (#582)
* Support published events

* Changelog

* Improve comments

* Add frontend support

* Change func names
2022-12-08 02:48:56 +00:00
Will Hunt
7d74f1b1a8
Support filtering workflow run on workflow names (#588)
* Filter workflow events on specific workflow names

* Document new key

* changelog

* Change to a allow/deny list as per feedback
2022-12-08 01:52:51 +00:00
Will Hunt
c3e1649a3c
Add support for cached responses (ETags/LastModified) for RSS feeds (#583)
* Support not modified responses.

* Support using last modified / etags

* changelog
2022-12-07 17:48:41 +00:00
Will Hunt
f7ccacb429
Check GitLab Repo access level via a better API (#539)
* Check access level via a better API

* remove unused import

* Fixup APIs

* bugfix

* Validate data type
2022-12-02 14:48:40 +00:00
Andrew Ferrazzutti
2c5f248d77
Save bot-created admin rooms in profile data (#578)
* Save bot-created admin rooms in profile data

This prevents a process restart from causing bot-created admin rooms
to be forgotten.

* Clarify changelog
2022-11-25 17:19:32 +00:00
Will Hunt
93e2dbe7ed
Increase feed.pollTimeoutSeconds from 10s to 30s (#483)
* Increase feed.pollTimeoutSeconds from 10s to 30s

* Drop pointless default

* changelog
2022-11-25 14:46:06 +00:00
Andrew Ferrazzutti
16c052e5b9
Harden against unauthorized changes to room state (#565)
* Harden against unauthorized changes to room state

If an unauthorized change to connection-related room state is detected,
deny the new connection settings & attempt to revert the state change.

Also catch an otherwise-uncaught error on authentication failure.

* `any`->`unknown` for some StateEvent content types

* Limit how far back in state to look when restoring

* Explicitly drop unneeded return value of promise

* Add reason to redacted state events

* Rename & document the fn to revert room state

* Move connection state check to ConnectionManager

* Don't rollback bad room state on startup
2022-11-22 11:50:47 -05:00
Christian Paul
caf545f1a4
Misspelling: occured -> occurred (#576)
* Typo: occured -> occurred

* Add newsfile 576
2022-11-22 15:17:43 +01:00
Christian Paul
80010f7b9b
Misspelling: to setup -> to set up (#572)
* Typo: to setup -> to set up

* Add newsfile
2022-11-21 18:38:50 +01:00
Andrew Ferrazzutti
db8221b60a
Allow GitLab connections without hook permissions (#567)
* Allow GitLab connections without hook permissions

Warn instead of fail when connecting a GitLab project that Hookshot
cannot provision a webhook for.

* Mention manual "Secret token" for GitLab webhooks

* Refactor warning pane into a separate component

* Recolour warning pane for better contrast
2022-11-08 10:19:41 -05:00
Will Hunt
c9a9a54e95
Increase SANITIZE_MAX_BREADTH/SANITIZE_MAX_DEPTH for GenericHook (#560)
* Increase SANITIZE_MAX_BREADTH/SANITIZE_MAX_DEPTH

I suspect #559 is failing because the body falls just outside our safe range. The safe ranges were chosen arbitrarily, but we can probably increase them without a huge perf penalty.

* Automatically JSONify anything exceeding the breadth or depth

* Create 560.bugfix

* Update GenericHook.ts

* Cleanup

* optimise newDepth
2022-11-07 12:02:46 +00:00
Will Hunt
28235547d2
Prevent users without permissions from inviting the bot (#561)
* Add filter

* tweak

* changelog

* Kick the right user

* Update src/Bridge.ts

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

* Update src/Bridge.ts

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

* Update changelog.d/561.bugfix

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

* Cleanup underlyingClient

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2022-11-03 12:55:48 +00:00
Andrew Ferrazzutti
cf10cf47a2
Don't provision command-created connections twice (#558) 2022-11-02 19:34:32 +00:00
Andrew Ferrazzutti
0bec1f6e6f
Make GitLab path uniqueness case-insensitive (#557)
NOTE: If a room already contains multiple GitLab connections with
case-insensensitive identical paths, they will _not_ be removed.
2022-11-02 14:42:18 -04:00
Andrew Ferrazzutti
37543eedaf
Display true casing of GitLab paths (#556) 2022-11-02 14:41:43 -04:00
Andrew Ferrazzutti
bf66dd2a01
Remove trailing slashes from GitLab instance URLs (#563)
Fixes #562
2022-11-02 14:39:37 -04:00
Will Hunt
0ad8e5e640
GitHub assign quality of life. (#554)
* Add defaults to assign

* changelog

* Update src/Connections/GithubRepo.ts

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

* Update GithubRepo.ts

Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2022-11-02 14:21:41 +00:00
Andrew Ferrazzutti
baa1b639c4
Don't skip non-lowercase GitLab connection paths (#553)
* Don't skip non-lowercase GitLab connection paths

Fixes #552

* Don't lower-case GitLab URLs with bot command

This allows GitLab URLs to appear in the configuration widget with their
original casing intact.

* Lowercase GitLab connection path on save
2022-11-01 14:14:58 -04:00
Will Hunt
ecbd7e6252
Skip GitLab MR reply comments (#536)
* Skip MR reply comments

* Skip comment event if filtered by events

* Use discussion IDS

* Create 536.bugfix

* Update src/Connections/GitlabRepo.ts

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

* Update src/Connections/GitlabRepo.ts

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

* Update src/Connections/GitlabRepo.ts

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

Co-authored-by: Christian Paul <christianp@matrix.org>
2022-10-31 16:06:38 +00:00
Will Hunt
dfad5b5c3b
Silence RSS timeouts (#551)
* Silence timeouts

* changelog
2022-10-31 16:04:52 +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
Andrew Ferrazzutti
f7bb20a639
Allow multiple Jira connections; stop prefix clash (#540)
* Allow multiple Jira connections; stop prefix clash

Fixes #533
Mitigates #421

* Follow review suggestions

- Set a status code for the ApiError on command prefix conflict
- Make `conflictsWithCommandPrefix` an optional method
2022-10-21 09:25:07 -04:00
Andrew Ferrazzutti
505c083f5f
Add support for Jira version events (#534)
- Support version created/updated/released events
- Look up project ID if missing when subscribing to version events
- Properly format version event notices
- Prioritize project URL over ID in debug strings
2022-10-21 09:24:35 -04:00
Andrew Ferrazzutti
d82e0d7d91
Fix & refactor Jira issue event handling (#543)
- Refactor Jira event handling to be more like GitHub & GitLab
- Fix silently-ignored Jira events due to expecting wrong type strings
- Update UI for Jira events
2022-10-21 09:16:00 -04:00
Will Hunt
3b2dff5d42
Don't crash the bridge on state update failure (#537) 2022-10-18 22:55:31 +01:00
Will Hunt
fdcb5a27cb
Improvements to GitHub auth (#523)
* Always report auth errors

* Raise OAuth errors

* Tweaks

* a newline

* changelog

* changes
2022-10-17 15:19:13 +01:00
Will Hunt
0865535c3c
Add a note to use help (#522) 2022-10-07 10:06:45 +00:00
Will Hunt
b8cc1f962f
Add support for GitHub workflow run completion events (#520)
* Add support for workflow run completions

* Create 520.feature
2022-10-07 10:35:05 +01: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
Andrew Ferrazzutti
3ec5bac5f9
Let GitHub widget support "issue.labeled" (#519)
The bridge supports it, but schema validation didn't think so
2022-10-05 03:59:23 -04:00
Andrew Ferrazzutti
d570dc8a3a
Send bot notice on GitHub OAuth success (#512)
* Send bot notice on GitHub OAuth success

i.e. the same as is done for Jira

* Nitpick: don't backtick plain string message
2022-10-04 18:05:17 -04:00
Andrew Ferrazzutti
c29c67fc2b
Fix command prefix field in widgets (#515)
* Read-your-writes consistency on connection update

Allow updates to connections made via config widgets to be reflected
immediately upon save in the widget UI.

* Use HTML elements as `ref`s in widgets

Fixes #422

* Add changelog

* Let widgets use new connection config on save

After a connection config is updated, but before a widget requests the
latest config from the bridge, make the widget display the just-saved
config instead of what the config was before being updated.

* Use input placeholder as prefix default

Otherwise, leaving the prefix field blank would apply no prefix, and
violate prefix length requirements.
2022-10-04 17:19:21 -04:00
Andrew Ferrazzutti
3ca61b9e02
Reorganize the GitHub config widget (#508)
- Group repos by org
- Paginate repo requests
- Remove redundant label next to chosen repo
- Remove redundant repo field below connected repo
- Include repos that user has doesn't have admin permissions for, to
  achieve parity with results from provisioning API
2022-10-03 10:43:16 -04:00