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