mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Consolidate AS interest checking (#539)
* Methods for checking if an AS is interested in events * Look through rooms namespace for matching room IDs
This commit is contained in:
parent
2154458589
commit
0eb6078dad
2 changed files with 8 additions and 2 deletions
|
@ -179,7 +179,12 @@ func (s *OutputRoomEventConsumer) filterRoomserverEvents(
|
|||
// appserviceIsInterestedInEvent returns a boolean depending on whether a given
|
||||
// event falls within one of a given application service's namespaces.
|
||||
func (s *OutputRoomEventConsumer) appserviceIsInterestedInEvent(ctx context.Context, event gomatrixserverlib.Event, appservice config.ApplicationService) bool {
|
||||
// Check room_id and sender of the event
|
||||
// No reason to queue events if they'll never be sent to the application
|
||||
// service
|
||||
if appservice.URL == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
if appservice.IsInterestedInUserID(event.Sender()) ||
|
||||
appservice.IsInterestedInRoomID(event.RoomID()) {
|
||||
return true
|
||||
|
|
|
@ -337,8 +337,9 @@ func UsernameMatchesMultipleExclusiveNamespaces(
|
|||
) bool {
|
||||
// Check namespaces and see if more than one match
|
||||
matchCount := 0
|
||||
userID := userutil.MakeUserID(username, cfg.Matrix.ServerName)
|
||||
for _, appservice := range cfg.Derived.ApplicationServices {
|
||||
if appservice.IsInterestedInUserID(username) {
|
||||
if appservice.IsInterestedInUserID(userID) {
|
||||
if matchCount++; matchCount > 1 {
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue