added expiration_time parameter to create group endpoint

see #587
This commit is contained in:
Bernhard B
2024-10-07 23:02:33 +02:00
parent 1506c1c9d4
commit 94e93cbe35
5 changed files with 25 additions and 208 deletions

View File

@@ -48,6 +48,7 @@ type CreateGroupRequest struct {
Description string `json:"description"` Description string `json:"description"`
Permissions GroupPermissions `json:"permissions"` Permissions GroupPermissions `json:"permissions"`
GroupLinkState string `json:"group_link" enums:"disabled,enabled,enabled-with-approval"` GroupLinkState string `json:"group_link" enums:"disabled,enabled,enabled-with-approval"`
ExpirationTime *int `json:"expiration_time"`
} }
type UpdateGroupRequest struct { type UpdateGroupRequest struct {
@@ -668,7 +669,7 @@ func (a *Api) CreateGroup(c *gin.Context) {
groupLinkState = groupLinkState.FromString(req.GroupLinkState) groupLinkState = groupLinkState.FromString(req.GroupLinkState)
} }
groupId, err := a.signalClient.CreateGroup(number, req.Name, req.Members, req.Description, editGroupPermission, addMembersPermission, groupLinkState) groupId, err := a.signalClient.CreateGroup(number, req.Name, req.Members, req.Description, editGroupPermission, addMembersPermission, groupLinkState, req.ExpirationTime)
if err != nil { if err != nil {
c.JSON(400, Error{Msg: err.Error()}) c.JSON(400, Error{Msg: err.Error()})
return return

View File

@@ -868,7 +868,7 @@ func (s *SignalClient) RemoveReceiveChannel(channelUuid string) {
jsonRpc2Client.RemoveReceiveChannel(channelUuid) jsonRpc2Client.RemoveReceiveChannel(channelUuid)
} }
func (s *SignalClient) CreateGroup(number string, name string, members []string, description string, editGroupPermission GroupPermission, addMembersPermission GroupPermission, groupLinkState GroupLinkState) (string, error) { func (s *SignalClient) CreateGroup(number string, name string, members []string, description string, editGroupPermission GroupPermission, addMembersPermission GroupPermission, groupLinkState GroupLinkState, expirationTime *int) (string, error) {
var internalGroupId string var internalGroupId string
if s.signalCliMode == JsonRpc { if s.signalCliMode == JsonRpc {
type Request struct { type Request struct {
@@ -878,6 +878,7 @@ func (s *SignalClient) CreateGroup(number string, name string, members []string,
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
EditGroupPermissions string `json:"setPermissionEditDetails,omitempty"` EditGroupPermissions string `json:"setPermissionEditDetails,omitempty"`
AddMembersPermissions string `json:"setPermissionAddMember,omitempty"` AddMembersPermissions string `json:"setPermissionAddMember,omitempty"`
Expiration int `json:"expiration,omitempty"`
} }
request := Request{Name: name, Members: members} request := Request{Name: name, Members: members}
@@ -897,6 +898,10 @@ func (s *SignalClient) CreateGroup(number string, name string, members []string,
request.AddMembersPermissions = addMembersPermission.String() request.AddMembersPermissions = addMembersPermission.String()
} }
if expirationTime != nil {
request.Expiration = *expirationTime
}
jsonRpc2Client, err := s.getJsonRpc2Client() jsonRpc2Client, err := s.getJsonRpc2Client()
if err != nil { if err != nil {
return "", err return "", err
@@ -936,6 +941,10 @@ func (s *SignalClient) CreateGroup(number string, name string, members []string,
cmd = append(cmd, []string{"--description", description}...) cmd = append(cmd, []string{"--description", description}...)
} }
if expirationTime != nil {
cmd = append(cmd, []string{"--expiration", strconv.Itoa(*expirationTime)}...)
}
rawData, err := s.cliClient.Execute(true, cmd, "") rawData, err := s.cliClient.Execute(true, cmd, "")
if err != nil { if err != nil {
if strings.Contains(err.Error(), signalCliV2GroupError) { if strings.Contains(err.Error(), signalCliV2GroupError) {

View File

@@ -1,4 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT // Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs package docs
import "github.com/swaggo/swag" import "github.com/swaggo/swag"
@@ -2090,6 +2090,9 @@ const docTemplate = `{
"description": { "description": {
"type": "string" "type": "string"
}, },
"expiration_time": {
"type": "integer"
},
"group_link": { "group_link": {
"type": "string", "type": "string",
"enum": [ "enum": [
@@ -2275,69 +2278,7 @@ const docTemplate = `{
} }
}, },
"api.SendMessageV2": { "api.SendMessageV2": {
"type": "object", "type": "object"
"properties": {
"base64_attachments": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
]
},
"edit_timestamp": {
"type": "integer"
},
"mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"message": {
"type": "string"
},
"notify_self": {
"type": "boolean"
},
"number": {
"type": "string"
},
"quote_author": {
"type": "string"
},
"quote_mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"quote_message": {
"type": "string"
},
"quote_timestamp": {
"type": "integer"
},
"recipients": {
"type": "array",
"items": {
"type": "string"
}
},
"sticker": {
"type": "string"
},
"text_mode": {
"type": "string",
"enum": [
"normal",
"styled"
]
}
}
}, },
"api.SetUsernameRequest": { "api.SetUsernameRequest": {
"type": "object", "type": "object",
@@ -2607,20 +2548,6 @@ const docTemplate = `{
"type": "string" "type": "string"
} }
} }
},
"data.MessageMention": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"length": {
"type": "integer"
},
"start": {
"type": "integer"
}
}
} }
}, },
"tags": [ "tags": [
@@ -2685,6 +2612,8 @@ var SwaggerInfo = &swag.Spec{
Description: "This is the Signal Cli REST API documentation.", Description: "This is the Signal Cli REST API documentation.",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate, SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
} }
func init() { func init() {

View File

@@ -2083,6 +2083,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"expiration_time": {
"type": "integer"
},
"group_link": { "group_link": {
"type": "string", "type": "string",
"enum": [ "enum": [
@@ -2268,69 +2271,7 @@
} }
}, },
"api.SendMessageV2": { "api.SendMessageV2": {
"type": "object", "type": "object"
"properties": {
"base64_attachments": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e",
"data:\u003cMIME-TYPE\u003e;filename=\u003cFILENAME\u003e;base64\u003ccomma\u003e\u003cBASE64 ENCODED DATA\u003e"
]
},
"edit_timestamp": {
"type": "integer"
},
"mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"message": {
"type": "string"
},
"notify_self": {
"type": "boolean"
},
"number": {
"type": "string"
},
"quote_author": {
"type": "string"
},
"quote_mentions": {
"type": "array",
"items": {
"$ref": "#/definitions/data.MessageMention"
}
},
"quote_message": {
"type": "string"
},
"quote_timestamp": {
"type": "integer"
},
"recipients": {
"type": "array",
"items": {
"type": "string"
}
},
"sticker": {
"type": "string"
},
"text_mode": {
"type": "string",
"enum": [
"normal",
"styled"
]
}
}
}, },
"api.SetUsernameRequest": { "api.SetUsernameRequest": {
"type": "object", "type": "object",
@@ -2600,20 +2541,6 @@
"type": "string" "type": "string"
} }
} }
},
"data.MessageMention": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"length": {
"type": "integer"
},
"start": {
"type": "integer"
}
}
} }
}, },
"tags": [ "tags": [

View File

@@ -37,6 +37,8 @@ definitions:
properties: properties:
description: description:
type: string type: string
expiration_time:
type: integer
group_link: group_link:
enum: enum:
- disabled - disabled
@@ -161,48 +163,6 @@ definitions:
type: array type: array
type: object type: object
api.SendMessageV2: api.SendMessageV2:
properties:
base64_attachments:
example:
- <BASE64 ENCODED DATA>
- data:<MIME-TYPE>;base64<comma><BASE64 ENCODED DATA>
- data:<MIME-TYPE>;filename=<FILENAME>;base64<comma><BASE64 ENCODED DATA>
items:
type: string
type: array
edit_timestamp:
type: integer
mentions:
items:
$ref: '#/definitions/data.MessageMention'
type: array
message:
type: string
notify_self:
type: boolean
number:
type: string
quote_author:
type: string
quote_mentions:
items:
$ref: '#/definitions/data.MessageMention'
type: array
quote_message:
type: string
quote_timestamp:
type: integer
recipients:
items:
type: string
type: array
sticker:
type: string
text_mode:
enum:
- normal
- styled
type: string
type: object type: object
api.SetUsernameRequest: api.SetUsernameRequest:
properties: properties:
@@ -379,15 +339,6 @@ definitions:
username_link: username_link:
type: string type: string
type: object type: object
data.MessageMention:
properties:
author:
type: string
length:
type: integer
start:
type: integer
type: object
info: info:
contact: {} contact: {}
description: This is the Signal Cli REST API documentation. description: This is the Signal Cli REST API documentation.