Skip to content

Commit

Permalink
added expiration_time to Update Groups endpoint
Browse files Browse the repository at this point in the history
see #616
  • Loading branch information
bbernhard committed Nov 15, 2024
1 parent cddf3c1 commit 2c4ef75
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ type CreateGroupRequest struct {
}

type UpdateGroupRequest struct {
Base64Avatar *string `json:"base64_avatar"`
Description *string `json:"description"`
Name *string `json:"name"`
Base64Avatar *string `json:"base64_avatar"`
Description *string `json:"description"`
Name *string `json:"name"`
ExpirationTime *int `json:"expiration_time"`
}

type ChangeGroupMembersRequest struct {
Expand Down Expand Up @@ -1477,7 +1478,7 @@ func (a *Api) UpdateGroup(c *gin.Context) {
return
}

err = a.signalClient.UpdateGroup(number, internalGroupId, req.Base64Avatar, req.Description, req.Name)
err = a.signalClient.UpdateGroup(number, internalGroupId, req.Base64Avatar, req.Description, req.Name, req.ExpirationTime)
if err != nil {
c.JSON(400, Error{Msg: err.Error()})
return
Expand Down
11 changes: 10 additions & 1 deletion src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ func (s *SignalClient) QuitGroup(number string, groupId string) error {
return err
}

func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *string, groupDescription *string, groupName *string) error {
func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *string, groupDescription *string, groupName *string, expirationTime *int) error {
var err error
var avatarTmpPath string = ""
if base64Avatar != nil {
Expand Down Expand Up @@ -1638,6 +1638,7 @@ func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *
Avatar string `json:"avatar,omitempty"`
Description *string `json:"description,omitempty"`
Name *string `json:"name,omitempty"`
Expiration int `json:"expiration,omitempty"`
}
request := Request{GroupId: groupId}

Expand All @@ -1648,6 +1649,10 @@ func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *
request.Description = groupDescription
request.Name = groupName

if expirationTime != nil {
request.Expiration = *expirationTime
}

jsonRpc2Client, err := s.getJsonRpc2Client()
if err != nil {
return err
Expand All @@ -1667,6 +1672,10 @@ func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *
cmd = append(cmd, []string{"-n", *groupName}...)
}

if expirationTime != nil {
cmd = append(cmd, []string{"--expiration", strconv.Itoa(*expirationTime)}...)
}

_, err = s.cliClient.Execute(true, cmd, "")
}

Expand Down
5 changes: 3 additions & 2 deletions src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,9 @@ const docTemplate = `{
"description": {
"type": "string"
},
"expiration_time": {
"type": "integer"
},
"name": {
"type": "string"
}
Expand Down Expand Up @@ -2712,8 +2715,6 @@ var SwaggerInfo = &swag.Spec{
Description: "This is the Signal Cli REST API documentation.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
Expand Down
3 changes: 3 additions & 0 deletions src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,9 @@
"description": {
"type": "string"
},
"expiration_time": {
"type": "integer"
},
"name": {
"type": "string"
}
Expand Down
2 changes: 2 additions & 0 deletions src/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ definitions:
type: string
description:
type: string
expiration_time:
type: integer
name:
type: string
type: object
Expand Down

0 comments on commit 2c4ef75

Please sign in to comment.