Implement Quote Messages #11

Merged
dan merged 2 commits from quote into trunk 2021-07-07 16:09:29 +00:00
2 changed files with 15 additions and 5 deletions
Showing only changes of commit bf193e6542 - Show all commits

6
lib.go
View File

@ -566,11 +566,7 @@ func GetMessagesByContentHash(profileOnion, handle string, contentHash string) s
profile := application.GetPeer(profileOnion)
ph := utils.NewPeerHelper(profile)
var err error
if ph.IsGroup(handle) {
indexedMessages,err = profile.GetGroup(handle).Timeline.GetMessagesByHash(contentHash)
} else {
indexedMessages,err = profile.GetContact(handle).Timeline.GetMessagesByHash(contentHash)
}
indexedMessages, err = ph.GetTimeline(handle).GetMessagesByHash(contentHash)
if err != nil {
indexedMessages = []model.LocallyIndexedMessage{}
}

View File

@ -36,6 +36,20 @@ func (p *PeerHelper) IsServer(id string) bool {
return ok
}
// GetTimeline returns a pointer to the timeline associated with the conversation handle
func (p *PeerHelper) GetTimeline(handle string) *model.Timeline {
if p.IsServer(handle) {
// This should *never* happen
log.Errorf("server accessed as contact when getting timeline...")
return &model.Timeline{}
}
// We return a pointer to the timeline to avoid copying, accessing Timeline is thread-safe
if p.IsGroup(handle) {
return &p.peer.GetGroup(handle).Timeline
}
return &p.peer.GetContact(handle).Timeline
}
/*
func getOrDefault(id, key string, defaultVal string) string {
var val string