Skip to content

Commit

Permalink
define attachment type from bluebubbles
Browse files Browse the repository at this point in the history
  • Loading branch information
trek-boldly-go committed Jan 16, 2024
1 parent 13b14a5 commit 926a64c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 36 deletions.
6 changes: 3 additions & 3 deletions imessage/bluebubbles/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,15 @@ func (bb *blueBubbles) BackfillTaskChan() <-chan *imessage.BackfillTask {

func (bb *blueBubbles) SendMessage(chatID, text string, replyTo string, replyToPart int, richLink *imessage.RichLink, metadata imessage.MessageMetadata) (*imessage.SendResponse, error) {

request := SendChatRequest{
request := SendTextRequest{
ChatGUID: chatID,
Method: "private-api",
Message: text,
SelectedMessageGuid: replyTo,
PartIndex: replyToPart,
}

var res SendChatResponse
var res SendTextResponse

err := bb.apiPost("/api/v1/message/text", request, &res)

Expand Down Expand Up @@ -785,7 +785,7 @@ func (bb *blueBubbles) SendFile(chatID, text, filename string, pathOnDisk string
path := "/api/v1/message/attachment"

// Make the API POST request with file
var response SendChatResponse // Assuming imessage.SendResponse is the correct type
var response SendTextResponse
if err := bb.apiPostWithFile(path, payload, pathOnDisk, &response); err != nil {
return nil, err
}
Expand Down
84 changes: 51 additions & 33 deletions imessage/bluebubbles/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,55 @@ type TypingNotification struct {
}

type Message struct {
AssociatedMessageGuid string `json:"associatedMessageGuid,omitempty"`
AssociatedMessageType interface{} `json:"associatedMessageType,omitempty"`
Attachments []interface{} `json:"attachments,omitempty"`
AttributedBody interface{} `json:"attributedBody,omitempty"`
BalloonBundleId interface{} `json:"balloonBundleId,omitempty"`
Chats []Chat `json:"chats,omitempty"`
DateCreated int64 `json:"dateCreated,omitempty"`
DateDelivered int64 `json:"dateDelivered,omitempty"`
DateEdited int64 `json:"dateEdited,omitempty"`
DateRead int64 `json:"dateRead,omitempty"`
DateRetracted int64 `json:"dateRetracted,omitempty"`
Error int `json:"error,omitempty"`
ExpressiveSendStyleId interface{} `json:"expressiveSendStyleId,omitempty"`
GroupActionType int `json:"groupActionType,omitempty"`
GroupTitle string `json:"groupTitle,omitempty"`
GUID string `json:"guid,omitempty"`
Handle Handle `json:"handle,omitempty"`
HandleId int `json:"handleId,omitempty"`
HasDdResults bool `json:"hasDdResults,omitempty"`
HasPayloadData bool `json:"hasPayloadData,omitempty"`
IsArchived bool `json:"isArchived,omitempty"`
IsFromMe bool `json:"isFromMe,omitempty"`
ItemType int `json:"itemType,omitempty"`
MessageSummaryInfo interface{} `json:"messageSummaryInfo,omitempty"`
OriginalROWID int `json:"originalROWID,omitempty"`
OtherHandle int `json:"otherHandle,omitempty"`
PartCount int `json:"partCount,omitempty"`
PayloadData interface{} `json:"payloadData,omitempty"`
Subject string `json:"subject,omitempty"`
Text string `json:"text,omitempty"`
ThreadOriginatorGuid string `json:"threadOriginatorGuid,omitempty"`
AssociatedMessageGuid string `json:"associatedMessageGuid,omitempty"`
AssociatedMessageType interface{} `json:"associatedMessageType,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
AttributedBody interface{} `json:"attributedBody,omitempty"`
BalloonBundleId interface{} `json:"balloonBundleId,omitempty"`
Chats []Chat `json:"chats,omitempty"`
DateCreated int64 `json:"dateCreated,omitempty"`
DateDelivered int64 `json:"dateDelivered,omitempty"`
DateEdited int64 `json:"dateEdited,omitempty"`
DateRead int64 `json:"dateRead,omitempty"`
DateRetracted int64 `json:"dateRetracted,omitempty"`
Error int `json:"error,omitempty"`
ExpressiveSendStyleId interface{} `json:"expressiveSendStyleId,omitempty"`
GroupActionType int `json:"groupActionType,omitempty"`
GroupTitle string `json:"groupTitle,omitempty"`
GUID string `json:"guid,omitempty"`
Handle Handle `json:"handle,omitempty"`
HandleId int `json:"handleId,omitempty"`
HasDdResults bool `json:"hasDdResults,omitempty"`
HasPayloadData bool `json:"hasPayloadData,omitempty"`
IsArchived bool `json:"isArchived,omitempty"`
IsFromMe bool `json:"isFromMe,omitempty"`
ItemType int `json:"itemType,omitempty"`
MessageSummaryInfo interface{} `json:"messageSummaryInfo,omitempty"`
OriginalROWID int `json:"originalROWID,omitempty"`
OtherHandle int `json:"otherHandle,omitempty"`
PartCount int `json:"partCount,omitempty"`
PayloadData interface{} `json:"payloadData,omitempty"`
Subject string `json:"subject,omitempty"`
Text string `json:"text,omitempty"`
ThreadOriginatorGuid string `json:"threadOriginatorGuid,omitempty"`
}

type Attachment struct {
OriginalRowID int `json:"originalROWID,omitempty"`
GUID string `json:"guid,omitempty"`
UTI string `json:"uti,omitempty"`
MimeType string `json:"mimeType,omitempty"`
TransferName string `json:"transferName,omitempty"`
TotalBytes int64 `json:"totalBytes,omitempty"`
TransferState int `json:"transferState,omitempty"`
IsOutgoing bool `json:"isOutgoing,omitempty"`
HideAttachment bool `json:"hideAttachment,omitempty"`
IsSticker bool `json:"isSticker,omitempty"`
OriginalGUID string `json:"originalGuid,omitempty"`
HasLivePhoto bool `json:"hasLivePhoto,omitempty"`
Height int64 `json:"height,omitempty"`
Width int64 `json:"width,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
}

type MessageResponse struct {
Expand All @@ -137,15 +155,15 @@ type Handle struct {
UncanonicalizedId interface{} `json:"uncanonicalizedId,omitempty"`
}

type SendChatRequest struct {
type SendTextRequest struct {
ChatGUID string `json:"chatGuid"`
Method string `json:"method"`
Message string `json:"message"`
SelectedMessageGuid string `json:"selectedMessageGuid"`
PartIndex int `json:"partIndex"`
}

type SendChatResponse struct {
type SendTextResponse struct {
Status int64 `json:"status"`
Message string `json:"message"`
Data Message `json:"data,omitempty"`
Expand Down

0 comments on commit 926a64c

Please sign in to comment.