Fix root type path

This commit is contained in:
nxshock 2019-08-10 10:48:35 +05:00
parent f7eb4f7e28
commit cb452bbd98
3 changed files with 17 additions and 15 deletions

View File

@ -5,12 +5,13 @@ import (
"time"
"github.com/signaller-matrix/signaller/internal"
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/rooms"
)
type RoomEvent struct {
Content json.RawMessage
Type rooms.Type
Type common.EventType
EventID string
Sender internal.User
OriginServerTS time.Time

View File

@ -10,7 +10,6 @@ import (
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/createroom"
"github.com/signaller-matrix/signaller/internal/models/devices"
"github.com/signaller-matrix/signaller/internal/models/rooms"
)
type User struct {
@ -50,7 +49,7 @@ func (user *User) CreateRoom(request createroom.Request) (internal.Room, models.
// Create room event
events = append(events, RoomEvent{
Content: nil,
Type: rooms.Create,
Type: common.Create,
EventID: internal.RandomString(eventIDSize),
Sender: user,
OriginServerTS: t})
@ -60,7 +59,7 @@ func (user *User) CreateRoom(request createroom.Request) (internal.Room, models.
// Set join rules event
events = append(events, RoomEvent{
Content: []byte(request.Visibility), // TODO: check visibility vs join rules
Type: rooms.JoinRules,
Type: common.JoinRules,
EventID: internal.RandomString(eventIDSize),
Sender: user,
OriginServerTS: t})
@ -69,7 +68,7 @@ func (user *User) CreateRoom(request createroom.Request) (internal.Room, models.
if request.Name != "" {
events = append(events, RoomEvent{
Content: nil, // TODO: add
Type: rooms.Name,
Type: common.Name,
EventID: internal.RandomString(eventIDSize),
Sender: user,
OriginServerTS: t})
@ -79,7 +78,7 @@ func (user *User) CreateRoom(request createroom.Request) (internal.Room, models.
if request.RoomAliasName != "" {
events = append(events, RoomEvent{
Content: nil, // TODO: add
Type: rooms.CanonicalAlias,
Type: common.CanonicalAlias,
EventID: internal.RandomString(eventIDSize),
Sender: user,
OriginServerTS: t})
@ -125,7 +124,7 @@ func (user *User) SetTopic(room internal.Room, topic string) models.ApiError {
memRoom.mutex.Unlock()
rEvent := &RoomEvent{
Type: rooms.Topic,
Type: common.Topic,
Sender: user,
OriginServerTS: time.Now(),
Room: room}
@ -206,7 +205,7 @@ func (user *User) SendMessage(room internal.Room, text string) models.ApiError {
rEvent := &RoomEvent{
Content: nil,
Type: rooms.Message,
Type: common.Message,
EventID: internal.RandomString(defaultTokenSize),
Sender: user,
OriginServerTS: time.Now(),

View File

@ -3,6 +3,8 @@ package rooms
import (
"encoding/json"
"github.com/signaller-matrix/signaller/internal/models/common"
"github.com/signaller-matrix/signaller/internal/models/events"
)
@ -17,13 +19,13 @@ const (
// https://matrix.org/docs/spec/client_server/latest#room-event-fields
type Event struct {
Content json.RawMessage `json:"content"` // Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
Type Type `json:"type"` // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
EventID string `json:"event_id"` // Required. The globally unique event identifier.
Sender string `json:"sender"` // Required. Contains the fully-qualified ID of the user who sent this event.
OriginServerTS int64 `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
Unsigned UnsignedData `json:"unsigned,omitempty"` // Contains optional extra information about the event.
RoomID string `json:"room_id"` // Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.
Content json.RawMessage `json:"content"` // Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
Type common.EventType `json:"type"` // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
EventID string `json:"event_id"` // Required. The globally unique event identifier.
Sender string `json:"sender"` // Required. Contains the fully-qualified ID of the user who sent this event.
OriginServerTS int64 `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
Unsigned UnsignedData `json:"unsigned,omitempty"` // Contains optional extra information about the event.
RoomID string `json:"room_id"` // Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.
}
type UnsignedData struct {