mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-23 09:34:24 +01:00
Merge branch 'master' of github.com:bbernhard/signal-cli-rest-api
This commit is contained in:
@@ -109,7 +109,7 @@ type SendMessageV2 struct {
|
|||||||
QuoteAuthor *string `json:"quote_author"`
|
QuoteAuthor *string `json:"quote_author"`
|
||||||
QuoteMessage *string `json:"quote_message"`
|
QuoteMessage *string `json:"quote_message"`
|
||||||
QuoteMentions []client.MessageMention `json:"quote_mentions"`
|
QuoteMentions []client.MessageMention `json:"quote_mentions"`
|
||||||
TextMode *string `json:"text_mode"`
|
TextMode *string `json:"text_mode" enums:"normal,styled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypingIndicatorRequest struct {
|
type TypingIndicatorRequest struct {
|
||||||
@@ -341,7 +341,7 @@ func (a *Api) Send(c *gin.Context) {
|
|||||||
|
|
||||||
// @Summary Send a signal message.
|
// @Summary Send a signal message.
|
||||||
// @Tags Messages
|
// @Tags Messages
|
||||||
// @Description Send a signal message
|
// @Description Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 201 {object} SendMessageResponse
|
// @Success 201 {object} SendMessageResponse
|
||||||
@@ -1623,3 +1623,27 @@ func (a *Api) GetTrustMode(c *gin.Context) {
|
|||||||
|
|
||||||
c.JSON(200, trustMode)
|
c.JSON(200, trustMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Send a synchronization message with the local contacts list to all linked devices.
|
||||||
|
// @Tags Contacts
|
||||||
|
// @Description Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param number path string true "Registered Phone Number"
|
||||||
|
// @Success 204
|
||||||
|
// @Failure 400 {object} Error
|
||||||
|
// @Router /v1/contacts{number}/sync [post]
|
||||||
|
func (a *Api) SendContacts(c *gin.Context) {
|
||||||
|
number := c.Param("number")
|
||||||
|
if number == "" {
|
||||||
|
c.JSON(400, Error{Msg: "Couldn't process request - number missing"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := a.signalClient.SendContacts(number)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(400, Error{Msg: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Status(http.StatusNoContent)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1582,6 +1582,21 @@ func (s *SignalClient) SearchForNumbers(number string, numbers []string) ([]Sear
|
|||||||
return searchResultEntries, err
|
return searchResultEntries, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s* SignalClient) SendContacts(number string) error {
|
||||||
|
var err error
|
||||||
|
if s.signalCliMode == JsonRpc {
|
||||||
|
jsonRpc2Client, err := s.getJsonRpc2Client(number)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = jsonRpc2Client.getRaw("sendContacts", nil)
|
||||||
|
} else {
|
||||||
|
cmd := []string{"--config", s.signalCliConfig, "-a", number, "sendContacts"}
|
||||||
|
_, err = s.cliClient.Execute(true, cmd, "")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SignalClient) UpdateContact(number string, recipient string, name *string, expirationInSeconds *int) error {
|
func (s *SignalClient) UpdateContact(number string, recipient string, name *string, expirationInSeconds *int) error {
|
||||||
var err error
|
var err error
|
||||||
if s.signalCliMode == JsonRpc {
|
if s.signalCliMode == JsonRpc {
|
||||||
|
|||||||
@@ -333,6 +333,39 @@ var doc = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/v1/contacts{number}/sync": {
|
||||||
|
"post": {
|
||||||
|
"description": "Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Contacts"
|
||||||
|
],
|
||||||
|
"summary": "Send a synchronization message with the local contacts list to all linked devices.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Registered Phone Number",
|
||||||
|
"name": "number",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"204": {},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/v1/devices/{number}": {
|
"/v1/devices/{number}": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Links another device to this device. Only works, if this is the master device.",
|
"description": "Links another device to this device. Only works, if this is the master device.",
|
||||||
@@ -1566,7 +1599,7 @@ var doc = `{
|
|||||||
},
|
},
|
||||||
"/v2/send": {
|
"/v2/send": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Send a signal message",
|
"description": "Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -1839,7 +1872,11 @@ var doc = `{
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"text_mode": {
|
"text_mode": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"normal",
|
||||||
|
"styled"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -317,6 +317,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/v1/contacts{number}/sync": {
|
||||||
|
"post": {
|
||||||
|
"description": "Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Contacts"
|
||||||
|
],
|
||||||
|
"summary": "Send a synchronization message with the local contacts list to all linked devices.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Registered Phone Number",
|
||||||
|
"name": "number",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"204": {},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/api.Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/v1/devices/{number}": {
|
"/v1/devices/{number}": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Links another device to this device. Only works, if this is the master device.",
|
"description": "Links another device to this device. Only works, if this is the master device.",
|
||||||
@@ -1550,7 +1583,7 @@
|
|||||||
},
|
},
|
||||||
"/v2/send": {
|
"/v2/send": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Send a signal message",
|
"description": "Send a signal message. Set the text_mode to 'styled' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -1823,7 +1856,11 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"text_mode": {
|
"text_mode": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"normal",
|
||||||
|
"styled"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ definitions:
|
|||||||
sticker:
|
sticker:
|
||||||
type: string
|
type: string
|
||||||
text_mode:
|
text_mode:
|
||||||
|
enum:
|
||||||
|
- normal
|
||||||
|
- styled
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
api.TrustIdentityRequest:
|
api.TrustIdentityRequest:
|
||||||
@@ -497,6 +500,28 @@ paths:
|
|||||||
summary: Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
|
summary: Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
|
||||||
tags:
|
tags:
|
||||||
- Contacts
|
- Contacts
|
||||||
|
/v1/contacts{number}/sync:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Send a synchronization message with the local contacts list to all linked devices. This command should only be used if this is the primary device.
|
||||||
|
parameters:
|
||||||
|
- description: Registered Phone Number
|
||||||
|
in: path
|
||||||
|
name: number
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"204": {}
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/api.Error'
|
||||||
|
summary: Send a synchronization message with the local contacts list to all linked devices.
|
||||||
|
tags:
|
||||||
|
- Contacts
|
||||||
/v1/devices/{number}:
|
/v1/devices/{number}:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -1317,7 +1342,7 @@ paths:
|
|||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: Send a signal message
|
description: 'Send a signal message. Set the text_mode to ''styled'' in case you want to add formatting to your text message. Styling Options: *italic text*, **bold text**, ~strikethrough text~.'
|
||||||
parameters:
|
parameters:
|
||||||
- description: Input Data
|
- description: Input Data
|
||||||
in: body
|
in: body
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ func main() {
|
|||||||
contacts := v1.Group("/contacts")
|
contacts := v1.Group("/contacts")
|
||||||
{
|
{
|
||||||
contacts.PUT(":number", api.UpdateContact)
|
contacts.PUT(":number", api.UpdateContact)
|
||||||
|
contacts.POST(":number/sync", api.SendContacts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user