3
0

fix(sam): undeclared parameter for channel join

This commit is contained in:
Tit Petric
2018-09-13 14:50:55 +02:00
parent 7bf78fb4e0
commit 639891c5ed
7 changed files with 42 additions and 32 deletions

View File

@@ -1,9 +1,9 @@
package rest
import (
"github.com/crusttech/crust/internal/auth"
"github.com/crusttech/crust/crm/rest/handlers"
"github.com/crusttech/crust/crm/service"
"github.com/crusttech/crust/internal/auth"
"github.com/go-chi/chi"
)

View File

@@ -293,7 +293,7 @@ A channel is a representation of a sequence of messages. It has meta data like c
| --------- | ---- | ------ | ----------- | ------- | --------- |
| channelID | uint64 | PATH | Channel ID | N/A | YES |
## Join channel
## List channel members
#### Method
@@ -313,13 +313,14 @@ A channel is a representation of a sequence of messages. It has meta data like c
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/channels/{channelID}/members/{userID}` | HTTP/S | POST | Client ID, Session ID |
| `/channels/{channelID}/members/{userID}/join` | HTTP/S | POST | Client ID, Session ID |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| channelID | uint64 | PATH | Channel ID | N/A | YES |
| userID | uint64 | PATH | Member ID | N/A | NO |
## Remove member from channel
@@ -327,14 +328,14 @@ A channel is a representation of a sequence of messages. It has meta data like c
| URI | Protocol | Method | Authentication |
| --- | -------- | ------ | -------------- |
| `/channels/{channelID}/members/{userID}` | HTTP/S | DELETE | Client ID, Session ID |
| `/channels/{channelID}/members/{userID}/part` | HTTP/S | DELETE | Client ID, Session ID |
#### Request parameters
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| channelID | uint64 | PATH | Channel ID | N/A | YES |
| userID | uint64 | PATH | Member ID | N/A | YES |
| userID | uint64 | PATH | Member ID | N/A | NO |
## Join channel

View File

@@ -261,7 +261,7 @@
"name": "members",
"method": "GET",
"path": "/{channelID}/members",
"title": "Join channel",
"title": "List channel members",
"parameters": {
"path": [
{ "name": "channelID", "type": "uint64", "required": true, "title": "Channel ID" }
@@ -271,23 +271,24 @@
{
"name": "join",
"method": "POST",
"path": "/{channelID}/members/{userID}",
"path": "/{channelID}/members/{userID}/join",
"title": "Join channel",
"parameters": {
"path": [
{ "name": "channelID", "type": "uint64", "required": true, "title": "Channel ID" }
{ "name": "channelID", "type": "uint64", "required": true, "title": "Channel ID" },
{ "name": "userID", "type": "uint64", "required": false, "title": "Member ID" }
]
}
},
{
"name": "part",
"method": "DELETE",
"path": "/{channelID}/members/{userID}",
"path": "/{channelID}/members/{userID}/part",
"title": "Remove member from channel",
"parameters": {
"path": [
{ "name": "channelID", "type": "uint64", "required": true, "title": "Channel ID" },
{ "name": "userID", "type": "uint64", "required": true, "title": "Member ID" }
{ "name": "channelID", "type": "uint64", "required": true, "title": "Channel ID" },
{ "name": "userID", "type": "uint64", "required": false, "title": "Member ID" }
]
}
},

View File

@@ -127,7 +127,7 @@
{
"Name": "members",
"Method": "GET",
"Title": "Join channel",
"Title": "List channel members",
"Path": "/{channelID}/members",
"Parameters": {
"path": [
@@ -144,23 +144,7 @@
"Name": "join",
"Method": "POST",
"Title": "Join channel",
"Path": "/{channelID}/members/{userID}",
"Parameters": {
"path": [
{
"name": "channelID",
"required": true,
"title": "Channel ID",
"type": "uint64"
}
]
}
},
{
"Name": "part",
"Method": "DELETE",
"Title": "Remove member from channel",
"Path": "/{channelID}/members/{userID}",
"Path": "/{channelID}/members/{userID}/join",
"Parameters": {
"path": [
{
@@ -171,7 +155,29 @@
},
{
"name": "userID",
"required": false,
"title": "Member ID",
"type": "uint64"
}
]
}
},
{
"Name": "part",
"Method": "DELETE",
"Title": "Remove member from channel",
"Path": "/{channelID}/members/{userID}/part",
"Parameters": {
"path": [
{
"name": "channelID",
"required": true,
"title": "Channel ID",
"type": "uint64"
},
{
"name": "userID",
"required": false,
"title": "Member ID",
"type": "uint64"
}

View File

@@ -138,8 +138,8 @@ func (ch *Channel) MountRoutes(r chi.Router, middlewares ...func(http.Handler) h
r.Get("/{channelID}", ch.Read)
r.Delete("/{channelID}", ch.Delete)
r.Get("/{channelID}/members", ch.Members)
r.Post("/{channelID}/members/{userID}", ch.Join)
r.Delete("/{channelID}/members/{userID}", ch.Part)
r.Post("/{channelID}/members/{userID}/join", ch.Join)
r.Delete("/{channelID}/members/{userID}/part", ch.Part)
r.Post("/{channelID}/invite", ch.Invite)
r.Post("/{channelID}/attach", ch.Attach)
})

View File

@@ -316,6 +316,7 @@ var _ RequestFiller = NewChannelMembers()
// Channel join request parameters
type ChannelJoin struct {
ChannelID uint64
UserID uint64
}
func NewChannelJoin() *ChannelJoin {
@@ -349,6 +350,7 @@ func (c *ChannelJoin) Fill(r *http.Request) error {
}
c.ChannelID = parseUInt64(chi.URLParam(r, "channelID"))
c.UserID = parseUInt64(chi.URLParam(r, "userID"))
return err
}

View File

@@ -4,9 +4,9 @@ import (
"context"
"fmt"
"github.com/crusttech/crust/internal/auth"
"github.com/crusttech/crust/internal/store"
"github.com/crusttech/crust/sam/repository"
"github.com/crusttech/crust/sam/types"
"github.com/crusttech/crust/internal/store"
"github.com/titpetric/factory"
"io"
"log"