Make coomon.Filter synonym of filter request

This commit is contained in:
nxshock 2019-08-05 20:06:46 +05:00
parent 330f362e54
commit 91b28d2dc1
5 changed files with 16 additions and 11 deletions

View File

@ -2,9 +2,9 @@ package internal
import ( import (
"github.com/signaller-matrix/signaller/internal/models" "github.com/signaller-matrix/signaller/internal/models"
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/createroom" "github.com/signaller-matrix/signaller/internal/models/createroom"
"github.com/signaller-matrix/signaller/internal/models/devices" "github.com/signaller-matrix/signaller/internal/models/devices"
"github.com/signaller-matrix/signaller/internal/models/filter"
"github.com/signaller-matrix/signaller/internal/models/rooms" "github.com/signaller-matrix/signaller/internal/models/rooms"
"github.com/signaller-matrix/signaller/internal/models/sync" "github.com/signaller-matrix/signaller/internal/models/sync"
) )
@ -51,6 +51,6 @@ type User interface {
LogoutAll() LogoutAll()
JoinRoom(Room) models.ApiError JoinRoom(Room) models.ApiError
Invite(Room, User) models.ApiError Invite(Room, User) models.ApiError
AddFilter(filterID string, filterReq filter.Request) AddFilter(filterID string, filter common.Filter)
GetFilterByID(filterID string) *filter.Request GetFilterByID(filterID string) *common.Filter
} }

View File

@ -9,8 +9,8 @@ import (
"github.com/signaller-matrix/signaller/internal" "github.com/signaller-matrix/signaller/internal"
"github.com/signaller-matrix/signaller/internal/models" "github.com/signaller-matrix/signaller/internal/models"
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/createroom" "github.com/signaller-matrix/signaller/internal/models/createroom"
"github.com/signaller-matrix/signaller/internal/models/filter"
mSync "github.com/signaller-matrix/signaller/internal/models/sync" mSync "github.com/signaller-matrix/signaller/internal/models/sync"
) )
@ -54,7 +54,7 @@ func (backend *Backend) Register(username, password, device string) (user intern
password: password, password: password,
Tokens: make(map[string]Token), Tokens: make(map[string]Token),
backend: backend, backend: backend,
filters: make(map[string]filter.Request)} filters: make(map[string]common.Filter)}
backend.data[username] = user backend.data[username] = user

View File

@ -6,9 +6,9 @@ import (
"github.com/signaller-matrix/signaller/internal" "github.com/signaller-matrix/signaller/internal"
"github.com/signaller-matrix/signaller/internal/models" "github.com/signaller-matrix/signaller/internal/models"
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/createroom" "github.com/signaller-matrix/signaller/internal/models/createroom"
"github.com/signaller-matrix/signaller/internal/models/devices" "github.com/signaller-matrix/signaller/internal/models/devices"
"github.com/signaller-matrix/signaller/internal/models/filter"
"github.com/signaller-matrix/signaller/internal/models/rooms" "github.com/signaller-matrix/signaller/internal/models/rooms"
) )
@ -16,7 +16,7 @@ type User struct {
name string name string
password string password string
Tokens map[string]Token Tokens map[string]Token
filters map[string]filter.Request filters map[string]common.Filter
backend *Backend backend *Backend
@ -278,14 +278,14 @@ func (user *User) JoinRoom(room internal.Room) models.ApiError {
return nil return nil
} }
func (user *User) AddFilter(filterID string, filterReq filter.Request) { func (user *User) AddFilter(filterID string, filter common.Filter) {
user.mutex.Lock() user.mutex.Lock()
defer user.mutex.Unlock() defer user.mutex.Unlock()
user.filters[filterID] = filterReq user.filters[filterID] = filter
} }
func (user *User) GetFilterByID(filterID string) *filter.Request { func (user *User) GetFilterByID(filterID string) *common.Filter {
user.mutex.RLock() user.mutex.RLock()
defer user.mutex.RUnlock() defer user.mutex.RUnlock()

View File

@ -351,7 +351,7 @@ func AddFilterHandler(w http.ResponseWriter, r *http.Request) {
} }
filterID := RandomString(12) filterID := RandomString(12)
user.AddFilter(filterID, request) user.AddFilter(filterID, common.Filter(request))
response := filter.Response{FilterID: filterID} response := filter.Response{FilterID: filterID}

View File

@ -0,0 +1,5 @@
package common
import "github.com/signaller-matrix/signaller/internal/models/filter"
type Filter filter.Request