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:
Andrew Morgan 2018-07-16 05:30:04 -07:00 committed by Andrew Morgan
parent 2154458589
commit 0eb6078dad
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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
}