Merge branch 'master' of git.openprivacy.ca:cwtch.im/cwtch into filey
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
erinn 2021-11-04 14:07:54 -07:00
commit 83935ac55c
2 changed files with 15 additions and 4 deletions

View File

@ -186,10 +186,18 @@ func (t *Timeline) Insert(mi *Message) int {
// check that we haven't seen this message before (this has no impact on p2p messages, but is essential for
// group messages)
idx, exists := t.signatureCache[base64.StdEncoding.EncodeToString(mi.Signature)]
if exists {
t.Messages[idx].Acknowledged = true
return idx
// FIXME: The below code now checks if the message has a signature. If it doesn't then skip duplication check.
// We do this because p2p messages right now do not have a signature, and so many p2p messages are not stored
// with a signature. In the future in hybrid groups this check will go away as all timelines will use the same
// underlying protocol.
// This is currently safe to do because p2p does not rely on signatures and groups will verify the signature of
// messages prior to generating an event to include them in the timeline.
if len(mi.Signature) != 0 {
idx, exists := t.signatureCache[base64.StdEncoding.EncodeToString(mi.Signature)]
if exists {
t.Messages[idx].Acknowledged = true
return idx
}
}
// update the message store

View File

@ -383,6 +383,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
t.Errorf("Alice's timeline does not have all messages")
} else {
// check message 0,1,2,3
alicesGroup.Timeline.Sort()
aliceGroupTimeline := alicesGroup.GetTimeline()
if aliceGroupTimeline[0].Message != aliceLines[0] || aliceGroupTimeline[1].Message != bobLines[0] ||
aliceGroupTimeline[2].Message != aliceLines[1] || aliceGroupTimeline[3].Message != bobLines[1] {
@ -394,6 +395,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
t.Errorf("Bob's timeline does not have all messages")
} else {
// check message 0,1,2,3,4,5
bobsGroup.Timeline.Sort()
bobGroupTimeline := bobsGroup.GetTimeline()
if bobGroupTimeline[0].Message != aliceLines[0] || bobGroupTimeline[1].Message != bobLines[0] ||
bobGroupTimeline[2].Message != aliceLines[1] || bobGroupTimeline[3].Message != bobLines[1] ||
@ -406,6 +408,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
t.Errorf("Carol's timeline does not have all messages")
} else {
// check message 0,1,2,3,4,5
carolsGroup.Timeline.Sort()
carolGroupTimeline := carolsGroup.GetTimeline()
if carolGroupTimeline[0].Message != aliceLines[0] || carolGroupTimeline[1].Message != bobLines[0] ||
carolGroupTimeline[2].Message != aliceLines[1] || carolGroupTimeline[3].Message != bobLines[1] ||