mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-21 18:02:24 +00:00
Replace reflection to type assertion
This commit is contained in:
parent
197b296a24
commit
d3f90c8eda
@ -2,7 +2,6 @@ package memory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
@ -230,13 +229,12 @@ func extractEventsFromNodes(nodes []*sortedset.SortedSetNode) []events.Event {
|
||||
}
|
||||
|
||||
func isEventRelatedToUser(event events.Event, user internal.User) bool {
|
||||
// get RoomID field from event interface
|
||||
// TODO: what if there are no RoomID field?
|
||||
roomID := reflect.ValueOf(event).Elem().FieldByName("RoomID").Addr().Interface().(string)
|
||||
|
||||
if internal.InArray(roomID, extractRoomIDsFromModel(user.JoinedRooms())) {
|
||||
return true
|
||||
if roomEvent, ok := event.(*events.RoomEvent); ok {
|
||||
if internal.InArray(roomEvent.RoomID, extractRoomIDsFromModel(user.JoinedRooms())) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user