3
0

Revert []string=>[]uint64 change for channel members

Due to golang's inability do decode uint64 slice from string slice, we're expecting
string input for members (for now): https://github.com/golang/go/issues/15624
This commit is contained in:
Denis Arh
2019-04-27 16:08:02 +02:00
parent 47dfbd8ab3
commit d96a6c8abc
5 changed files with 20 additions and 18 deletions
+2 -2
View File
@@ -179,7 +179,7 @@
"title": "Channel type"
},
{
"type": "[]uint64",
"type": "[]string",
"name": "members",
"required": false,
"title": "Initial members of the channel"
@@ -386,7 +386,7 @@
"post": [
{
"name": "userID",
"type": "[]uint64",
"type": "[]string",
"required": false,
"title": "User ID"
}
+2 -2
View File
@@ -56,7 +56,7 @@
"name": "members",
"required": false,
"title": "Initial members of the channel",
"type": "[]uint64"
"type": "[]string"
}
]
}
@@ -262,7 +262,7 @@
"name": "userID",
"required": false,
"title": "User ID",
"type": "[]uint64"
"type": "[]string"
}
]
}
+2 -2
View File
@@ -120,7 +120,7 @@ A channel is a representation of a sequence of messages. It has meta data like c
| name | string | POST | Name of Channel | N/A | NO |
| topic | string | POST | Subject of Channel | N/A | NO |
| type | string | POST | Channel type | N/A | NO |
| members | []uint64 | POST | Initial members of the channel | N/A | NO |
| members | []string | POST | Initial members of the channel | N/A | NO |
## Update channel details
@@ -255,7 +255,7 @@ A channel is a representation of a sequence of messages. It has meta data like c
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| channelID | uint64 | PATH | Channel ID | N/A | YES |
| userID | []uint64 | POST | User ID | N/A | NO |
| userID | []string | POST | User ID | N/A | NO |
## Attach file to channel
+11 -5
View File
@@ -33,10 +33,13 @@ func (Channel) New() *Channel {
func (ctrl *Channel) Create(ctx context.Context, r *request.ChannelCreate) (interface{}, error) {
channel := &types.Channel{
Name: r.Name,
Topic: r.Topic,
Type: types.ChannelType(r.Type),
Members: r.Members,
Name: r.Name,
Topic: r.Topic,
Type: types.ChannelType(r.Type),
// Due to golang's inability do decode uint64 slice from string slice, we're expecting
// string input for members (for now)
// https://github.com/golang/go/issues/15624
Members: payload.ParseUInt64s(r.Members),
}
return ctrl.wrap(ctrl.svc.ch.With(ctx).Create(channel))
@@ -94,7 +97,10 @@ func (ctrl *Channel) Members(ctx context.Context, r *request.ChannelMembers) (in
}
func (ctrl *Channel) Invite(ctx context.Context, r *request.ChannelInvite) (interface{}, error) {
return ctrl.wrapMemberSet(ctrl.svc.ch.With(ctx).InviteUser(r.ChannelID, r.UserID...))
// Due to golang's inability do decode uint64 slice from string slice, we're expecting
// string input for members (for now)
// https://github.com/golang/go/issues/15624
return ctrl.wrapMemberSet(ctrl.svc.ch.With(ctx).InviteUser(r.ChannelID, payload.ParseUInt64s(r.UserID)...))
}
func (ctrl *Channel) Join(ctx context.Context, r *request.ChannelJoin) (interface{}, error) {
+3 -7
View File
@@ -81,7 +81,7 @@ type ChannelCreate struct {
Name string
Topic string
Type string
Members []uint64 `json:",string"`
Members []string
}
func NewChannelCreate() *ChannelCreate {
@@ -128,8 +128,6 @@ func (cReq *ChannelCreate) Fill(r *http.Request) (err error) {
cReq.Type = val
}
cReq.Members = parseUInt64A(r.Form["members"])
return err
}
@@ -515,8 +513,8 @@ var _ RequestFiller = NewChannelPart()
// Channel invite request parameters
type ChannelInvite struct {
ChannelID uint64 `json:",string"`
UserID []uint64 `json:",string"`
ChannelID uint64 `json:",string"`
UserID []string
}
func NewChannelInvite() *ChannelInvite {
@@ -552,8 +550,6 @@ func (cReq *ChannelInvite) Fill(r *http.Request) (err error) {
cReq.ChannelID = parseUInt64(chi.URLParam(r, "channelID"))
cReq.UserID = parseUInt64A(r.Form["userID"])
return err
}