mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
465afd0131
Additionally to allow this process flow I refactored RawMessagePayloadReceiver and InstallationPayloadHandler to use a dedicated Marshaller type. Also added a fix to struct extention functionality, we want to ignore the process if there is no public key because that will key encoding. Seems an unnecessary bug to have to handle when you know there is no key.
34 lines
905 B
Go
34 lines
905 B
Go
package pairing
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
"github.com/status-im/status-go/protocol/common"
|
|
)
|
|
|
|
type RawMessageCollector struct {
|
|
rawMessages []*common.RawMessage
|
|
}
|
|
|
|
func (r *RawMessageCollector) dispatchMessage(_ context.Context, rawMessage common.RawMessage) (common.RawMessage, error) {
|
|
r.rawMessages = append(r.rawMessages, &rawMessage)
|
|
return rawMessage, nil
|
|
}
|
|
|
|
func (r *RawMessageCollector) getRawMessages() []*common.RawMessage {
|
|
return r.rawMessages
|
|
}
|
|
|
|
func (r *RawMessageCollector) convertToSyncRawMessage() *protobuf.SyncRawMessage {
|
|
syncRawMessage := new(protobuf.SyncRawMessage)
|
|
for _, m := range r.getRawMessages() {
|
|
rawMessage := new(protobuf.RawMessage)
|
|
rawMessage.Payload = m.Payload
|
|
rawMessage.MessageType = m.MessageType
|
|
syncRawMessage.RawMessages = append(syncRawMessage.RawMessages, rawMessage)
|
|
}
|
|
return syncRawMessage
|
|
}
|