diff --git a/VERSION b/VERSION index 471f554e9..39a60331f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.76.4+hotfix.1 +0.76.4+hotfix.2 diff --git a/protocol/chat.go b/protocol/chat.go index 1aa1966bb..3f1a3f3b7 100644 --- a/protocol/chat.go +++ b/protocol/chat.go @@ -33,7 +33,11 @@ const ( ChatTypeCommunityChat ) -const pkStringLength = 68 +const ( + // timelineChatID is a magic ID for the singleton timeline chat + timelineChatID = "@timeline70bd746ddcc12beb96b2c9d572d0784ab137ffc774f5383e50585a932080b57cca0484b259e61cecbaa33a4c98a300a" + pkStringLength = 68 +) type Chat struct { // ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one @@ -285,6 +289,16 @@ func CreateOneToOneChat(name string, publicKey *ecdsa.PublicKey, timesource comm } } +func CreateTimelineChat(timesource common.TimeSource) *Chat { + return &Chat{ + ID: timelineChatID, + Name: "#" + timelineChatID, + Timestamp: int64(timesource.GetCurrentTime()), + Active: true, + ChatType: ChatTypeTimeline, + } +} + func CreateCommunityChat(orgID, chatID string, orgChat *protobuf.CommunityChat, timesource common.TimeSource) *Chat { color := orgChat.Identity.Color if color == "" { diff --git a/protocol/messenger.go b/protocol/messenger.go index 54962c140..52c914550 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -3071,7 +3071,16 @@ func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*common return nil, "", err } - if chat.Timeline() { + if chatID == timelineChatID { + // If no timeline chat exists, creates it + if chat == nil { + err = m.ensureTimelineChat() + if err != nil { + return nil, "", err + + } + } + var chatIDs = []string{"@" + contactIDFromPublicKey(&m.identity.PublicKey)} contacts, err := m.persistence.Contacts() if err != nil { @@ -4172,7 +4181,14 @@ func (m *Messenger) EmojiReactionsByChatID(chatID string, cursor string, limit i return nil, err } - if chat.Timeline() { + if chatID == timelineChatID { + if chat == nil { + err = m.ensureTimelineChat() + if err != nil { + return nil, err + } + } + var chatIDs = []string{"@" + contactIDFromPublicKey(&m.identity.PublicKey)} m.allContacts.Range(func(contactID string, contact *Contact) (shouldContinue bool) { if contact.IsAdded() { diff --git a/protocol/messenger_chats.go b/protocol/messenger_chats.go index 5d0794ff6..2d16dcdb5 100644 --- a/protocol/messenger_chats.go +++ b/protocol/messenger_chats.go @@ -228,3 +228,18 @@ func (m *Messenger) Join(chat *Chat) ([]*transport.Filter, error) { return nil, errors.New("chat is neither public nor private") } } + +func (m *Messenger) ensureTimelineChat() error { + chat, err := m.persistence.Chat(timelineChatID) + if err != nil { + return err + } + + if chat == nil { + chat = CreateTimelineChat(m.getTimesource()) + } + + m.allChats.Store(timelineChatID, chat) + + return nil +}