From 60778761c21dd68e082db03f7668097d03f86acc Mon Sep 17 00:00:00 2001 From: Finn Date: Sat, 27 Feb 2021 12:29:48 -0800 Subject: [PATCH] Update protocol --- protocol.json | 403 ++----------------- signald/client-protocol/v1/requests.go | 25 -- signald/client-protocol/v1/structs.go | 6 +- signald/client-protocol/v1alpha1/requests.go | 260 ------------ signald/client-protocol/v1alpha1/structs.go | 95 ----- signald/client-protocol/v1alpha2/requests.go | 44 -- signald/client-protocol/v1alpha2/structs.go | 30 -- 7 files changed, 37 insertions(+), 826 deletions(-) delete mode 100644 signald/client-protocol/v1alpha1/requests.go delete mode 100644 signald/client-protocol/v1alpha1/structs.go delete mode 100644 signald/client-protocol/v1alpha2/requests.go delete mode 100644 signald/client-protocol/v1alpha2/structs.go diff --git a/protocol.json b/protocol.json index 3281fa0..3205011 100644 --- a/protocol.json +++ b/protocol.json @@ -2,9 +2,9 @@ "doc_version": "v1", "version": { "name": "signald", - "version": "0.12.0+git2021-02-18r577f6d0f.36", + "version": "0.12.0+git2021-02-26r10a16d18.43", "branch": "main", - "commit": "577f6d0f076466fe6006fea2e99c53519531830b" + "commit": "10a16d18fed05327ac723a0dc561bf2800115f6f" }, "info": "This document describes objects that may be used when communicating with signald.", "types": { @@ -34,7 +34,7 @@ }, "timestamp": { "type": "long", - "example": "1613676833495" + "example": "1614362423771" }, "timestampISO": { "type": "String" @@ -44,7 +44,7 @@ }, "serverDeliveredTimestamp": { "type": "long", - "example": "161367683349580" + "example": "161436242377180" }, "hasLegacyMessage": { "type": "boolean" @@ -124,7 +124,7 @@ }, "timestamp": { "type": "long", - "example": "1613676833495" + "example": "1614362423771" } } }, @@ -165,7 +165,7 @@ }, "version": { "type": "String", - "example": "\"0.12.0+git2021-02-18r577f6d0f.36\"" + "example": "\"0.12.0+git2021-02-26r10a16d18.43\"" }, "branch": { "type": "String", @@ -173,7 +173,7 @@ }, "commit": { "type": "String", - "example": "\"577f6d0f076466fe6006fea2e99c53519531830b\"" + "example": "\"10a16d18fed05327ac723a0dc561bf2800115f6f\"" } } }, @@ -360,9 +360,6 @@ } } }, - "ProtocolRequest": { - "fields": {} - }, "RemoveLinkedDeviceRequest": { "fields": { "account": { @@ -517,7 +514,7 @@ "list": true, "type": "Long", "doc": "List of messages to mark as read", - "example": "1613676833495", + "example": "1614362423771", "required": true } } @@ -607,7 +604,7 @@ }, "async": { "type": "boolean", - "doc": "return results from local store immediately, refreshing from server if needed. If false (default), block until all pending profiles have been retrieved." + "doc": "return results from local store immediately, refreshing from server afterward if needed. If false (default), block until all pending profiles have been retrieved." } } }, @@ -716,7 +713,7 @@ "timestamp": { "type": "long", "doc": "the timestamp that the message was sent at, according to the sender's device. This is used to uniquely identify this message for things like reactions and quotes.", - "example": "1613676833495" + "example": "1614362423771" }, "attachments": { "list": true, @@ -853,7 +850,7 @@ "id": { "type": "long", "doc": "the client timestamp of the message being quoted", - "example": "1613676833495" + "example": "1614362423771" }, "author": { "type": "JsonAddress", @@ -941,28 +938,7 @@ "targetSentTimestamp": { "type": "long", "doc": "the client timestamp of the message being reacted to", - "example": "1613676833495" - } - } - }, - "JsonGroupInfo": { - "fields": { - "groupId": { - "type": "String" - }, - "members": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "name": { - "type": "String" - }, - "type": { - "type": "String" - }, - "avatarId": { - "type": "long" + "example": "1614362423771" } } }, @@ -1000,6 +976,27 @@ } } }, + "JsonGroupInfo": { + "fields": { + "groupId": { + "type": "String" + }, + "members": { + "list": true, + "type": "JsonAddress", + "version": "v1" + }, + "name": { + "type": "String" + }, + "type": { + "type": "String" + }, + "avatarId": { + "type": "long" + } + } + }, "Capabilities": { "fields": { "gv2": { @@ -1021,7 +1018,7 @@ }, "timestamp": { "type": "long", - "example": "1613676833495" + "example": "1614362423771" }, "expirationStartTimestamp": { "type": "long" @@ -1059,7 +1056,7 @@ }, "timestamp": { "type": "long", - "example": "1613676833495" + "example": "1614362423771" } } }, @@ -1071,7 +1068,7 @@ }, "timestamp": { "type": "long", - "example": "1613676833495" + "example": "1614362423771" } } }, @@ -1490,276 +1487,6 @@ "Type": { "fields": {} } - }, - "v1alpha1": { - "ProtocolRequest": { - "fields": {}, - "deprecated": true - }, - "GetLinkedDevicesRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - } - }, - "doc": "list all linked devices on a Signal account", - "deprecated": true - }, - "LinkedDevices": { - "fields": { - "devices": { - "list": true, - "type": "DeviceInfo", - "version": "v0" - } - } - }, - "RemoveLinkedDeviceRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "deviceId": { - "type": "long", - "doc": "the ID of the device to unlink", - "example": "3", - "required": true - } - }, - "doc": "Remove a linked device from the Signal account. Only allowed when the local device id is 1", - "deprecated": true - }, - "JoinGroupRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "uri": { - "type": "String", - "doc": "The signal.group URL", - "example": "\"https://signal.group/#CjQKINH_GZhXhfifTcnBkaKTNRxW-hHKnGSq-cJNyPVqHRp8EhDUB7zjKNEl0NaULhsqJCX3\"", - "required": true - } - }, - "doc": "Join a group using the a signal.group URL. Note that you must have a profile name set to join groups.", - "deprecated": true - }, - "JsonGroupJoinInfo": { - "fields": { - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"" - }, - "title": { - "type": "String", - "example": "\"Parkdale Run Club\"" - }, - "memberCount": { - "type": "int", - "example": "3" - }, - "addFromInviteLink": { - "type": "int" - }, - "revision": { - "type": "int", - "example": "5" - }, - "pendingAdminApproval": { - "type": "boolean" - } - } - }, - "UpdateGroupRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"", - "required": true - }, - "title": { - "type": "String", - "example": "\"Parkdale Run Club\"" - }, - "addMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "removeMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - } - }, - "doc": "modify a group. only v2 groups for now", - "deprecated": true - }, - "JsonGroupV2Info": { - "fields": { - "id": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"" - }, - "revision": { - "type": "int", - "example": "5" - }, - "title": { - "type": "String", - "example": "\"Parkdale Run Club\"" - }, - "timer": { - "type": "int", - "example": "604800" - }, - "members": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "pendingMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "requestingMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "inviteLink": { - "type": "String" - } - } - }, - "AcceptInvitationRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"", - "required": true - } - }, - "doc": "Accept a v2 group invitation. Note that you must have a profile name set to join groups.", - "deprecated": true - }, - "ApproveMembershipRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"", - "required": true - }, - "members": { - "list": true, - "type": "JsonAddress", - "version": "v1", - "doc": "list of requesting members to approve", - "required": true - } - }, - "doc": "approve a request to join a group", - "deprecated": true - }, - "GetGroupRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"", - "required": true - }, - "revision": { - "type": "int", - "doc": "the latest known revision, default value (-1) forces fetch from server" - } - }, - "doc": "Query the server for the latest state of a known group", - "deprecated": true - } - }, - "v1alpha2": { - "UpdateGroupRequest": { - "fields": { - "account": { - "type": "String", - "doc": "The identifier of the account to interact with", - "example": "\"+12024561414\"", - "required": true - }, - "groupID": { - "type": "String", - "example": "\"EdSqI90cS0UomDpgUXOlCoObWvQOXlH5G3Z2d3f4ayE=\"", - "required": true - }, - "title": { - "type": "String", - "example": "\"Parkdale Run Club\"" - }, - "avatar": { - "type": "String", - "example": "\"/tmp/image.jpg\"" - }, - "addMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - }, - "removeMembers": { - "list": true, - "type": "JsonAddress", - "version": "v1" - } - }, - "doc": "modify a group", - "deprecated": true - }, - "GroupInfo": { - "fields": { - "v1": { - "type": "JsonGroupInfo", - "version": "v1" - }, - "v2": { - "type": "JsonGroupV2Info", - "version": "v1" - } - }, - "doc": "A generic type that is used when the group version is not known" - } } }, "actions": { @@ -1802,9 +1529,6 @@ "response": "JsonGroupJoinInfo", "doc": "Join a group using the a signal.group URL. Note that you must have a profile name set to join groups." }, - "protocol": { - "request": "ProtocolRequest" - }, "remove_linked_device": { "request": "RemoveLinkedDeviceRequest", "doc": "Remove a linked device from the Signal account. Only allowed when the local device id is 1" @@ -1855,61 +1579,6 @@ "request": "FinishLinkRequest", "response": "Account" } - }, - "v1alpha1": { - "protocol": { - "request": "ProtocolRequest", - "deprecated": true - }, - "get_linked_devices": { - "request": "GetLinkedDevicesRequest", - "response": "LinkedDevices", - "doc": "list all linked devices on a Signal account", - "deprecated": true - }, - "remove_linked_device": { - "request": "RemoveLinkedDeviceRequest", - "doc": "Remove a linked device from the Signal account. Only allowed when the local device id is 1", - "deprecated": true - }, - "join_group": { - "request": "JoinGroupRequest", - "response": "JsonGroupJoinInfo", - "doc": "Join a group using the a signal.group URL. Note that you must have a profile name set to join groups.", - "deprecated": true - }, - "update_group": { - "request": "UpdateGroupRequest", - "response": "JsonGroupV2Info", - "doc": "modify a group. only v2 groups for now", - "deprecated": true - }, - "accept_invitation": { - "request": "AcceptInvitationRequest", - "response": "JsonGroupV2Info", - "doc": "Accept a v2 group invitation. Note that you must have a profile name set to join groups.", - "deprecated": true - }, - "approve_membership": { - "request": "ApproveMembershipRequest", - "response": "JsonGroupV2Info", - "doc": "approve a request to join a group", - "deprecated": true - }, - "get_group": { - "request": "GetGroupRequest", - "response": "JsonGroupV2Info", - "doc": "Query the server for the latest state of a known group", - "deprecated": true - } - }, - "v1alpha2": { - "update_group": { - "request": "UpdateGroupRequest", - "response": "GroupInfo", - "doc": "modify a group", - "deprecated": true - } } } } diff --git a/signald/client-protocol/v1/requests.go b/signald/client-protocol/v1/requests.go index 56970d7..887a4c9 100644 --- a/signald/client-protocol/v1/requests.go +++ b/signald/client-protocol/v1/requests.go @@ -426,31 +426,6 @@ func (r *MarkReadRequest) Submit(conn *signald.Signald) (err error) { } -func (r *ProtocolRequest) Submit(conn *signald.Signald) (err error) { - r.Version = "v1" - r.Type = "protocol" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - return err - -} - // Submit: react to a previous message func (r *ReactRequest) Submit(conn *signald.Signald) (response SendResponse, err error) { r.Version = "v1" diff --git a/signald/client-protocol/v1/structs.go b/signald/client-protocol/v1/structs.go index 8a613d2..9865e65 100644 --- a/signald/client-protocol/v1/structs.go +++ b/signald/client-protocol/v1/structs.go @@ -300,7 +300,7 @@ type LinkingURI struct { type ListContactsRequest struct { Request Account string `json:"account,omitempty" yaml:"account,omitempty"` - Async bool `json:"async,omitempty" yaml:"async,omitempty"` // return results from local store immediately, refreshing from server if needed. If false (default), block until all pending profiles have been retrieved. + Async bool `json:"async,omitempty" yaml:"async,omitempty"` // return results from local store immediately, refreshing from server afterward if needed. If false (default), block until all pending profiles have been retrieved. } type ListGroupsRequest struct { @@ -331,10 +331,6 @@ type ProfileList struct { Profiles []*Profile `json:"profiles,omitempty" yaml:"profiles,omitempty"` } -type ProtocolRequest struct { - Request -} - // ReactRequest: react to a previous message type ReactRequest struct { Request diff --git a/signald/client-protocol/v1alpha1/requests.go b/signald/client-protocol/v1alpha1/requests.go deleted file mode 100644 index f3f39ff..0000000 --- a/signald/client-protocol/v1alpha1/requests.go +++ /dev/null @@ -1,260 +0,0 @@ -package v1alpha1 - -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo - -import ( - "encoding/json" - "fmt" - "log" - - "gitlab.com/signald/signald-go/signald" -) - -// Submit: Accept a v2 group invitation. Note that you must have a profile name set to join groups. -func (r *AcceptInvitationRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) { - r.Version = "v1alpha1" - r.Type = "accept_invitation" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} - -// Submit: approve a request to join a group -func (r *ApproveMembershipRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) { - r.Version = "v1alpha1" - r.Type = "approve_membership" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} - -// Submit: Query the server for the latest state of a known group -func (r *GetGroupRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) { - r.Version = "v1alpha1" - r.Type = "get_group" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} - -// Submit: list all linked devices on a Signal account -func (r *GetLinkedDevicesRequest) Submit(conn *signald.Signald) (response LinkedDevices, err error) { - r.Version = "v1alpha1" - r.Type = "get_linked_devices" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} - -// Submit: Join a group using the a signal.group URL. Note that you must have a profile name set to join groups. -func (r *JoinGroupRequest) Submit(conn *signald.Signald) (response JsonGroupJoinInfo, err error) { - r.Version = "v1alpha1" - r.Type = "join_group" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} - -func (r *ProtocolRequest) Submit(conn *signald.Signald) (err error) { - r.Version = "v1alpha1" - r.Type = "protocol" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - return err - -} - -// Submit: Remove a linked device from the Signal account. Only allowed when the local device id is 1 -func (r *RemoveLinkedDeviceRequest) Submit(conn *signald.Signald) (err error) { - r.Version = "v1alpha1" - r.Type = "remove_linked_device" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - return err - -} - -// Submit: modify a group. only v2 groups for now -func (r *UpdateGroupRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) { - r.Version = "v1alpha1" - r.Type = "update_group" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} diff --git a/signald/client-protocol/v1alpha1/structs.go b/signald/client-protocol/v1alpha1/structs.go deleted file mode 100644 index fbc1288..0000000 --- a/signald/client-protocol/v1alpha1/structs.go +++ /dev/null @@ -1,95 +0,0 @@ -package v1alpha1 - -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo - -import ( - "gitlab.com/signald/signald-go/signald/client-protocol/v0" - "gitlab.com/signald/signald-go/signald/client-protocol/v1" -) - -type Request struct { - ID string `json:"id" yaml:"id"` - Version string `json:"version" yaml:"version"` - Type string `json:"type" yaml:"type"` -} - -// AcceptInvitationRequest: Accept a v2 group invitation. Note that you must have a profile name set to join groups. -type AcceptInvitationRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` -} - -// ApproveMembershipRequest: approve a request to join a group -type ApproveMembershipRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` - Members []*v1.JsonAddress `json:"members,omitempty" yaml:"members,omitempty"` // list of requesting members to approve -} - -// GetGroupRequest: Query the server for the latest state of a known group -type GetGroupRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` - Revision int32 `json:"revision,omitempty" yaml:"revision,omitempty"` // the latest known revision, default value (-1) forces fetch from server -} - -// GetLinkedDevicesRequest: list all linked devices on a Signal account -type GetLinkedDevicesRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with -} - -// JoinGroupRequest: Join a group using the a signal.group URL. Note that you must have a profile name set to join groups. -type JoinGroupRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` // The signal.group URL -} - -type JsonGroupJoinInfo struct { - AddFromInviteLink int32 `json:"addFromInviteLink,omitempty" yaml:"addFromInviteLink,omitempty"` - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` - MemberCount int32 `json:"memberCount,omitempty" yaml:"memberCount,omitempty"` - PendingAdminApproval bool `json:"pendingAdminApproval,omitempty" yaml:"pendingAdminApproval,omitempty"` - Revision int32 `json:"revision,omitempty" yaml:"revision,omitempty"` - Title string `json:"title,omitempty" yaml:"title,omitempty"` -} - -type JsonGroupV2Info struct { - ID string `json:"id,omitempty" yaml:"id,omitempty"` - InviteLink string `json:"inviteLink,omitempty" yaml:"inviteLink,omitempty"` - Members []*v1.JsonAddress `json:"members,omitempty" yaml:"members,omitempty"` - PendingMembers []*v1.JsonAddress `json:"pendingMembers,omitempty" yaml:"pendingMembers,omitempty"` - RequestingMembers []*v1.JsonAddress `json:"requestingMembers,omitempty" yaml:"requestingMembers,omitempty"` - Revision int32 `json:"revision,omitempty" yaml:"revision,omitempty"` - Timer int32 `json:"timer,omitempty" yaml:"timer,omitempty"` - Title string `json:"title,omitempty" yaml:"title,omitempty"` -} - -type LinkedDevices struct { - Devices []*v0.DeviceInfo `json:"devices,omitempty" yaml:"devices,omitempty"` -} - -type ProtocolRequest struct { - Request -} - -// RemoveLinkedDeviceRequest: Remove a linked device from the Signal account. Only allowed when the local device id is 1 -type RemoveLinkedDeviceRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - DeviceId int64 `json:"deviceId,omitempty" yaml:"deviceId,omitempty"` // the ID of the device to unlink -} - -// UpdateGroupRequest: modify a group. only v2 groups for now -type UpdateGroupRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with - AddMembers []*v1.JsonAddress `json:"addMembers,omitempty" yaml:"addMembers,omitempty"` - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` - RemoveMembers []*v1.JsonAddress `json:"removeMembers,omitempty" yaml:"removeMembers,omitempty"` - Title string `json:"title,omitempty" yaml:"title,omitempty"` -} diff --git a/signald/client-protocol/v1alpha2/requests.go b/signald/client-protocol/v1alpha2/requests.go deleted file mode 100644 index 018a254..0000000 --- a/signald/client-protocol/v1alpha2/requests.go +++ /dev/null @@ -1,44 +0,0 @@ -package v1alpha2 - -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo - -import ( - "encoding/json" - "fmt" - "log" - - "gitlab.com/signald/signald-go/signald" -) - -// Submit: modify a group -func (r *UpdateGroupRequest) Submit(conn *signald.Signald) (response GroupInfo, err error) { - r.Version = "v1alpha2" - r.Type = "update_group" - if r.ID == "" { - r.ID = signald.GenerateID() - } - err = conn.RawRequest(r) - if err != nil { - log.Println("signald-go: error submitting request to signald") - return - } - - responseChannel := conn.GetResponseListener(r.ID) - defer conn.CloseResponseListener(r.ID) - - rawResponse := <-responseChannel - if rawResponse.Error != nil { - err = fmt.Errorf("signald error: %s", string(rawResponse.Error)) - return - } - - err = json.Unmarshal(rawResponse.Data, &response) - if err != nil { - rawResponseJson, _ := rawResponse.Data.MarshalJSON() - log.Println("signald-go: error unmarshalling response from signald of type", rawResponse.Type, string(rawResponseJson)) - return - } - - return response, nil - -} diff --git a/signald/client-protocol/v1alpha2/structs.go b/signald/client-protocol/v1alpha2/structs.go deleted file mode 100644 index d594209..0000000 --- a/signald/client-protocol/v1alpha2/structs.go +++ /dev/null @@ -1,30 +0,0 @@ -package v1alpha2 - -// DO NOT EDIT: this file is automatically generated by ./tools/generator in this repo - -import ( - "gitlab.com/signald/signald-go/signald/client-protocol/v1" -) - -type Request struct { - ID string `json:"id" yaml:"id"` - Version string `json:"version" yaml:"version"` - Type string `json:"type" yaml:"type"` -} - -// GroupInfo: A generic type that is used when the group version is not known -type GroupInfo struct { - V1 *v1.JsonGroupInfo `json:"v1,omitempty" yaml:"v1,omitempty"` - V2 *v1.JsonGroupV2Info `json:"v2,omitempty" yaml:"v2,omitempty"` -} - -// UpdateGroupRequest: modify a group -type UpdateGroupRequest struct { - Request - Account string `json:"account,omitempty" yaml:"account,omitempty"` // The identifier of the account to interact with - AddMembers []*v1.JsonAddress `json:"addMembers,omitempty" yaml:"addMembers,omitempty"` - Avatar string `json:"avatar,omitempty" yaml:"avatar,omitempty"` - GroupID string `json:"groupID,omitempty" yaml:"groupID,omitempty"` - RemoveMembers []*v1.JsonAddress `json:"removeMembers,omitempty" yaml:"removeMembers,omitempty"` - Title string `json:"title,omitempty" yaml:"title,omitempty"` -}