Apply new templates (form parsing, db tag) to all structs & requests
This commit is contained in:
@@ -33,6 +33,7 @@ func (channelCreateRequest) new() *channelCreateRequest {
|
||||
}
|
||||
|
||||
func (c *channelCreateRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -66,6 +67,7 @@ func (channelEditRequest) new() *channelEditRequest {
|
||||
}
|
||||
|
||||
func (c *channelEditRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -101,6 +103,7 @@ func (channelRemoveRequest) new() *channelRemoveRequest {
|
||||
}
|
||||
|
||||
func (c *channelRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -128,6 +131,7 @@ func (channelReadRequest) new() *channelReadRequest {
|
||||
}
|
||||
|
||||
func (c *channelReadRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -155,6 +159,7 @@ func (channelSearchRequest) new() *channelSearchRequest {
|
||||
}
|
||||
|
||||
func (c *channelSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
@@ -23,13 +23,13 @@ import (
|
||||
type (
|
||||
// Channels
|
||||
Channel struct {
|
||||
ID uint64
|
||||
Name string
|
||||
Topic string
|
||||
Meta json.RawMessage
|
||||
LastMessageId uint64 `json:",omitempty" db:"rel_last_message"`
|
||||
ArchivedAt *time.Time `json:",omitempty" db:"archived_at"`
|
||||
DeletedAt *time.Time `json:",omitempty" db:"deleted_at"`
|
||||
ID uint64 `db:"id"`
|
||||
Name string `db:"name"`
|
||||
Topic string `db:"-"`
|
||||
Meta json.RawMessage `db:"meta"`
|
||||
LastMessageId uint64 `json:",omitempty" db:"rel_last_message"`
|
||||
ArchivedAt *time.Time `json:",omitempty" db:"archived_at"`
|
||||
DeletedAt *time.Time `json:",omitempty" db:"deleted_at"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
@@ -184,11 +184,11 @@
|
||||
"fields": [
|
||||
{ "type": "uint64", "name": "ID" },
|
||||
{ "type": "string", "name": "Name" },
|
||||
{ "type": "string", "name": "Topic" },
|
||||
{ "type": "string", "name": "Topic", "dbname": "-" },
|
||||
{ "type": "json.RawMessage", "name": "Meta", "complex": true},
|
||||
{ "type": "uint64", "name": "LastMessageId", "tag": "json:\",omitempty\"", "dbname": "rel_last_message" },
|
||||
{ "type": "*time.Time", "name": "ArchivedAt", "tag": "json:\",omitempty\" db:\"archived_at\"", "complex": true },
|
||||
{ "type": "*time.Time", "name": "DeletedAt", "tag": "json:\",omitempty\" db:\"deleted_at\"", "complex": true }
|
||||
{ "type": "*time.Time", "name": "ArchivedAt", "tag": "json:\",omitempty\"", "complex": true },
|
||||
{ "type": "*time.Time", "name": "DeletedAt", "tag": "json:\",omitempty\"", "complex": true }
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -200,7 +200,7 @@
|
||||
"parameters": {
|
||||
"post": [
|
||||
{ "type": "string", "name": "name", "required": true, "title": "Name of Channel" },
|
||||
{ "type": "string", "name": "topic", "required": true, "title": "Subject of Channel" }
|
||||
{ "type": "string", "name": "topic", "required": false, "title": "Subject of Channel" }
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -210,9 +210,9 @@
|
||||
"title": "Update channel details",
|
||||
"parameters": {
|
||||
"post": [
|
||||
{ "type": "uint64", "name": "id", "required": false, "title": "Channel ID" },
|
||||
{ "type": "string", "name": "name", "required": true, "title": "Name of Channel" },
|
||||
{ "type": "string", "name": "topic", "required": true, "title": "Subject of Channel" },
|
||||
{ "type": "uint64", "name": "id", "required": true, "title": "Channel ID" },
|
||||
{ "type": "string", "name": "name", "required": false, "title": "Name of Channel" },
|
||||
{ "type": "string", "name": "topic", "required": false, "title": "Subject of Channel" },
|
||||
{ "type": "bool", "name": "archive", "required": false, "title": "Request channel to be archived or unarchived" },
|
||||
{ "type": "uint64", "name": "organisationId", "required": false, "title": "Move channel to different organisation" }
|
||||
]
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"dbname": "-",
|
||||
"name": "Topic",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -32,13 +33,13 @@
|
||||
{
|
||||
"complex": true,
|
||||
"name": "ArchivedAt",
|
||||
"tag": "json:\",omitempty\" db:\"archived_at\"",
|
||||
"tag": "json:\",omitempty\"",
|
||||
"type": "*time.Time"
|
||||
},
|
||||
{
|
||||
"complex": true,
|
||||
"name": "DeletedAt",
|
||||
"tag": "json:\",omitempty\" db:\"deleted_at\"",
|
||||
"tag": "json:\",omitempty\"",
|
||||
"type": "*time.Time"
|
||||
}
|
||||
],
|
||||
@@ -71,7 +72,7 @@
|
||||
},
|
||||
{
|
||||
"name": "topic",
|
||||
"required": true,
|
||||
"required": false,
|
||||
"title": "Subject of Channel",
|
||||
"type": "string"
|
||||
}
|
||||
@@ -87,19 +88,19 @@
|
||||
"post": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": false,
|
||||
"required": true,
|
||||
"title": "Channel ID",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"required": false,
|
||||
"title": "Name of Channel",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "topic",
|
||||
"required": true,
|
||||
"required": false,
|
||||
"title": "Subject of Channel",
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -34,6 +34,7 @@ func (messageEditRequest) new() *messageEditRequest {
|
||||
}
|
||||
|
||||
func (m *messageEditRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -64,6 +65,7 @@ func (messageAttachRequest) new() *messageAttachRequest {
|
||||
}
|
||||
|
||||
func (m *messageAttachRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -89,6 +91,7 @@ func (messageRemoveRequest) new() *messageRemoveRequest {
|
||||
}
|
||||
|
||||
func (m *messageRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -116,6 +119,7 @@ func (messageReadRequest) new() *messageReadRequest {
|
||||
}
|
||||
|
||||
func (m *messageReadRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -144,6 +148,7 @@ func (messageSearchRequest) new() *messageSearchRequest {
|
||||
}
|
||||
|
||||
func (m *messageSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -173,6 +178,7 @@ func (messagePinRequest) new() *messagePinRequest {
|
||||
}
|
||||
|
||||
func (m *messagePinRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -200,6 +206,7 @@ func (messageFlagRequest) new() *messageFlagRequest {
|
||||
}
|
||||
|
||||
func (m *messageFlagRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
@@ -18,15 +18,15 @@ package sam
|
||||
type (
|
||||
// Messages
|
||||
Message struct {
|
||||
Service string
|
||||
Channel string
|
||||
UserName string
|
||||
UserID uint64
|
||||
User *User
|
||||
UserAvatar string
|
||||
Message string
|
||||
MessageID string
|
||||
Type MessageType
|
||||
Service string `db:"service"`
|
||||
Channel string `db:"channel"`
|
||||
UserName string `db:"user_name"`
|
||||
UserID uint64 `db:"user_id"`
|
||||
User *User `db:"user"`
|
||||
UserAvatar string `db:"user_avatar"`
|
||||
Message string `db:"message"`
|
||||
MessageID string `db:"message_id"`
|
||||
Type MessageType `db:"type"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ func (organisationEditRequest) new() *organisationEditRequest {
|
||||
}
|
||||
|
||||
func (o *organisationEditRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -62,6 +63,7 @@ func (organisationRemoveRequest) new() *organisationRemoveRequest {
|
||||
}
|
||||
|
||||
func (o *organisationRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -89,6 +91,7 @@ func (organisationReadRequest) new() *organisationReadRequest {
|
||||
}
|
||||
|
||||
func (o *organisationReadRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -116,6 +119,7 @@ func (organisationSearchRequest) new() *organisationSearchRequest {
|
||||
}
|
||||
|
||||
func (o *organisationSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -143,6 +147,7 @@ func (organisationArchiveRequest) new() *organisationArchiveRequest {
|
||||
}
|
||||
|
||||
func (o *organisationArchiveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
@@ -22,10 +22,10 @@ import (
|
||||
type (
|
||||
// Organisations
|
||||
Organisation struct {
|
||||
ID uint64
|
||||
Name string
|
||||
ArchivedAt *time.Time `json:",omitempty"`
|
||||
DeletedAt *time.Time `json:",omitempty"`
|
||||
ID uint64 `db:"id"`
|
||||
Name string `db:"name"`
|
||||
ArchivedAt *time.Time `json:",omitempty" db:"archived_at"`
|
||||
DeletedAt *time.Time `json:",omitempty" db:"deleted_at"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ func (teamEditRequest) new() *teamEditRequest {
|
||||
}
|
||||
|
||||
func (t *teamEditRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -63,6 +64,7 @@ func (teamRemoveRequest) new() *teamRemoveRequest {
|
||||
}
|
||||
|
||||
func (t *teamRemoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -90,6 +92,7 @@ func (teamReadRequest) new() *teamReadRequest {
|
||||
}
|
||||
|
||||
func (t *teamReadRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -117,6 +120,7 @@ func (teamSearchRequest) new() *teamSearchRequest {
|
||||
}
|
||||
|
||||
func (t *teamSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -144,6 +148,7 @@ func (teamArchiveRequest) new() *teamArchiveRequest {
|
||||
}
|
||||
|
||||
func (t *teamArchiveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -172,6 +177,7 @@ func (teamMoveRequest) new() *teamMoveRequest {
|
||||
}
|
||||
|
||||
func (t *teamMoveRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -202,6 +208,7 @@ func (teamMergeRequest) new() *teamMergeRequest {
|
||||
}
|
||||
|
||||
func (t *teamMergeRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
+6
-6
@@ -22,12 +22,12 @@ import (
|
||||
type (
|
||||
// Teams
|
||||
Team struct {
|
||||
ID uint64
|
||||
Name string
|
||||
MemberIDs []uint64 `json:"-"`
|
||||
Members []User `json:",omitempty"`
|
||||
ArchivedAt *time.Time `json:",omitempty"`
|
||||
DeletedAt *time.Time `json:",omitempty"`
|
||||
ID uint64 `db:"id"`
|
||||
Name string `db:"name"`
|
||||
MemberIDs []uint64 `json:"-" db:"member_i_ds"`
|
||||
Members []User `json:",omitempty" db:"members"`
|
||||
ArchivedAt *time.Time `json:",omitempty" db:"archived_at"`
|
||||
DeletedAt *time.Time `json:",omitempty" db:"deleted_at"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ func (userLoginRequest) new() *userLoginRequest {
|
||||
}
|
||||
|
||||
func (u *userLoginRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
@@ -62,6 +63,7 @@ func (userSearchRequest) new() *userSearchRequest {
|
||||
}
|
||||
|
||||
func (u *userSearchRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
+5
-5
@@ -22,11 +22,11 @@ import (
|
||||
type (
|
||||
// Users
|
||||
User struct {
|
||||
ID uint64
|
||||
Username string
|
||||
Password []byte `json:"-"`
|
||||
SuspendedAt *time.Time `json:",omitempty"`
|
||||
DeletedAt *time.Time `json:",omitempty"`
|
||||
ID uint64 `db:"id"`
|
||||
Username string `db:"username"`
|
||||
Password []byte `json:"-" db:"password"`
|
||||
SuspendedAt *time.Time `json:",omitempty" db:"suspended_at"`
|
||||
DeletedAt *time.Time `json:",omitempty" db:"deleted_at"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ func (websocketClientRequest) new() *websocketClientRequest {
|
||||
}
|
||||
|
||||
func (w *websocketClientRequest) Fill(r *http.Request) error {
|
||||
r.ParseForm()
|
||||
get := map[string]string{}
|
||||
post := map[string]string{}
|
||||
urlQuery := r.URL.Query()
|
||||
|
||||
@@ -18,8 +18,8 @@ package sam
|
||||
type (
|
||||
// Websocket
|
||||
Websocket struct {
|
||||
UserID uint64
|
||||
User User
|
||||
UserID uint64 `db:"user_id"`
|
||||
User User `db:"user"`
|
||||
|
||||
changed []string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user