Commit c3bfae87 authored by Finn's avatar Finn 🌵
Browse files

Update to work with latest signald client protocol as of...

Update to work with latest signald client protocol as of https://gitlab.com/thefinn93/signald/-/merge_requests/14
parent 34a20858
Pipeline #3949 passed with stages
in 1 minute and 53 seconds
......@@ -21,6 +21,7 @@ import (
"github.com/spf13/cobra"
"git.callpipe.com/finn/signald-go/signald"
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
)
var (
......@@ -43,7 +44,7 @@ var sendCmd = &cobra.Command{
}
if toUser != "" {
request.RecipientNumber = toUser
request.RecipientAddress = v1.JsonAddress{Number: toUser}
} else if toGroup != "" {
request.RecipientGroupID = toGroup
} else {
......
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
/* The class in signald:
class JsonRequest {
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() {}
}
*/
import (
"git.callpipe.com/finn/signald-go/signald/client-protocol/v1"
)
// Request represents a message sent to signald
type Request struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Username string `json:"username,omitempty"`
MessageBody string `json:"messageBody,omitempty"`
RecipientNumber string `json:"recipientNumber,omitempty"`
RecipientGroupID string `json:"recipientGroupId,omitempty"`
Voice bool `json:"voice,omitempty"`
Code string `json:"code,omitempty"`
DeviceName string `json:"deviceName,omitempty"`
AttachmentFilenames []string `json:"attachmentFilenames,omitempty"`
URI string `json:"uri,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
GroupName string `json:"groupName,omitempty"`
Members []string `json:"members,omitempty"`
Avatar string `json:"avatar,omitempty"`
Type string `json:"type"`
ID string `json:"id,omitempty"`
Username string `json:"username,omitempty"`
MessageBody string `json:"messageBody,omitempty"`
RecipientAddress v1.JsonAddress `json:"recipientAddress,omitempty"`
RecipientGroupID string `json:"recipientGroupId,omitempty"`
Voice bool `json:"voice,omitempty"`
Code string `json:"code,omitempty"`
DeviceName string `json:"deviceName,omitempty"`
AttachmentFilenames []string `json:"attachmentFilenames,omitempty"`
URI string `json:"uri,omitempty"`
Attachments []JsonAttachment `json:"attachments,omitempty"`
GroupName string `json:"groupName,omitempty"`
Members []string `json:"members,omitempty"`
Avatar string `json:"avatar,omitempty"`
}
type Attachment struct {
type JsonAttachment struct {
Filename string `json:"filename"`
Caption string `json:"caption"`
Width int `json:"width"`
......
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
type Response struct {
ID string
......@@ -15,9 +19,9 @@ type ResponseData struct {
DataMessage DataMessage
Message string
Username string
Source string
Source v1.JsonAddress
SourceDevice int
Type int
Type string
IsReceipt bool
Timestamp float64
ServerTimestamp float64
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment