This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -13,6 +15,7 @@ import (
|
||||
"forge.redroom.link/yves/meowlib/client"
|
||||
invmsgs "forge.redroom.link/yves/meowlib/client/invitation/messages"
|
||||
invsrv "forge.redroom.link/yves/meowlib/client/invitation/server"
|
||||
doubleratchet "github.com/status-im/doubleratchet"
|
||||
"github.com/google/uuid"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -154,6 +157,18 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
|
||||
}
|
||||
// Chat messages
|
||||
if len(fromServerMessage.Chat) > 0 {
|
||||
// Sort by DR chain sequence number so messages are decrypted in ratchet order,
|
||||
// regardless of server delivery order.
|
||||
sort.SliceStable(fromServerMessage.Chat, func(i, j int) bool {
|
||||
var hi, hj doubleratchet.MessageHeader
|
||||
if err := json.Unmarshal(fromServerMessage.Chat[i].DrHeader, &hi); err != nil {
|
||||
return false
|
||||
}
|
||||
if err := json.Unmarshal(fromServerMessage.Chat[j].DrHeader, &hj); err != nil {
|
||||
return false
|
||||
}
|
||||
return hi.N < hj.N
|
||||
})
|
||||
for _, packedUserMessage := range fromServerMessage.Chat {
|
||||
|
||||
// find the peer with that lookup key
|
||||
|
||||
Reference in New Issue
Block a user