Renamed RoomFilter & Validate err message

Signed-off-by: Thibaut CHARLES cromfr@gmail.com
This commit is contained in:
Crom (Thibaut CHARLES) 2018-05-09 12:57:42 +02:00
parent c7e35f87cc
commit 5e66256b63
No known key found for this signature in database
GPG Key ID: 45A3D5F880B9E6D0
1 changed files with 5 additions and 5 deletions

View File

@ -23,11 +23,11 @@ type Filter struct {
EventFields []string `json:"event_fields,omitempty"` EventFields []string `json:"event_fields,omitempty"`
EventFormat string `json:"event_format,omitempty"` EventFormat string `json:"event_format,omitempty"`
Presence FilterPart `json:"presence,omitempty"` Presence FilterPart `json:"presence,omitempty"`
Room FilterRoom `json:"room,omitempty"` Room RoomFilter `json:"room,omitempty"`
} }
// FilterRoom is used to define filtering rules for room events // RoomFilter is used to define filtering rules for room events
type FilterRoom struct { type RoomFilter struct {
AccountData FilterPart `json:"account_data,omitempty"` AccountData FilterPart `json:"account_data,omitempty"`
Ephemeral FilterPart `json:"ephemeral,omitempty"` Ephemeral FilterPart `json:"ephemeral,omitempty"`
IncludeLeave bool `json:"include_leave,omitempty"` IncludeLeave bool `json:"include_leave,omitempty"`
@ -52,7 +52,7 @@ type FilterPart struct {
// Validate checks if the filter contains valid property values // Validate checks if the filter contains valid property values
func (filter *Filter) Validate() error { func (filter *Filter) Validate() error {
if filter.EventFormat != "client" && filter.EventFormat != "federation" { if filter.EventFormat != "client" && filter.EventFormat != "federation" {
return errors.New("Bad event_format value. Must be any of [\"client\", \"federation\"]") return errors.New("Bad event_format value. Must be one of [\"client\", \"federation\"]")
} }
return nil return nil
} }
@ -64,7 +64,7 @@ func DefaultFilter() Filter {
EventFields: nil, EventFields: nil,
EventFormat: "client", EventFormat: "client",
Presence: DefaultFilterPart(), Presence: DefaultFilterPart(),
Room: FilterRoom{ Room: RoomFilter{
AccountData: DefaultFilterPart(), AccountData: DefaultFilterPart(),
Ephemeral: DefaultFilterPart(), Ephemeral: DefaultFilterPart(),
IncludeLeave: false, IncludeLeave: false,