Update protocol

This commit is contained in:
Finn 2021-06-12 16:13:00 -07:00
parent 2a9e942b78
commit a2f2cf9c05
3 changed files with 72 additions and 4 deletions

View file

@ -2,9 +2,9 @@
"doc_version": "v1", "doc_version": "v1",
"version": { "version": {
"name": "signald", "name": "signald",
"version": "0.13.1+git2021-05-25re38e8fc8.8", "version": "0.13.1+git2021-06-11recc12048.24",
"branch": "main", "branch": "main",
"commit": "e38e8fc88a659df3d65f2db5dfd5f19b1a181747" "commit": "ecc12048b02b601b21ad563dd3f48adb5f59f605"
}, },
"info": "This document describes objects that may be used when communicating with signald.", "info": "This document describes objects that may be used when communicating with signald.",
"types": { "types": {
@ -165,7 +165,7 @@
}, },
"version": { "version": {
"type": "String", "type": "String",
"example": "\"0.13.1+git2021-05-25re38e8fc8.8\"" "example": "\"0.13.1+git2021-06-11recc12048.24\""
}, },
"branch": { "branch": {
"type": "String", "type": "String",
@ -173,7 +173,7 @@
}, },
"commit": { "commit": {
"type": "String", "type": "String",
"example": "\"e38e8fc88a659df3d65f2db5dfd5f19b1a181747\"" "example": "\"ecc12048b02b601b21ad563dd3f48adb5f59f605\""
} }
} }
}, },
@ -1022,6 +1022,26 @@
}, },
"doc": "set this device's name. This will show up on the mobile device on the same account under " "doc": "set this device's name. This will show up on the mobile device on the same account under "
}, },
"GetAllIdentities": {
"fields": {
"account": {
"type": "String",
"doc": "The account to interact with",
"example": "\"+12024561414\"",
"required": true
}
},
"doc": "get all known identity keys"
},
"AllIdentityKeyList": {
"fields": {
"identity_keys": {
"list": true,
"type": "IdentityKeyList",
"version": "v1"
}
}
},
"JsonDataMessage": { "JsonDataMessage": {
"fields": { "fields": {
"timestamp": { "timestamp": {
@ -1975,6 +1995,11 @@
"set_device_name": { "set_device_name": {
"request": "SetDeviceNameRequest", "request": "SetDeviceNameRequest",
"doc": "set this device's name. This will show up on the mobile device on the same account under " "doc": "set this device's name. This will show up on the mobile device on the same account under "
},
"get_all_identities": {
"request": "GetAllIdentities",
"response": "AllIdentityKeyList",
"doc": "get all known identity keys"
} }
} }
} }

View file

@ -225,6 +225,39 @@ func (r *GenerateLinkingURIRequest) Submit(conn *signald.Signald) (response Link
} }
// Submit: get all known identity keys
func (r *GetAllIdentities) Submit(conn *signald.Signald) (response AllIdentityKeyList, err error) {
r.Version = "v1"
r.Type = "get_all_identities"
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 // Submit: Query the server for the latest state of a known group
func (r *GetGroupRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) { func (r *GetGroupRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) {
r.Version = "v1" r.Version = "v1"

View file

@ -37,6 +37,10 @@ type AddLinkedDeviceRequest struct {
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` // the tsdevice:/ uri provided (typically in qr code form) by the new device Uri string `json:"uri,omitempty" yaml:"uri,omitempty"` // the tsdevice:/ uri provided (typically in qr code form) by the new device
} }
type AllIdentityKeyList struct {
IdentityKeys []*IdentityKeyList `json:"identity_keys,omitempty" yaml:"identity_keys,omitempty"`
}
// ApproveMembershipRequest: approve a request to join a group // ApproveMembershipRequest: approve a request to join a group
type ApproveMembershipRequest struct { type ApproveMembershipRequest struct {
Request Request
@ -86,6 +90,12 @@ type GenerateLinkingURIRequest struct {
Request Request
} }
// GetAllIdentities: get all known identity keys
type GetAllIdentities struct {
Request
Account string `json:"account,omitempty" yaml:"account,omitempty"` // The account to interact with
}
// GetGroupRequest: Query the server for the latest state of a known group // GetGroupRequest: Query the server for the latest state of a known group
type GetGroupRequest struct { type GetGroupRequest struct {
Request Request