aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing
diff options
context:
space:
mode:
authorWill Hunt <will@half-shot.uk>2021-03-03 16:27:44 +0000
committerGitHub <noreply@github.com>2021-03-03 16:27:44 +0000
commita2773922d2fe40e6d95d73f532640702709ab526 (patch)
treeaaf2f63073eb840655d6b244d0c85b534d7b91c3 /clientapi/routing
parentd15836e260130f85edd5d9a104e5304f001d2681 (diff)
Send events to appservice based on room membership (#1680)
* Check membership of room * Use QueryStateAfterEventsResponse * Fix complexity * Changes that I made a long time ago * Rename to appserviceJoinedAtEvent * Check membership in GetMemberships * Update QueryMembershipsForRoom * Tweaks in client API * Update appserviceJoinedAtEvent * Comments * Try QueryMembershipForUser instead * Undo some changes to client API that shouldn't be needed * More /event tweaks * Refactor /event bit * Go back to QueryMembershipsForRoom because appservices are hard * Fix bugs in onMessage * Add comments Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'clientapi/routing')
-rw-r--r--clientapi/routing/getevent.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/clientapi/routing/getevent.go b/clientapi/routing/getevent.go
index 29340cc0..36f3ee9e 100644
--- a/clientapi/routing/getevent.go
+++ b/clientapi/routing/getevent.go
@@ -103,8 +103,22 @@ func GetEvent(
}
}
+ var appService *config.ApplicationService
+ if device.AppserviceID != "" {
+ for _, as := range cfg.Derived.ApplicationServices {
+ if as.ID == device.AppserviceID {
+ appService = &as
+ break
+ }
+ }
+ }
+
for _, stateEvent := range stateResp.StateEvents {
- if !stateEvent.StateKeyEquals(device.UserID) {
+ if appService != nil {
+ if !appService.IsInterestedInUserID(*stateEvent.StateKey()) {
+ continue
+ }
+ } else if !stateEvent.StateKeyEquals(device.UserID) {
continue
}
membership, err := stateEvent.Membership()