signaller/internal/backend.go

47 lines
1.4 KiB
Go
Raw Normal View History

package internal
2019-07-18 14:10:43 +00:00
import (
"github.com/nxshock/signaller/internal/models"
"github.com/nxshock/signaller/internal/models/createroom"
"github.com/nxshock/signaller/internal/models/devices"
"github.com/nxshock/signaller/internal/models/rooms"
"github.com/nxshock/signaller/internal/models/sync"
)
2019-07-18 14:10:43 +00:00
type Backend interface {
Register(username, password, device string) (user User, token string, err *models.ApiError)
2019-07-31 15:53:36 +00:00
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
Sync(token string, request sync.SyncRequest) (response *sync.SyncReply, err *models.ApiError)
2019-07-18 14:10:43 +00:00
}
type Room interface {
ID() string
Creator() User
2019-07-22 16:02:53 +00:00
Users() []User
AliasName() string
Name() string
Topic() string
Events() []rooms.Event
2019-07-31 15:01:20 +00:00
Visibility() createroom.VisibilityType
2019-08-02 16:46:46 +00:00
State() createroom.Preset
}
type User interface {
Name() string
ID() string
Password() string
2019-07-21 11:52:32 +00:00
CreateRoom(request createroom.Request) (Room, *models.ApiError)
2019-07-22 13:58:18 +00:00
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)
Devices() []devices.Device
2019-07-31 15:01:20 +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()
}