2019-07-19 07:39:53 +00:00
|
|
|
package internal
|
2019-07-18 14:10:43 +00:00
|
|
|
|
2019-07-19 15:52:03 +00:00
|
|
|
import (
|
2019-08-03 14:19:18 +00:00
|
|
|
"github.com/signaller-matrix/signaller/internal/models"
|
2019-08-05 15:06:46 +00:00
|
|
|
"github.com/signaller-matrix/signaller/internal/models/common"
|
2019-08-03 14:19:18 +00:00
|
|
|
"github.com/signaller-matrix/signaller/internal/models/createroom"
|
|
|
|
"github.com/signaller-matrix/signaller/internal/models/devices"
|
2019-08-10 07:48:55 +00:00
|
|
|
"github.com/signaller-matrix/signaller/internal/models/events"
|
2019-08-03 14:19:18 +00:00
|
|
|
"github.com/signaller-matrix/signaller/internal/models/sync"
|
2019-07-19 15:52:03 +00:00
|
|
|
)
|
2019-07-18 14:10:43 +00:00
|
|
|
|
|
|
|
type Backend interface {
|
2019-08-03 06:46:57 +00:00
|
|
|
Register(username, password, device string) (user User, token string, err models.ApiError)
|
|
|
|
Login(username, password, device string) (user User, token string, err models.ApiError)
|
2019-07-23 14:37:02 +00:00
|
|
|
GetUserByToken(token string) (user User)
|
2019-08-02 13:17:18 +00:00
|
|
|
GetUserByName(userName string) User
|
2019-07-31 15:01:20 +00:00
|
|
|
GetRoomByID(id string) Room
|
2019-08-03 06:46:57 +00:00
|
|
|
Sync(token string, request sync.SyncRequest) (response *sync.SyncReply, err models.ApiError)
|
2019-08-03 14:47:33 +00:00
|
|
|
PublicRooms(filter string) []Room
|
2019-08-03 07:54:32 +00:00
|
|
|
ValidateUsernameFunc() func(string) error
|
2019-08-10 07:48:55 +00:00
|
|
|
GetEventByID(id string) events.Event
|
|
|
|
PutEvent(events.Event) error
|
2019-08-06 15:28:39 +00:00
|
|
|
GetRoomByAlias(string) Room
|
2019-08-10 07:48:55 +00:00
|
|
|
GetEventsSince(user User, sinceToken string, limit int) []events.Event
|
2019-07-18 14:10:43 +00:00
|
|
|
}
|
2019-07-21 09:43:14 +00:00
|
|
|
|
|
|
|
type Room interface {
|
|
|
|
ID() string
|
|
|
|
Creator() User
|
2019-07-22 16:02:53 +00:00
|
|
|
Users() []User
|
2019-07-21 09:43:14 +00:00
|
|
|
AliasName() string
|
2019-08-08 14:38:30 +00:00
|
|
|
Aliases() []string
|
2019-07-21 09:43:14 +00:00
|
|
|
Name() string
|
|
|
|
Topic() string
|
2019-07-31 15:01:20 +00:00
|
|
|
Visibility() createroom.VisibilityType
|
2019-08-02 17:55:35 +00:00
|
|
|
WorldReadable() bool
|
|
|
|
GuestCanJoin() bool
|
|
|
|
AvatarURL() string
|
2019-08-02 16:46:46 +00:00
|
|
|
State() createroom.Preset
|
2019-07-21 09:43:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type User interface {
|
|
|
|
Name() string
|
|
|
|
ID() string
|
|
|
|
Password() string
|
2019-08-03 06:46:57 +00:00
|
|
|
CreateRoom(request createroom.Request) (Room, models.ApiError)
|
|
|
|
LeaveRoom(room Room) models.ApiError
|
|
|
|
SetTopic(room Room, topic string) models.ApiError
|
|
|
|
SendMessage(room Room, text string) models.ApiError
|
2019-07-24 15:04:45 +00:00
|
|
|
JoinedRooms() []Room
|
2019-07-25 16:56:31 +00:00
|
|
|
ChangePassword(newPassword string)
|
2019-07-29 14:32:38 +00:00
|
|
|
Devices() []devices.Device
|
2019-08-03 06:46:57 +00:00
|
|
|
SetRoomVisibility(Room, createroom.VisibilityType) models.ApiError
|
2019-07-24 14:31:07 +00:00
|
|
|
Logout(token string)
|
2019-07-24 14:15:07 +00:00
|
|
|
LogoutAll()
|
2019-08-03 06:46:57 +00:00
|
|
|
JoinRoom(Room) models.ApiError
|
2019-08-04 08:47:58 +00:00
|
|
|
Invite(Room, User) models.ApiError
|
2019-08-05 15:06:46 +00:00
|
|
|
AddFilter(filterID string, filter common.Filter)
|
|
|
|
GetFilterByID(filterID string) *common.Filter
|
2019-08-06 15:28:39 +00:00
|
|
|
AddRoomAlias(Room, string) models.ApiError
|
|
|
|
DeleteRoomAlias(string) models.ApiError
|
2019-07-21 09:43:14 +00:00
|
|
|
}
|