Update to work with latest signald client protocol as of https://gitlab.com/thefinn93/signald/-/merge_requests/14
This commit is contained in:
parent
34a208588b
commit
c3bfae8751
4 changed files with 71 additions and 39 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"git.callpipe.com/finn/signald-go/signald"
|
"git.callpipe.com/finn/signald-go/signald"
|
||||||
|
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -43,7 +44,7 @@ var sendCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
if toUser != "" {
|
if toUser != "" {
|
||||||
request.RecipientNumber = toUser
|
request.RecipientAddress = v1.JsonAddress{Number: toUser}
|
||||||
} else if toGroup != "" {
|
} else if toGroup != "" {
|
||||||
request.RecipientGroupID = toGroup
|
request.RecipientGroupID = toGroup
|
||||||
} else {
|
} else {
|
||||||
|
|
44
signald/client-protocol/v1/types.go
Normal file
44
signald/client-protocol/v1/types.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package v1
|
||||||
|
|
||||||
|
// JsonAddress is a signal user's contact information. a phone number, UUID or both
|
||||||
|
type JsonAddress struct {
|
||||||
|
UUID string `json:"uuid"`
|
||||||
|
Number string `json:"number"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonMessageRequestResponseMessage struct {
|
||||||
|
Person JsonAddress `json:"person"`
|
||||||
|
GroupID string `json:"groupId"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonReaction struct {
|
||||||
|
Emoji string `json:"emoji"`
|
||||||
|
Remove bool `json:"remove"`
|
||||||
|
TargetAuthor JsonAddress `json:"targetAuthor"`
|
||||||
|
TargetSentTimestamp uint64 `json:"targetSentTimestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonReadMessage struct {
|
||||||
|
Sender JsonAddress `json:"sender"`
|
||||||
|
Timestamp uint64 `json:"timestamp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JsonSendMessageResult struct {
|
||||||
|
Address JsonAddress `json:"address"`
|
||||||
|
Success Success `json:"success"`
|
||||||
|
NetworkFailure bool `json:"networkFailure"`
|
||||||
|
UnregisteredFailure bool `json:"unregisteredFailure"`
|
||||||
|
IdentityFailure string `json:"identityFailure"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Success struct {
|
||||||
|
Unidentified bool `json:"unidentified"`
|
||||||
|
NeedsSync bool `json:"needsSync"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RequestValidationFailure struct {
|
||||||
|
ValidationResults []string `json:"validationResults"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
|
@ -15,47 +15,30 @@
|
||||||
|
|
||||||
package signald
|
package signald
|
||||||
|
|
||||||
/* The class in signald:
|
import (
|
||||||
class JsonRequest {
|
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
||||||
public String type;
|
)
|
||||||
public String id;
|
|
||||||
public String username;
|
|
||||||
public String messageBody;
|
|
||||||
public String recipientNumber;
|
|
||||||
public String recipientGroupId;
|
|
||||||
public Boolean voice;
|
|
||||||
public String code;
|
|
||||||
public String deviceName;
|
|
||||||
public List<String> attachmentFilenames;
|
|
||||||
public String uri;
|
|
||||||
public String groupName;
|
|
||||||
public List<String> members;
|
|
||||||
public String avatar;
|
|
||||||
|
|
||||||
JsonRequest() {}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Request represents a message sent to signald
|
// Request represents a message sent to signald
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
MessageBody string `json:"messageBody,omitempty"`
|
MessageBody string `json:"messageBody,omitempty"`
|
||||||
RecipientNumber string `json:"recipientNumber,omitempty"`
|
RecipientAddress v1.JsonAddress `json:"recipientAddress,omitempty"`
|
||||||
RecipientGroupID string `json:"recipientGroupId,omitempty"`
|
RecipientGroupID string `json:"recipientGroupId,omitempty"`
|
||||||
Voice bool `json:"voice,omitempty"`
|
Voice bool `json:"voice,omitempty"`
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
DeviceName string `json:"deviceName,omitempty"`
|
DeviceName string `json:"deviceName,omitempty"`
|
||||||
AttachmentFilenames []string `json:"attachmentFilenames,omitempty"`
|
AttachmentFilenames []string `json:"attachmentFilenames,omitempty"`
|
||||||
URI string `json:"uri,omitempty"`
|
URI string `json:"uri,omitempty"`
|
||||||
Attachments []Attachment `json:"attachments,omitempty"`
|
Attachments []JsonAttachment `json:"attachments,omitempty"`
|
||||||
GroupName string `json:"groupName,omitempty"`
|
GroupName string `json:"groupName,omitempty"`
|
||||||
Members []string `json:"members,omitempty"`
|
Members []string `json:"members,omitempty"`
|
||||||
Avatar string `json:"avatar,omitempty"`
|
Avatar string `json:"avatar,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Attachment struct {
|
type JsonAttachment struct {
|
||||||
Filename string `json:"filename"`
|
Filename string `json:"filename"`
|
||||||
Caption string `json:"caption"`
|
Caption string `json:"caption"`
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package signald
|
package signald
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
|
||||||
|
)
|
||||||
|
|
||||||
// Response is a response to a request to signald, or a new inbound message
|
// Response is a response to a request to signald, or a new inbound message
|
||||||
type Response struct {
|
type Response struct {
|
||||||
ID string
|
ID string
|
||||||
|
@ -15,9 +19,9 @@ type ResponseData struct {
|
||||||
DataMessage DataMessage
|
DataMessage DataMessage
|
||||||
Message string
|
Message string
|
||||||
Username string
|
Username string
|
||||||
Source string
|
Source v1.JsonAddress
|
||||||
SourceDevice int
|
SourceDevice int
|
||||||
Type int
|
Type string
|
||||||
IsReceipt bool
|
IsReceipt bool
|
||||||
Timestamp float64
|
Timestamp float64
|
||||||
ServerTimestamp float64
|
ServerTimestamp float64
|
||||||
|
|
Loading…
Reference in a new issue