diff --git a/sam/rest/auth.go b/sam/rest/auth.go index e2ba8eae1..6acf900b5 100644 --- a/sam/rest/auth.go +++ b/sam/rest/auth.go @@ -43,7 +43,7 @@ func (ctrl *Auth) Login(ctx context.Context, r *server.AuthLoginRequest) (interf return struct { JWT string - User *types.User + User *types.User `json:"user"` }{ JWT: ctrl.svc.token.Encode(user), User: user, diff --git a/sam/types/attachment.go b/sam/types/attachment.go index 2ffa55520..5fc23bb85 100644 --- a/sam/types/attachment.go +++ b/sam/types/attachment.go @@ -17,8 +17,8 @@ type ( Size uint `db:"size"` Mimetype string `db:"mimetype"` Name string `db:"name"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } ) diff --git a/sam/types/channel.go b/sam/types/channel.go index cf2933a8d..446303dab 100644 --- a/sam/types/channel.go +++ b/sam/types/channel.go @@ -7,21 +7,23 @@ import ( type ( Channel struct { - ID uint64 `db:"id"` - Name string `db:"name"` - Topic string `db:"topic"` - Type ChannelType `db:"type"` - Meta json.RawMessage `db:"meta"` + ID uint64 `json:"id" db:"id"` + Name string `json:"name" db:"name"` + Topic string `json:"topic" db:"topic"` + Type ChannelType `json:"type" db:"type"` + Meta json.RawMessage `json:"-" db:"meta"` - CreatorID uint64 `db:"rel_creator"` - OrganisationID uint64 `db:"rel_organisation"` + CreatorID uint64 `json:"creatorId" db:"rel_creator"` + OrganisationID uint64 `json:"organisationId" db:"rel_organisation"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - ArchivedAt *time.Time `json:"archived_at,omitempty" db:"archived_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + ArchivedAt *time.Time `json:"archivedAt,omitempty" db:"archived_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` LastMessageID uint64 `json:",omitempty" db:"rel_last_message"` + + Member *ChannelMember `json:"-" db:"-"` } ChannelMember struct { @@ -30,8 +32,8 @@ type ( Type ChannelMembershipType `db:"type"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` } ChannelFilter struct { @@ -48,5 +50,5 @@ const ( ChannelTypePublic ChannelType = "public" ChannelTypePrivate = "private" - ChannelTypeDirect = "direct" + ChannelTypeGroup = "group" ) diff --git a/sam/types/message.go b/sam/types/message.go index 73b5e0224..e2320b378 100644 --- a/sam/types/message.go +++ b/sam/types/message.go @@ -6,15 +6,15 @@ import ( type ( Message struct { - ID uint64 `db:"id"` - Type string `db:"type"` - Message string `db:"message"` - UserID uint64 `db:"rel_user"` - ChannelID uint64 `db:"rel_channel"` - ReplyTo uint64 `db:"reply_to"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + ID uint64 `json:"id" db:"id"` + Type string `json:"type" db:"type"` + Message string `json:"message" db:"message"` + UserID uint64 `json:"userId" db:"rel_user"` + ChannelID uint64 `json:"channelId" db:"rel_channel"` + ReplyTo uint64 `json:"replyTo" db:"reply_to"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } MessageFilter struct { diff --git a/sam/types/organisation.go b/sam/types/organisation.go index 226cb76bb..7ac7dc32d 100644 --- a/sam/types/organisation.go +++ b/sam/types/organisation.go @@ -7,13 +7,13 @@ import ( type ( // Organisations - Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment. Organisation struct { - ID uint64 `db:"id"` - FQN string `db:"fqn"` - Name string `db:"name"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - ArchivedAt *time.Time `json:"archived_at,omitempty" db:"archived_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + ID uint64 `json:"id" db:"id"` + FQN string `json:"fqn" db:"fqn"` + Name string `json:"name" db:"name"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + ArchivedAt *time.Time `json:"archivedAt,omitempty" db:"archived_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } OrganisationFilter struct { diff --git a/sam/types/reaction.go b/sam/types/reaction.go index e76416846..f9009d21c 100644 --- a/sam/types/reaction.go +++ b/sam/types/reaction.go @@ -6,11 +6,11 @@ import ( type ( Reaction struct { - ID uint64 `db:"id"` - UserID uint64 `db:"rel_user"` - MessageID uint64 `db:"rel_message"` - ChannelID uint64 `db:"rel_channel"` - Reaction string `db:"reaction"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` + ID uint64 `json:"id" db:"id"` + UserID uint64 `json:"userId" db:"rel_user"` + MessageID uint64 `json:"messageId" db:"rel_message"` + ChannelID uint64 `json:"channelId" db:"rel_channel"` + Reaction string `json:"reaction" db:"reaction"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` } ) diff --git a/sam/types/team.go b/sam/types/team.go index fcd150713..3d6e4aa20 100644 --- a/sam/types/team.go +++ b/sam/types/team.go @@ -7,13 +7,13 @@ import ( type ( // Teams - An organisation may have many teams. Teams may have many channels available. Access to channels may be shared between teams. Team struct { - ID uint64 `db:"id"` - Name string `db:"name"` - Handle string `db:"handle"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - ArchivedAt *time.Time `json:"archived_at,omitempty" db:"archived_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + ID uint64 `json:"id" db:"id"` + Name string `json:"name" db:"name"` + Handle string `json:"handle" db:"handle"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + ArchivedAt *time.Time `json:"archivedAt,omitempty" db:"archived_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } TeamFilter struct { diff --git a/sam/types/user.go b/sam/types/user.go index f26491ba3..06e1001ee 100644 --- a/sam/types/user.go +++ b/sam/types/user.go @@ -7,15 +7,15 @@ import ( type ( User struct { - ID uint64 `db:"id"` - Username string `db:"username"` + ID uint64 `json:"id" db:"id"` + Username string `json:"username" db:"username"` Meta json.RawMessage `json:"-" db:"meta"` - OrganisationID uint64 `db:"rel_organisation"` + OrganisationID uint64 `json:"organisationId" db:"rel_organisation"` Password []byte `json:"-" db:"password"` - CreatedAt time.Time `json:"created_at,omitempty" db:"created_at"` - UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` - SuspendedAt *time.Time `json:"suspended_at,omitempty" db:"suspended_at"` - DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` + CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"` + UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at"` + SuspendedAt *time.Time `json:"suspendedAt,omitempty" db:"suspended_at"` + DeletedAt *time.Time `json:"deletedAt,omitempty" db:"deleted_at"` } UserFilter struct {