From 3391e4c8275cbd1298b789f8b5c4611066a120b4 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 3 Mar 2021 12:56:10 +0000 Subject: [PATCH] Refactor /event bit --- clientapi/routing/getevent.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/getevent.go b/clientapi/routing/getevent.go index 29340cc04..36f3ee9e3 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()