fix: Fix bug with filter adding

This commit is contained in:
ChronosX88 2019-08-05 14:12:48 +04:00
parent 501c7b0795
commit 6dba957e5f
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
3 changed files with 6 additions and 3 deletions

View File

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

View File

@ -324,7 +324,7 @@ func CapabilitiesHandler(w http.ResponseWriter, r *http.Request) {
}
func AddFilterHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
if r.Method != http.MethodPost {
errorResponse(w, models.M_UNKNOWN, http.StatusBadRequest, "wrong method: "+r.Method)
return
}

View File

@ -40,7 +40,7 @@ func NewServer(port int) (*Server, error) {
router.HandleFunc("/_matrix/client/r0/rooms/{roomId}/leave", leaveRoomHandler)
router.HandleFunc("/_matrix/client/r0/register/available", registerAvailableHandler)
router.HandleFunc("/_matrix/client/r0/publicRooms", publicRoomsHandler)
router.HandleFunc("/_matrix/client/r0/user/{userId}/filter/{filterId}", GetFilterHandler).Methods("GET")
router.HandleFunc("/_matrix/client/r0/user/{userId}/filter/{filterID}", GetFilterHandler).Methods("GET")
router.HandleFunc("/_matrix/client/r0/user/{userId}/filter", AddFilterHandler).Methods("POST")
router.HandleFunc("/", RootHandler)