Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,60 @@ require (
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect
github.com/Masterminds/semver/v3 v3.5.0 // indirect
github.com/MicahParks/keyfunc v1.9.0 // indirect
github.com/PuerkitoBio/boom v0.0.0-20140219125548-fecdef1c97ca // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20260202195803-dba9d589def2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dyatlov/go-opengraph/opengraph v0.0.0-20220524092352-606d7b1e5f8a // indirect
github.com/envoyproxy/go-control-plane/envoy v1.37.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.3.3 // indirect
github.com/fatih/color v1.19.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/garyburd/redigo v1.6.4 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-yaml v1.19.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.8.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 // indirect
github.com/mattermost/ldap v0.0.0-20231116144001-0f480c025956 // indirect
github.com/mattermost/logr/v2 v2.0.22 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.2.0 // indirect
github.com/olekukonko/ts v0.0.0-20171002115256-78ecb04241c0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/rakyll/pb v0.0.0-20160123035540-8d46b8b097ef // indirect
github.com/spiffe/go-spiffe/v2 v2.6.0 // indirect
github.com/tinylib/msgp v1.6.4 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/wiggin77/merror v1.0.5 // indirect
github.com/wiggin77/srslog v1.0.1 // indirect
github.com/zeebo/errs v1.4.0 // indirect
Expand All @@ -77,6 +99,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.0 // indirect
golang.org/x/crypto v0.51.0 // indirect
golang.org/x/mod v0.36.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/text v0.37.0 // indirect
Expand All @@ -88,5 +111,6 @@ require (
google.golang.org/grpc v1.81.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
63 changes: 63 additions & 0 deletions go.sum

Large diffs are not rendered by default.

53 changes: 27 additions & 26 deletions server/android_notification_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"golang.org/x/oauth2/google"
"google.golang.org/api/option"

"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
)

Expand Down Expand Up @@ -113,25 +114,25 @@ func (me *AndroidNotificationServer) Initialize() error {
return nil
}

func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) PushResponse {
func (me *AndroidNotificationServer) SendNotification(_ int, msg *model.PushNotification) PushResponse {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appVersion not on model.PushNotification -- passed explicitly instead.

pushType := msg.Type
data := map[string]string{
"ack_id": msg.AckID,
"ack_id": msg.AckId,
"type": pushType,
"sub_type": msg.SubType,
"sub_type": string(msg.SubType),
"version": msg.Version,
"channel_id": msg.ChannelID,
"channel_id": msg.ChannelId,
"is_crt_enabled": strconv.FormatBool(msg.IsCRTEnabled),
"server_id": msg.ServerID,
"server_id": msg.ServerId,
"category": msg.Category,
}

if msg.Badge != -1 {
data["badge"] = strconv.Itoa(msg.Badge)
}

if msg.RootID != "" {
data["root_id"] = msg.RootID
if msg.RootId != "" {
data["root_id"] = msg.RootId
}

if msg.Signature == "" {
Expand All @@ -140,30 +141,30 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus
data["signature"] = msg.Signature
}

if msg.IsIDLoaded {
data["post_id"] = msg.PostID
if msg.IsIdLoaded {
data["post_id"] = msg.PostId
data["message"] = msg.Message
data["id_loaded"] = "true"
data["sender_id"] = msg.SenderID
data["sender_id"] = msg.SenderId
data["sender_name"] = "Someone"
data["team_id"] = msg.TeamID
} else if pushType == PushTypeMessage || pushType == PushTypeSession {
data["team_id"] = msg.TeamID
data["sender_id"] = msg.SenderID
data["team_id"] = msg.TeamId
} else if pushType == model.PushTypeMessage || pushType == model.PushTypeSession {
data["team_id"] = msg.TeamId
data["sender_id"] = msg.SenderId
data["sender_name"] = msg.SenderName
data["message"] = emoji.Sprint(msg.Message)
data["channel_name"] = msg.ChannelName
data["post_id"] = msg.PostID
data["post_id"] = msg.PostId
data["override_username"] = msg.OverrideUsername
data["override_icon_url"] = msg.OverrideIconURL
data["from_webhook"] = msg.FromWebhook
}

if me.metrics != nil {
me.metrics.incrementNotificationTotal(PushNotifyAndroid, pushType, PushTransportStandard)
me.metrics.incrementNotificationTotal(model.PushNotifyAndroid, pushType, model.PushTransportStandard)
}
fcmMsg := &messaging.Message{
Token: msg.DeviceID,
Token: msg.DeviceId,
Data: data,
Android: &messaging.AndroidConfig{
Priority: "high",
Expand All @@ -174,7 +175,7 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus
"Sending android push notification",
mlog.String("device", me.AndroidPushSettings.Type),
mlog.String("type", msg.Type),
mlog.String("ack_id", msg.AckID),
mlog.String("ack_id", msg.AckId),
)
err := me.SendNotificationWithRetry(fcmMsg)
if err != nil {
Expand All @@ -185,8 +186,8 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus

me.logger.Error(
"Failed to send FCM push",
mlog.String("sid", msg.ServerID),
mlog.String("did", redactToken(msg.DeviceID)),
mlog.String("sid", msg.ServerId),
mlog.String("did", redactToken(msg.DeviceId)),
mlog.Err(err),
mlog.String("type", me.AndroidPushSettings.Type),
mlog.String("errorCode", errorCode),
Expand All @@ -195,7 +196,7 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus
if messaging.IsUnregistered(err) || messaging.IsSenderIDMismatch(err) {
me.logger.Info("Android response failure sending remove code", mlog.String("type", me.AndroidPushSettings.Type))
if me.metrics != nil {
me.metrics.incrementRemoval(PushNotifyAndroid, pushType, PushTransportStandard, unregistered)
me.metrics.incrementRemoval(model.PushNotifyAndroid, pushType, model.PushTransportStandard, unregistered)
}
return NewRemovePushResponse()
}
Expand All @@ -217,17 +218,17 @@ func (me *AndroidNotificationServer) SendNotification(msg *PushNotification) Pus

}
if me.metrics != nil {
me.metrics.incrementFailure(PushNotifyAndroid, pushType, PushTransportStandard, reason)
me.metrics.incrementFailure(model.PushNotifyAndroid, pushType, model.PushTransportStandard, reason)
}

return NewErrorPushResponse(err.Error())
}

if me.metrics != nil {
if msg.AckID != "" {
me.metrics.incrementSuccessWithAck(PushNotifyAndroid, pushType, PushTransportStandard)
if msg.AckId != "" {
me.metrics.incrementSuccessWithAck(model.PushNotifyAndroid, pushType, model.PushTransportStandard)
} else {
me.metrics.incrementSuccess(PushNotifyAndroid, pushType, PushTransportStandard)
me.metrics.incrementSuccess(model.PushNotifyAndroid, pushType, model.PushTransportStandard)
}
}
return NewOkPushResponse()
Expand All @@ -251,7 +252,7 @@ func (me *AndroidNotificationServer) SendNotificationWithRetry(fcmMsg *messaging
defer cancelRetryContext()
_, err = me.client.Send(retryContext, fcmMsg)
if me.metrics != nil {
me.metrics.observerNotificationResponse(PushNotifyAndroid, time.Since(start).Seconds())
me.metrics.observerNotificationResponse(model.PushNotifyAndroid, time.Since(start).Seconds())
}

if err == nil || !isRetryable(err) {
Expand Down
Loading
Loading