shuffle servers and limit & filter by chat id
This commit is contained in:
parent
401d18e558
commit
d7222c89e0
|
@ -618,6 +618,10 @@ func NewNodeConfigWithDefaults(dataDir string, networkID uint64, opts ...Option)
|
|||
}
|
||||
|
||||
func (c *NodeConfig) setDefaultPushNotificationsServers() error {
|
||||
if c.ClusterConfig.Fleet == FleetUndefined {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If empty load defaults from the fleet
|
||||
if len(c.ClusterConfig.PushNotificationsServers) == 0 {
|
||||
log.Debug("empty push notification servers, setting", "fleet", c.ClusterConfig.Fleet)
|
||||
|
|
|
@ -545,7 +545,7 @@ func (m *PushNotificationQueryResponse) GetSuccess() bool {
|
|||
|
||||
type PushNotification struct {
|
||||
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
|
||||
ChatId string `protobuf:"bytes,2,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
|
||||
ChatId []byte `protobuf:"bytes,2,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
|
||||
PublicKey []byte `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
|
||||
InstallationId string `protobuf:"bytes,4,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
|
||||
Message []byte `protobuf:"bytes,5,opt,name=message,proto3" json:"message,omitempty"`
|
||||
|
@ -587,11 +587,11 @@ func (m *PushNotification) GetAccessToken() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (m *PushNotification) GetChatId() string {
|
||||
func (m *PushNotification) GetChatId() []byte {
|
||||
if m != nil {
|
||||
return m.ChatId
|
||||
}
|
||||
return ""
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PushNotification) GetPublicKey() []byte {
|
||||
|
@ -800,64 +800,64 @@ func init() { proto.RegisterFile("push_notifications.proto", fileDescriptor_200a
|
|||
|
||||
var fileDescriptor_200acd86044eaa5d = []byte{
|
||||
// 952 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x6e, 0xe3, 0x44,
|
||||
0x14, 0xc6, 0x4e, 0xda, 0x24, 0x27, 0x21, 0x75, 0x47, 0x6d, 0xd7, 0x2c, 0x74, 0x09, 0x06, 0x89,
|
||||
0xa8, 0x17, 0x01, 0x15, 0x89, 0x5d, 0x71, 0x45, 0x48, 0x9d, 0xae, 0xd5, 0xc6, 0x0e, 0x13, 0x97,
|
||||
0xd5, 0x4a, 0x48, 0x96, 0x63, 0x4f, 0x5a, 0xab, 0xae, 0xc7, 0x78, 0x26, 0x45, 0xb9, 0xe3, 0x01,
|
||||
0xb8, 0xe1, 0x96, 0xc7, 0xe0, 0x9a, 0x37, 0xe0, 0xa5, 0x90, 0xc7, 0x76, 0x9a, 0x36, 0x6e, 0x5a,
|
||||
0x24, 0xae, 0x92, 0xf3, 0x9d, 0x9f, 0x99, 0x39, 0xdf, 0xf9, 0x8e, 0x41, 0x8d, 0xe7, 0xec, 0xca,
|
||||
0x89, 0x28, 0x0f, 0x66, 0x81, 0xe7, 0xf2, 0x80, 0x46, 0xac, 0x17, 0x27, 0x94, 0x53, 0x54, 0x17,
|
||||
0x3f, 0xd3, 0xf9, 0x4c, 0xfb, 0xbb, 0x0a, 0x9f, 0x8c, 0xe7, 0xec, 0xca, 0x5c, 0x89, 0xc2, 0xe4,
|
||||
0x32, 0x60, 0x3c, 0x11, 0xff, 0x91, 0x05, 0xc0, 0xe9, 0x35, 0x89, 0x1c, 0xbe, 0x88, 0x89, 0x2a,
|
||||
0x75, 0xa4, 0x6e, 0xfb, 0xf8, 0xeb, 0x5e, 0x91, 0xdf, 0xdb, 0x94, 0xdb, 0xb3, 0xd3, 0x44, 0x7b,
|
||||
0x11, 0x13, 0xdc, 0xe0, 0xc5, 0x5f, 0xf4, 0x19, 0xb4, 0x7c, 0x72, 0x1b, 0x78, 0xc4, 0x11, 0x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0x2f, 0xfc,
|
||||
0xc3, 0x84, 0xde, 0x0c, 0x72, 0xaf, 0x15, 0x85, 0x0b, 0xf4, 0x31, 0x34, 0xdc, 0x38, 0x72, 0x38,
|
||||
0x8d, 0x03, 0x4f, 0x6d, 0x89, 0xc6, 0xd4, 0xdd, 0x38, 0xb2, 0x53, 0x5b, 0x1b, 0x42, 0x63, 0x49,
|
||||
0x0e, 0x3a, 0x00, 0x74, 0x61, 0x9e, 0x99, 0xd6, 0x3b, 0xd3, 0xb1, 0xad, 0x33, 0xdd, 0x74, 0xec,
|
||||
0xf7, 0x63, 0x5d, 0xf9, 0x00, 0x7d, 0x08, 0x8d, 0xfe, 0x38, 0xc7, 0x14, 0x09, 0x21, 0x68, 0x0f,
|
||||
0x0d, 0xac, 0xff, 0xd0, 0x9f, 0xe8, 0x39, 0x26, 0x6b, 0x7f, 0xc9, 0xf0, 0xc5, 0xa6, 0x11, 0xc0,
|
||||
0x84, 0xc5, 0x34, 0x62, 0x24, 0x6d, 0x36, 0x9b, 0x0b, 0x5a, 0xc4, 0x0c, 0xd5, 0x71, 0x61, 0x22,
|
||||
0x13, 0xb6, 0x48, 0x92, 0xd0, 0x44, 0x0c, 0x42, 0xfb, 0xf8, 0xcd, 0xf3, 0x66, 0xab, 0x28, 0xdc,
|
||||
0xd3, 0xd3, 0x5c, 0x31, 0x63, 0x59, 0x19, 0x74, 0x08, 0x90, 0x90, 0x5f, 0xe6, 0x84, 0xf1, 0x62,
|
||||
0x6e, 0x5a, 0xb8, 0x91, 0x23, 0x86, 0xaf, 0xfd, 0x26, 0x41, 0x63, 0x99, 0xb3, 0xfa, 0x74, 0x1d,
|
||||
0x63, 0x0b, 0x17, 0x4f, 0xdf, 0x87, 0xdd, 0x51, 0xff, 0x7c, 0x68, 0xe1, 0x91, 0x7e, 0xe2, 0x8c,
|
||||
0xf4, 0xc9, 0xa4, 0x7f, 0xaa, 0x2b, 0x12, 0xda, 0x03, 0xe5, 0x27, 0x1d, 0x4f, 0x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 0x3f, 0x67, 0xa9, 0xee, 0x40,
|
||||
0xf3, 0x1d, 0xb6, 0xcc, 0xd3, 0xd5, 0x2f, 0xca, 0x83, 0xe5, 0x28, 0xa7, 0x98, 0x69, 0xd9, 0x0e,
|
||||
0xd6, 0x4f, 0x8d, 0x89, 0xad, 0x63, 0xfd, 0x44, 0xa9, 0xa4, 0x0b, 0x73, 0xfd, 0x41, 0xb9, 0xd4,
|
||||
0xee, 0xf7, 0x55, 0x7a, 0xa8, 0x98, 0xef, 0xa0, 0x96, 0x88, 0xb7, 0x33, 0x55, 0x16, 0x6c, 0x75,
|
||||
0x9e, 0x6a, 0x12, 0x2e, 0x12, 0xa6, 0xdb, 0x22, 0xf2, 0x9b, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff,
|
||||
0xc6, 0x95, 0x5d, 0x48, 0x48, 0x09, 0x00, 0x00,
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x51, 0x6f, 0xe3, 0x44,
|
||||
0x10, 0xc6, 0x4e, 0xda, 0x24, 0x93, 0x90, 0xba, 0xab, 0xb6, 0x67, 0x0e, 0x7a, 0x04, 0x83, 0x44,
|
||||
0xd4, 0x87, 0x80, 0x8a, 0xc4, 0x9d, 0x78, 0x22, 0xa4, 0x4e, 0xcf, 0x6a, 0x63, 0x87, 0x8d, 0xcb,
|
||||
0xe9, 0x24, 0x24, 0xcb, 0xb1, 0x37, 0xad, 0x55, 0xd7, 0x6b, 0xbc, 0x9b, 0xa2, 0xbc, 0xf1, 0x03,
|
||||
0x78, 0xe1, 0x95, 0x9f, 0xc1, 0x33, 0xff, 0x80, 0x3f, 0x85, 0xbc, 0xb6, 0xd3, 0xb4, 0x71, 0xd3,
|
||||
0x22, 0xf1, 0x94, 0xcc, 0x37, 0x3b, 0x33, 0xbb, 0xf3, 0xcd, 0x37, 0x06, 0x35, 0x9e, 0xb3, 0x2b,
|
||||
0x27, 0xa2, 0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
0xc8, 0xe2, 0x3c, 0x60, 0x1c, 0x1d, 0xc1, 0xee, 0x34, 0xa4, 0xde, 0x35, 0xf1, 0x1d, 0xef, 0xca,
|
||||
0xe5, 0xd9, 0xd1, 0xba, 0x38, 0xba, 0x93, 0x3b, 0x06, 0x57, 0x2e, 0x17, 0x67, 0x5f, 0x01, 0xcc,
|
||||
0xa3, 0x44, 0xf4, 0x87, 0x24, 0x6a, 0x43, 0x5c, 0x66, 0x05, 0x41, 0x7b, 0xb0, 0x75, 0x99, 0xb8,
|
||||
0x11, 0x57, 0xa1, 0x23, 0x75, 0x5b, 0x38, 0x33, 0xd0, 0x6b, 0x50, 0x45, 0x4d, 0x67, 0x96, 0xd0,
|
||||
0x1b, 0xc7, 0xa3, 0x11, 0x77, 0x3d, 0xce, 0x1c, 0x1a, 0x85, 0x0b, 0xb5, 0x29, 0x72, 0xec, 0x0b,
|
||||
0xff, 0x30, 0xa1, 0x37, 0x83, 0xdc, 0x6b, 0x45, 0xe1, 0x02, 0x7d, 0x0c, 0x0d, 0x37, 0x8e, 0x1c,
|
||||
0x4e, 0xe3, 0xc0, 0x53, 0x5b, 0xa2, 0x31, 0x75, 0x37, 0x8e, 0xec, 0xd4, 0xd6, 0x86, 0xd0, 0x58,
|
||||
0x92, 0x83, 0x0e, 0x00, 0x5d, 0x98, 0x67, 0xa6, 0xf5, 0xce, 0x74, 0x6c, 0xeb, 0x4c, 0x37, 0x1d,
|
||||
0xfb, 0xfd, 0x58, 0x57, 0x3e, 0x40, 0x1f, 0x42, 0xa3, 0x3f, 0xce, 0x31, 0x45, 0x42, 0x08, 0xda,
|
||||
0x43, 0x03, 0xeb, 0x3f, 0xf4, 0x27, 0x7a, 0x8e, 0xc9, 0xda, 0x5f, 0x32, 0x7c, 0xb1, 0x69, 0x04,
|
||||
0x30, 0x61, 0x31, 0x8d, 0x18, 0x49, 0x9b, 0xcd, 0xe6, 0x82, 0x16, 0x31, 0x43, 0x75, 0x5c, 0x98,
|
||||
0xc8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 0xf2, 0xd6,
|
||||
0x31, 0x2d, 0xdb, 0x18, 0x1a, 0x83, 0xbe, 0x9d, 0x6a, 0x37, 0x17, 0x79, 0x13, 0x6a, 0x77, 0xd2,
|
||||
0x16, 0x86, 0x99, 0xba, 0x15, 0x59, 0x8b, 0xe1, 0xc5, 0xfa, 0xf2, 0x11, 0x1b, 0x04, 0x7d, 0x0b,
|
||||
0xf5, 0x7c, 0x99, 0xb0, 0x9c, 0xde, 0x97, 0x1b, 0x36, 0xd6, 0xf2, 0xec, 0x13, 0xcc, 0x6a, 0x7f,
|
||||
0xca, 0x70, 0xb0, 0x5e, 0x32, 0xa6, 0x09, 0xdf, 0xb0, 0x3a, 0xbf, 0xbf, 0xbf, 0x3a, 0x8f, 0x36,
|
||||
0xad, 0xce, 0x34, 0x55, 0xe9, 0xb2, 0xfc, 0x3f, 0x58, 0xd6, 0x7e, 0x7e, 0xce, 0x52, 0xdd, 0x81,
|
||||
0xe6, 0x3b, 0x6c, 0x99, 0xa7, 0xab, 0x5f, 0x94, 0x07, 0xcb, 0x51, 0x4e, 0x31, 0xd3, 0xb2, 0x1d,
|
||||
0xac, 0x9f, 0x1a, 0x13, 0x5b, 0xc7, 0xfa, 0x89, 0x52, 0x49, 0x17, 0xe6, 0xfa, 0x83, 0x72, 0xa9,
|
||||
0xdd, 0xef, 0xab, 0xf4, 0x50, 0x31, 0xdf, 0x41, 0x2d, 0x11, 0x6f, 0x67, 0xaa, 0x2c, 0xd8, 0xea,
|
||||
0x3c, 0xd5, 0x24, 0x5c, 0x04, 0x4c, 0xb7, 0xc5, 0xc9, 0x6f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff,
|
||||
0xff, 0x42, 0x7f, 0xee, 0x48, 0x09, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ message PushNotificationQueryResponse {
|
|||
|
||||
message PushNotification {
|
||||
string access_token = 1;
|
||||
string chat_id = 2;
|
||||
bytes chat_id = 2;
|
||||
bytes public_key = 3;
|
||||
string installation_id = 4;
|
||||
bytes message = 5;
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"errors"
|
||||
"io"
|
||||
"math"
|
||||
"sort"
|
||||
mrand "math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
@ -60,6 +60,9 @@ const pushNotificationBackoffTime int64 = 2
|
|||
// RegistrationBackoffTime is the step of the exponential backoff
|
||||
const RegistrationBackoffTime int64 = 15
|
||||
|
||||
// defaultPushNotificationsServerCount is how many push notification servers we should register with if none is selected
|
||||
const defaultPushNotificationsServersCount = 3
|
||||
|
||||
type ServerType int
|
||||
|
||||
const (
|
||||
|
@ -301,6 +304,23 @@ func (c *Client) Reregister(contactIDs []*ecdsa.PublicKey, mutedChatIDs []string
|
|||
return c.Register(c.deviceToken, c.apnTopic, c.tokenType, contactIDs, mutedChatIDs)
|
||||
}
|
||||
|
||||
// pickDefaultServesr picks n servers at random
|
||||
func (c *Client) pickDefaultServers(servers []*ecdsa.PublicKey) []*ecdsa.PublicKey {
|
||||
// shuffle and pick n at random
|
||||
shuffledServers := make([]*ecdsa.PublicKey, len(servers))
|
||||
copy(shuffledServers, c.config.DefaultServers)
|
||||
mrand.Shuffle(len(shuffledServers), func(i, j int) {
|
||||
shuffledServers[i], shuffledServers[j] = shuffledServers[j], shuffledServers[i]
|
||||
})
|
||||
// Take the min not to get an out of bounds slice
|
||||
min := len(c.config.DefaultServers)
|
||||
if min > defaultPushNotificationsServersCount {
|
||||
min = defaultPushNotificationsServersCount
|
||||
}
|
||||
|
||||
return shuffledServers[:min]
|
||||
}
|
||||
|
||||
// Register registers with all the servers
|
||||
func (c *Client) Register(deviceToken, apnTopic string, tokenType protobuf.PushNotificationRegistration_TokenType, contactIDs []*ecdsa.PublicKey, mutedChatIDs []string) error {
|
||||
// stop registration loop
|
||||
|
@ -313,9 +333,9 @@ func (c *Client) Register(deviceToken, apnTopic string, tokenType protobuf.PushN
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(currentServers) == 0 {
|
||||
if len(currentServers) == 0 && len(c.config.DefaultServers) != 0 {
|
||||
c.config.Logger.Debug("servers empty, checking default servers")
|
||||
for _, s := range c.config.DefaultServers {
|
||||
for _, s := range c.pickDefaultServers(c.config.DefaultServers) {
|
||||
err = c.AddPushNotificationsServer(s, ServerTypeDefault)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1117,9 +1137,12 @@ func (c *Client) sendNotification(publicKey *ecdsa.PublicKey, installationIDs []
|
|||
// we should also retry if no response at all is received after a timeout.
|
||||
// also we send a single notification for multiple message ids, need to check with UI what's the desired behavior
|
||||
|
||||
// sort by server so we tend to hit the same one
|
||||
sort.Slice(info, func(i, j int) bool {
|
||||
return info[i].ServerPublicKey.X.Cmp(info[j].ServerPublicKey.X) <= 0
|
||||
// shuffle so we don't hit the same servers all the times
|
||||
// NOTE: here's is a tradeoff, ideally we want to randomly pick a server,
|
||||
// but hit the same servers for batched notifications, for now naively
|
||||
// hit a random server
|
||||
mrand.Shuffle(len(info), func(i, j int) {
|
||||
info[i], info[j] = info[j], info[i]
|
||||
})
|
||||
|
||||
installationIDsMap := make(map[string]bool)
|
||||
|
@ -1152,9 +1175,12 @@ func (c *Client) sendNotification(publicKey *ecdsa.PublicKey, installationIDs []
|
|||
for _, infos := range actionableInfos {
|
||||
var pushNotifications []*protobuf.PushNotification
|
||||
for _, i := range infos {
|
||||
// TODO: Add ChatID, message, public_key
|
||||
// TODO: Add group chat ChatID
|
||||
pushNotifications = append(pushNotifications, &protobuf.PushNotification{
|
||||
Type: protobuf.PushNotification_MESSAGE,
|
||||
Type: protobuf.PushNotification_MESSAGE,
|
||||
// For now we set the ChatID to our own identity key, this will work fine for blocked users
|
||||
// and muted 1-to-1 chats, but not for group chats.
|
||||
ChatId: common.Shake256([]byte(types.EncodeHex(crypto.FromECDSAPub(&c.config.Identity.PublicKey)))),
|
||||
AccessToken: i.AccessToken,
|
||||
PublicKey: common.HashPublicKey(publicKey),
|
||||
InstallationId: i.InstallationID,
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
||||
|
@ -60,7 +61,7 @@ func PushNotificationRegistrationToGoRushRequest(requestAndRegistrations []*Requ
|
|||
Topic: registration.ApnTopic,
|
||||
Data: &GoRushRequestData{
|
||||
EncryptedMessage: hex.EncodeToString(request.Message),
|
||||
ChatID: request.ChatId,
|
||||
ChatID: types.EncodeHex(request.ChatId),
|
||||
PublicKey: hex.EncodeToString(request.PublicKey),
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pushnotificationserver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"encoding/hex"
|
||||
|
@ -137,7 +138,7 @@ func (s *Server) HandlePushNotificationQuery(publicKey *ecdsa.PublicKey, message
|
|||
// HandlePushNotificationRequest will send a gorush notification and send a response back to the user
|
||||
func (s *Server) HandlePushNotificationRequest(publicKey *ecdsa.PublicKey,
|
||||
request protobuf.PushNotificationRequest) error {
|
||||
s.config.Logger.Debug("handling pn request")
|
||||
s.config.Logger.Info("handling pn request")
|
||||
response := s.buildPushNotificationRequestResponseAndSendNotification(&request)
|
||||
if response == nil {
|
||||
return nil
|
||||
|
@ -284,7 +285,7 @@ func (s *Server) validateRegistration(publicKey *ecdsa.PublicKey, payload []byte
|
|||
// buildPushNotificationQueryResponse check if we have the client information and send them back
|
||||
func (s *Server) buildPushNotificationQueryResponse(query *protobuf.PushNotificationQuery) *protobuf.PushNotificationQueryResponse {
|
||||
|
||||
s.config.Logger.Debug("handling push notification query")
|
||||
s.config.Logger.Info("handling push notification query")
|
||||
response := &protobuf.PushNotificationQueryResponse{}
|
||||
if query == nil || len(query.PublicKeys) == 0 {
|
||||
return response
|
||||
|
@ -320,6 +321,15 @@ func (s *Server) buildPushNotificationQueryResponse(query *protobuf.PushNotifica
|
|||
return response
|
||||
}
|
||||
|
||||
func (s *Server) blockedChatID(blockedChatIDs [][]byte, chatID []byte) bool {
|
||||
for _, blockedChatID := range blockedChatIDs {
|
||||
if bytes.Equal(blockedChatID, chatID) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// buildPushNotificationRequestResponseAndSendNotification will build a response
|
||||
// and fire-and-forget send a query to the gorush instance
|
||||
func (s *Server) buildPushNotificationRequestResponseAndSendNotification(request *protobuf.PushNotificationRequest) *protobuf.PushNotificationResponse {
|
||||
|
@ -332,7 +342,6 @@ func (s *Server) buildPushNotificationRequestResponseAndSendNotification(request
|
|||
|
||||
response.MessageId = request.MessageId
|
||||
|
||||
// TODO: filter by chat id
|
||||
// collect successful requests & registrations
|
||||
var requestAndRegistrations []*RequestAndRegistration
|
||||
|
||||
|
@ -356,6 +365,9 @@ func (s *Server) buildPushNotificationRequestResponseAndSendNotification(request
|
|||
report.Error = protobuf.PushNotificationReport_NOT_REGISTERED
|
||||
} else if registration.AccessToken != pn.AccessToken {
|
||||
report.Error = protobuf.PushNotificationReport_WRONG_TOKEN
|
||||
} else if s.blockedChatID(registration.BlockedChatList, pn.ChatId) {
|
||||
// We report as successful but don't send the notification
|
||||
report.Success = true
|
||||
} else {
|
||||
// For now we just assume that the notification will be successful
|
||||
requestAndRegistrations = append(requestAndRegistrations, &RequestAndRegistration{
|
||||
|
@ -368,7 +380,7 @@ func (s *Server) buildPushNotificationRequestResponseAndSendNotification(request
|
|||
response.Reports = append(response.Reports, report)
|
||||
}
|
||||
|
||||
s.config.Logger.Debug("built pn request")
|
||||
s.config.Logger.Info("built pn request")
|
||||
if len(requestAndRegistrations) == 0 {
|
||||
s.config.Logger.Warn("no request and registration")
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue