2023-08-18 11:39:59 +00:00
|
|
|
//nolint
|
|
|
|
// Code generated by generate_handlers.go. DO NOT EDIT.
|
2023-11-08 18:05:33 +00:00
|
|
|
// source: generate_handlers.go
|
2023-08-18 11:39:59 +00:00
|
|
|
|
|
|
|
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-11-08 18:05:33 +00:00
|
|
|
switch msg.ApplicationLayer.Type {
|
2023-08-18 11:39:59 +00:00
|
|
|
{{ range .}}
|
|
|
|
case protobuf.ApplicationMetadataMessage_{{.EnumValue}}:
|
2023-09-07 10:33:20 +00:00
|
|
|
return m.{{.MethodName}}(messageState, protoBytes, msg, filter{{ if .FromArchiveArg }}, fromArchive{{ end }})
|
2024-09-23 13:12:02 +00:00
|
|
|
{{ end }}
|
2023-08-18 11:39:59 +00:00
|
|
|
}
|
2024-09-23 13:12:02 +00:00
|
|
|
m.logger.Info("protobuf type not found", zap.String("type", string(msg.ApplicationLayer.Type)))
|
|
|
|
return errors.New("protobuf type not found")
|
2023-08-18 11:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{{ 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-11-08 18:05:33 +00:00
|
|
|
m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.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 }}
|