Skip to content

Commit

Permalink
Images Album (#3021)
Browse files Browse the repository at this point in the history
* feat: add `AlbumID` field to messages
  • Loading branch information
OmarBasem authored Dec 14, 2022
1 parent 3025cdc commit d03691c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 72 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.116.0
0.117.0
4 changes: 4 additions & 0 deletions protocol/common/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ type Message struct {
AudioPath string `json:"audioPath,omitempty"`
// ImageLocalURL is the local url of the image
ImageLocalURL string `json:"imageLocalUrl,omitempty"`
// AlbumID for a collage of images
AlbumID string `json:"albumId,omitempty"`
// AudioLocalURL is the local url of the audio
AudioLocalURL string `json:"audioLocalUrl,omitempty"`
// StickerLocalURL is the local url of the sticker
Expand Down Expand Up @@ -229,6 +231,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
EnsName string `json:"ensName"`
DisplayName string `json:"displayName"`
Image string `json:"image,omitempty"`
AlbumID string `json:"albumId,omitempty"`
Audio string `json:"audio,omitempty"`
AudioDurationMs uint64 `json:"audioDurationMs,omitempty"`
CommunityID string `json:"communityId,omitempty"`
Expand Down Expand Up @@ -269,6 +272,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
EnsName: m.EnsName,
DisplayName: m.DisplayName,
Image: m.ImageLocalURL,
AlbumID: m.AlbumID,
Audio: m.AudioLocalURL,
CommunityID: m.CommunityID,
Timestamp: m.Timestamp,
Expand Down
9 changes: 9 additions & 0 deletions protocol/message_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (db sqlitePersistence) tableUserMessagesAllFields() string {
sticker_hash,
image_payload,
image_type,
album_id,
image_base64,
audio_payload,
audio_type,
Expand Down Expand Up @@ -114,6 +115,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string {
m1.sticker_hash,
m1.image_payload,
m1.image_type,
m1.album_id,
COALESCE(m1.audio_duration_ms,0),
m1.community_id,
m1.mentions,
Expand Down Expand Up @@ -187,6 +189,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
var alias sql.NullString
var identicon sql.NullString
var communityID sql.NullString
var albumID sql.NullString
var gapFrom sql.NullInt64
var gapTo sql.NullInt64
var editedAt sql.NullInt64
Expand Down Expand Up @@ -226,6 +229,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
&sticker.Hash,
&image.Payload,
&image.Type,
&message.AlbumID,
&audio.DurationMs,
&communityID,
&serializedMentions,
Expand Down Expand Up @@ -325,6 +329,10 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
message.CommunityID = communityID.String
}

if albumID.Valid {
message.AlbumID = albumID.String
}

if serializedMentions != nil {
err := json.Unmarshal(serializedMentions, &message.Mentions)
if err != nil {
Expand Down Expand Up @@ -442,6 +450,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message)
sticker.Hash,
image.Payload,
image.Type,
message.AlbumID,
message.Base64Image,
audio.Payload,
audio.Type,
Expand Down
Loading

0 comments on commit d03691c

Please sign in to comment.