Added option to specify created conversation is a DM
parent
1064edce60
commit
a48a4f4e2d
|
@ -23,14 +23,14 @@ Supply environment variables by either exporting them or editing ```.env```.
|
||||||
|
|
||||||
## API
|
## 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 |
|
| Contents |
|
||||||
| -------- |
|
| -------- |
|
||||||
| [Create User](#Create-User) |
|
| [Create User](#Create-User) |
|
||||||
| [Get Users by Phone](#Get-Users-by-Phone) |
|
| [Get Users by Phone](#Get-Users-by-Phone) |
|
||||||
| [Get User by ID](#Get-User-by-ID) |
|
| [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) |
|
| [Update User](#Update-User) |
|
||||||
| [Create Conversation](#Create-Conversation) |
|
| [Create Conversation](#Create-Conversation) |
|
||||||
| [Delete Conversation](#Delete-Conversation) |
|
| [Delete Conversation](#Delete-Conversation) |
|
||||||
|
@ -252,6 +252,7 @@ Create a new conversation for a user.
|
||||||
| Name | Type | Description | Required |
|
| Name | Type | Description | Required |
|
||||||
| ---- | ---- | ----------- | -------- |
|
| ---- | ---- | ----------- | -------- |
|
||||||
| title | String | Title of the conversation | X |
|
| title | String | Title of the conversation | X |
|
||||||
|
| dm | Boolean | Whether the conversation is a DM or not | X |
|
||||||
|
|
||||||
#### Success Response (200 OK)
|
#### Success Response (200 OK)
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,8 @@ func (h *Handler) CreateConversation(w http.ResponseWriter, r *http.Request, p h
|
||||||
|
|
||||||
// Conversation
|
// Conversation
|
||||||
_, err1 := tx.Exec(`
|
_, err1 := tx.Exec(`
|
||||||
INSERT INTO "conversation" (id, title) VALUES ($1, $2)
|
INSERT INTO "conversation" (id, title, dm) VALUES ($1, $2, $3)
|
||||||
`, conversation.ID, conversation.Title)
|
`, conversation.ID, conversation.Title, conversation.DM)
|
||||||
// First member
|
// First member
|
||||||
_, err2 := tx.Exec(`
|
_, err2 := tx.Exec(`
|
||||||
INSERT INTO member ("user", "conversation") VALUES ($1, $2)
|
INSERT INTO member ("user", "conversation") VALUES ($1, $2)
|
||||||
|
|
1
types.go
1
types.go
|
@ -3,6 +3,7 @@ package main
|
||||||
type Conversation struct {
|
type Conversation struct {
|
||||||
ID string `json:"id"` // id
|
ID string `json:"id"` // id
|
||||||
Title string `json:"title"` // title
|
Title string `json:"title"` // title
|
||||||
|
DM bool `json:"dm"` // dm
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|
Loading…
Reference in New Issue