2023-08-18 11:39:59 +00:00
|
|
|
//nolint
|
|
|
|
// Code generated by generate_handlers.go. DO NOT EDIT.
|
|
|
|
// source: geneate_handlers.go
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/protocol/common"
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
"github.com/status-im/status-go/protocol/transport"
|
|
|
|
v1protocol "github.com/status-im/status-go/protocol/v1"
|
|
|
|
)
|
|
|
|
|
2023-09-07 10:33:20 +00:00
|
|
|
func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter, fromArchive bool) error {
|
2023-08-18 11:39:59 +00:00
|
|
|
switch msg.Type {
|
|
|
|
{{ range .}}
|
|
|
|
case protobuf.ApplicationMetadataMessage_{{.EnumValue}}:
|
2023-09-07 10:33:20 +00:00
|
|
|
return m.{{.MethodName}}(messageState, protoBytes, msg, filter{{ if .FromArchiveArg }}, fromArchive{{ end }})
|
2023-08-18 11:39:59 +00:00
|
|
|
{{ end }}
|
|
|
|
default:
|
|
|
|
m.logger.Info("protobuf type not found", zap.String("type", string(msg.Type)))
|
|
|
|
return errors.New("protobuf type not found")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
{{ range . }}
|
2023-09-07 10:33:20 +00:00
|
|
|
func (m *Messenger) {{.MethodName}}(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter{{ if .FromArchiveArg }}, fromArchive bool{{ end }}) error {
|
2023-08-18 11:39:59 +00:00
|
|
|
m.logger.Info("handling {{ .ProtobufName}}")
|
|
|
|
{{ if .SyncMessage }}
|
|
|
|
if !common.IsPubKeyEqual(messageState.CurrentMessageState.PublicKey, &m.identity.PublicKey) {
|
|
|
|
m.logger.Warn("not coming from us, ignoring")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ if .ProcessRaw }}
|
|
|
|
return m.Handle{{.ProtobufName}}(messageState, protoBytes, msg)
|
|
|
|
{{ else }}
|
|
|
|
p := &protobuf.{{.ProtobufName}}{}
|
|
|
|
err := proto.Unmarshal(protoBytes, p)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-08-28 03:48:10 +00:00
|
|
|
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p)
|
2023-08-18 11:39:59 +00:00
|
|
|
|
2023-09-07 10:33:20 +00:00
|
|
|
return m.Handle{{.ProtobufName}}(messageState, p, msg{{ if .FromArchiveArg }}, fromArchive {{ end }})
|
2023-08-18 11:39:59 +00:00
|
|
|
{{ end }}
|
|
|
|
}
|
|
|
|
|
|
|
|
{{ end }}
|