Skip to content

Commit

Permalink
apply fixes from PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed Jan 15, 2024
1 parent f8e2450 commit 8e2f00f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
14 changes: 7 additions & 7 deletions imessage/bluebubbles/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ func (bb *blueBubbles) GetChatsWithMessagesAfter(minDate time.Time) (resp []imes
request := ChatQueryRequest{
Limit: limit,
Offset: offset,
With: []string{
"lastMessage",
"sms",
With: []ChatQueryWith{
ChatQueryWithLastMessage,
ChatQueryWithSMS,
},
Sort: "lastmessage",
Sort: QuerySortLastMessage,
}
var response ChatQueryResponse

Expand All @@ -329,10 +329,10 @@ func (bb *blueBubbles) GetChatsWithMessagesAfter(minDate time.Time) (resp []imes
return nil, err
}

for _, chat := range *response.Data {
for _, chat := range response.Data {
resp = append(resp, imessage.ChatIdentifier{
ChatGUID: fmt.Sprintf("%v", chat.GUID),
ThreadID: fmt.Sprintf("%v", chat.ChatIdentifier), // TODO Is this the right one to use?
ChatGUID: chat.GUID,
ThreadID: chat.GroupId,
})
}

Expand Down
23 changes: 18 additions & 5 deletions imessage/bluebubbles/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,31 @@ type PageMetadata struct {
Limit int64 `json:"limit"`
}

type QuerySort string

const (
QuerySortLastMessage QuerySort = "lastmessage"
)

type ChatQueryRequest struct {
// TODO Other Fields
Limit int64 `json:"limit"`
Offset int64 `json:"offset"`
With []string `json:"with"`
Sort string `json:"sort"`
Limit int64 `json:"limit"`
Offset int64 `json:"offset"`
With []ChatQueryWith `json:"with"`
Sort QuerySort `json:"sort"`
}

type ChatQueryWith string

const (
ChatQueryWithSMS ChatQueryWith = "sms"
ChatQueryWithLastMessage ChatQueryWith = "lastMessage"
)

type ChatQueryResponse struct {
Status int64 `json:"status"`
Message string `json:"message"`
Data *[]Chat `json:"data"`
Data []Chat `json:"data"`
Metadata PageMetadata `json:"metadata"`
}

Expand Down

0 comments on commit 8e2f00f

Please sign in to comment.