This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -13,6 +15,7 @@ import (
|
|||||||
"forge.redroom.link/yves/meowlib/client"
|
"forge.redroom.link/yves/meowlib/client"
|
||||||
invmsgs "forge.redroom.link/yves/meowlib/client/invitation/messages"
|
invmsgs "forge.redroom.link/yves/meowlib/client/invitation/messages"
|
||||||
invsrv "forge.redroom.link/yves/meowlib/client/invitation/server"
|
invsrv "forge.redroom.link/yves/meowlib/client/invitation/server"
|
||||||
|
doubleratchet "github.com/status-im/doubleratchet"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@@ -154,6 +157,18 @@ func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error
|
|||||||
}
|
}
|
||||||
// Chat messages
|
// Chat messages
|
||||||
if len(fromServerMessage.Chat) > 0 {
|
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 {
|
for _, packedUserMessage := range fromServerMessage.Chat {
|
||||||
|
|
||||||
// find the peer with that lookup key
|
// find the peer with that lookup key
|
||||||
|
|||||||
Reference in New Issue
Block a user