luoyangwei 1 жил өмнө
parent
commit
7e5da73a53
4 өөрчлөгдсөн 19 нэмэгдсэн , 17 устгасан
  1. 1 1
      go.mod
  2. 2 0
      go.sum
  3. 2 1
      server/client.go
  4. 14 15
      server/message.go

+ 1 - 1
go.mod

@@ -17,7 +17,7 @@ require (
 	github.com/spf13/viper v1.18.2
 	go.uber.org/zap v1.27.0
 	gorm.io/gorm v1.25.7
-	x.sikey.com.cn/serverx v1.2.29
+	x.sikey.com.cn/serverx v1.2.32
 )
 
 // replace x.sikey.com.cn/serverx v1.2.26 => ../serverx

+ 2 - 0
go.sum

@@ -321,3 +321,5 @@ x.sikey.com.cn/serverx v1.2.28 h1:2NaXovSVsZGqe3Cofwxx9KWjVuJmFN+5skBLJWUof68=
 x.sikey.com.cn/serverx v1.2.28/go.mod h1:+jho37jloxhYP66RsEKw4Qc+bcoInP/zWP4/Xhx18GM=
 x.sikey.com.cn/serverx v1.2.29 h1:2vAFnSYvA0a21UT3j/3yhZ3LWI6WEE+MrY9WCjUT4gA=
 x.sikey.com.cn/serverx v1.2.29/go.mod h1:+jho37jloxhYP66RsEKw4Qc+bcoInP/zWP4/Xhx18GM=
+x.sikey.com.cn/serverx v1.2.32 h1:bqvD46TF19GY2FnO5IRdVLsF8fjAtuWC72Uai/Xp004=
+x.sikey.com.cn/serverx v1.2.32/go.mod h1:+jho37jloxhYP66RsEKw4Qc+bcoInP/zWP4/Xhx18GM=

+ 2 - 1
server/client.go

@@ -174,6 +174,8 @@ func (c *Client) Processing(bytes []byte) {
 	case MessageTypeUpChating:
 		// Chat dialogue messages
 		if chatingContent, ok := message.Content.(ChatingContent); ok {
+			// if chatingContent.SessionId == "" {
+			// }
 			chatingContent.MessageId = message.MessageId
 			c.procChating(ctx, message.Type, chatingContent)
 		}
@@ -324,7 +326,6 @@ func (c *Client) procNotify(ctx context.Context, notificationContent Notificatio
 // procChating received message processing
 func (c *Client) procChating(ctx context.Context, msgType MessageType, chatingContent ChatingContent) {
 	requestId := ctx.Value("request_id").(string)
-	chatingContent.SessionId = chatingContent.Receiver
 
 	// Receiver ID format determines whether the receiver is an account or a session
 	users := c.regexpReceiveUserIds(chatingContent.Receiver)

+ 14 - 15
server/message.go

@@ -60,18 +60,17 @@ type FirebaseMessage struct {
 type (
 	// ChatingContent to client chating message
 	ChatingContent struct {
-		MessageId   string             `json:"messageId"`
-		SessionId   string             `json:"sessionId"`
-		Receiver    string             `json:"receiver"`
-		PayloadType ChatingContentType `json:"payloadType"`
-		Payload     any                `json:"payload"`
-		SendTime    int64              `json:"sendTime"`
+		MessageId   string             `json:"messageId" mapstructure:"messageId"`
+		Receiver    string             `json:"receiver" mapstructure:"receiver"`
+		PayloadType ChatingContentType `json:"payloadType" mapstructure:"payloadType"`
+		Payload     any                `json:"payload" mapstructure:"payload"`
+		SendTime    int64              `json:"sendTime" mapstructure:"sendTime"`
 	}
 
 	// NotificationContent to client notice message
 	NotificationContent struct {
-		ID      int                    `json:"id"`
-		Payload map[string]interface{} `json:"payload"`
+		ID      int                    `json:"id" mapstructure:"id"`
+		Payload map[string]interface{} `json:"payload" mapstructure:"payload"`
 	}
 
 	LocationMessageContent struct {
@@ -84,31 +83,31 @@ type (
 	}
 
 	VideoCallMessageContent struct {
-		AccountId string `json:"accountId"` // AccountId 账号ID
+		AccountId string `json:"accountId" mapstructure:"accountId"` // AccountId 账号ID
 	}
 )
 
 type (
 	// ContentText received a text message from the client
 	ContentText struct {
-		Raw string `json:"raw"`
+		Raw string `json:"raw" mapstructure:"raw"`
 	}
 
 	// ContentMetadata received media file message from client
 	ContentMetadata struct {
-		Url      string `json:"url"`      // Url 文件地址
-		FileType string `json:"fileType"` // FileType 文件类型
-		Duration uint   `json:"duration"` // Duration 视频/语音时长
+		Url      string `json:"url" mapstructure:""`      // Url 文件地址
+		FileType string `json:"fileType" mapstructure:""` // FileType 文件类型
+		Duration uint   `json:"duration" mapstructure:""` // Duration 视频/语音时长
 	}
 
 	// ContentReply content to be replied to after receiving the message
 	ContentReply struct {
-		MessageId string `json:"messageId"`
+		MessageId string `json:"messageId" mapstructure:"messageId"`
 	}
 
 	// ContentError an error occurred while processing the message
 	ContentError struct {
-		Err string `json:"err"`
+		Err string `json:"err" mapstructure:"err"`
 	}
 )