diff --git a/doc/EXAMPLES.md b/doc/EXAMPLES.md index 597175d..cdc93da 100644 --- a/doc/EXAMPLES.md +++ b/doc/EXAMPLES.md @@ -125,6 +125,16 @@ e.g: `curl -X DELETE -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups/+431212131491291/ckRzaEd4VmRzNnJaASAEsasa'` +- Terminate (end) a group for everyone + + Permanently end the group with the given group id for all members. Afterwards nobody, not even an admin, can send messages or start calls in the group, but members keep the message history. This can't be undone. The account must be an admin of the group. + + `curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups///terminate'` + + e.g: + + `curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups/+431212131491291/group.ckRzaEd4VmRzNnJaASAEsasa/terminate'` + - Link a device `curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/qrcodelink?device_name='` diff --git a/src/api/api.go b/src/api/api.go index 465fa03..8bb0671 100644 --- a/src/api/api.go +++ b/src/api/api.go @@ -1790,6 +1790,42 @@ func (a *Api) QuitGroup(c *gin.Context) { c.Status(http.StatusNoContent) } +// @Summary Terminate a Signal Group for all members. +// @Tags Groups +// @Description Permanently end the specified Signal Group for everyone ("End group" in the Signal apps). Afterwards no member, not even an admin, can send messages or start calls in the group; members keep the existing message history. This can't be undone. Requires admin rights in the group. +// @Accept json +// @Produce json +// @Success 204 {string} OK +// @Failure 400 {object} Error +// @Param number path string true "Account identifier (E.164 phone number or ACI UUID)" +// @Param groupid path string true "Group ID" +// @Router /v1/groups/{number}/{groupid}/terminate [post] +func (a *Api) TerminateGroup(c *gin.Context) { + _, number, err := accountIdentifierFromParam(c) + if err != nil { + c.JSON(400, Error{Msg: err.Error()}) + return + } + if number == "" { + c.JSON(400, Error{Msg: "Couldn't process request - number missing"}) + return + } + + groupId := c.Param("groupid") + internalGroupId, err := client.ConvertGroupIdToInternalGroupId(groupId) + if err != nil { + c.JSON(400, Error{Msg: err.Error()}) + return + } + + err = a.signalClient.TerminateGroup(number, internalGroupId) + if err != nil { + c.JSON(400, Error{Msg: err.Error()}) + return + } + c.Status(http.StatusNoContent) +} + // @Summary Update the state of a Signal Group. // @Tags Groups // @Description Update the state of a Signal Group. diff --git a/src/client/client.go b/src/client/client.go index 6dc0d1f..03f69f8 100644 --- a/src/client/client.go +++ b/src/client/client.go @@ -2133,6 +2133,25 @@ func (s *SignalClient) QuitGroup(number string, groupId string) error { return err } +func (s *SignalClient) TerminateGroup(number string, groupId string) error { + var err error + var jsonRpc2Client *JsonRpc2Client + if s.signalCliMode == JsonRpc { + type Request struct { + GroupId string `json:"groupId"` + } + request := Request{GroupId: groupId} + jsonRpc2Client, err = s.getJsonRpc2Client() + if err != nil { + return err + } + _, err = jsonRpc2Client.getRaw("terminateGroup", &number, request) + } else { + _, err = s.cliClient.Execute(true, []string{"--config", s.signalCliConfig, "-a", number, "terminateGroup", "-g", groupId}, "") + } + return err +} + func (s *SignalClient) UpdateGroup(number string, groupId string, base64Avatar *string, groupDescription *string, groupName *string, expirationTime *int, groupLinkState *GroupLinkState, editGroupPermission GroupPermission, addMembersPermission GroupPermission, sendMessagesPermission GroupPermission) error { var err error diff --git a/src/docs/docs.go b/src/docs/docs.go index db26180..96a8e1c 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -4082,6 +4082,51 @@ const docTemplate = `{ ] } }, + "/v1/groups/{number}/{groupid}/terminate": { + "post": { + "consumes": [ + "application/json" + ], + "description": "Permanently end the specified Signal Group for everyone (\"End group\" in the Signal apps). Afterwards no member, not even an admin, can send messages or start calls in the group; members keep the existing message history. This can't be undone. Requires admin rights in the group.", + "parameters": [ + { + "description": "Account identifier (E.164 phone number or ACI UUID)", + "in": "path", + "name": "number", + "required": true, + "type": "string" + }, + { + "description": "Group ID", + "in": "path", + "name": "groupid", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "204": { + "description": "No Content", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + }, + "summary": "Terminate a Signal Group for all members.", + "tags": [ + "Groups" + ] + } + }, "/v1/health": { "get": { "description": "Internally used by the docker container to perform the health check.", diff --git a/src/docs/swagger.json b/src/docs/swagger.json index c8e910b..0fb0953 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -4077,6 +4077,51 @@ ] } }, + "/v1/groups/{number}/{groupid}/terminate": { + "post": { + "consumes": [ + "application/json" + ], + "description": "Permanently end the specified Signal Group for everyone (\"End group\" in the Signal apps). Afterwards no member, not even an admin, can send messages or start calls in the group; members keep the existing message history. This can't be undone. Requires admin rights in the group.", + "parameters": [ + { + "description": "Account identifier (E.164 phone number or ACI UUID)", + "in": "path", + "name": "number", + "required": true, + "type": "string" + }, + { + "description": "Group ID", + "in": "path", + "name": "groupid", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "204": { + "description": "No Content", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.Error" + } + } + }, + "summary": "Terminate a Signal Group for all members.", + "tags": [ + "Groups" + ] + } + }, "/v1/health": { "get": { "description": "Internally used by the docker container to perform the health check.", diff --git a/src/main.go b/src/main.go index 30ac26f..be9f6b7 100644 --- a/src/main.go +++ b/src/main.go @@ -234,6 +234,7 @@ func main() { groups.POST(":number/:groupid/block", api.BlockGroup) groups.POST(":number/:groupid/join", api.JoinGroup) groups.POST(":number/:groupid/quit", api.QuitGroup) + groups.POST(":number/:groupid/terminate", api.TerminateGroup) groups.PUT(":number/:groupid", api.UpdateGroup) groups.POST(":number/:groupid/members", api.AddMembersToGroup) groups.DELETE(":number/:groupid/members", api.RemoveMembersFromGroup)