4
1
Fork 0

Added option to specify created conversation is a DM

pull/24/head
Daniel Lim 2019-07-02 23:01:44 +08:00
parent 1064edce60
commit a48a4f4e2d
3 changed files with 6 additions and 4 deletions

View File

@ -23,14 +23,14 @@ Supply environment variables by either exporting them or editing ```.env```.
## API
Unless otherwise noted, bodies and responses are with `Content-Type: application/json`. Endpoints marked with a `*` require a populated `X-User-Claim` header from `backend-auth`.
Unless otherwise noted, bodies and responses are with `Content-Type: application/json`. Endpoints marked with a ```*``` require a populated `X-User-Claim` header from `backend-auth`.
| Contents |
| -------- |
| [Create User](#Create-User) |
| [Get Users by Phone](#Get-Users-by-Phone) |
| [Get User by ID](#Get-User-by-ID) |
| [Get User by Username(#Get-User-by-Username) ]
| [Get User by Username](#Get-User-by-Username) ]
| [Update User](#Update-User) |
| [Create Conversation](#Create-Conversation) |
| [Delete Conversation](#Delete-Conversation) |
@ -252,6 +252,7 @@ Create a new conversation for a user.
| Name | Type | Description | Required |
| ---- | ---- | ----------- | -------- |
| title | String | Title of the conversation | X |
| dm | Boolean | Whether the conversation is a DM or not | X |
#### Success Response (200 OK)

View File

@ -225,8 +225,8 @@ func (h *Handler) CreateConversation(w http.ResponseWriter, r *http.Request, p h
// Conversation
_, err1 := tx.Exec(`
INSERT INTO "conversation" (id, title) VALUES ($1, $2)
`, conversation.ID, conversation.Title)
INSERT INTO "conversation" (id, title, dm) VALUES ($1, $2, $3)
`, conversation.ID, conversation.Title, conversation.DM)
// First member
_, err2 := tx.Exec(`
INSERT INTO member ("user", "conversation") VALUES ($1, $2)

View File

@ -3,6 +3,7 @@ package main
type Conversation struct {
ID string `json:"id"` // id
Title string `json:"title"` // title
DM bool `json:"dm"` // dm
}
type User struct {