refactor: refactor the code of push and optimization.

This commit is contained in:
Gordon
2024-01-21 20:47:07 +08:00
parent c7067bc48a
commit 9660556f35
17 changed files with 610 additions and 738 deletions
+12
View File
@@ -16,6 +16,7 @@ package push
import (
"context"
"encoding/json"
"github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/protocol/sdkws"
@@ -136,3 +137,14 @@ func callbackBeforeSuperGroupOnlinePush(
}
return nil
}
func GetContent(msg *sdkws.MsgData) string {
if msg.ContentType >= constant.NotificationBegin && msg.ContentType <= constant.NotificationEnd {
var notification sdkws.NotificationElem
if err := json.Unmarshal(msg.Content, &notification); err != nil {
return ""
}
return notification.Detail
} else {
return string(msg.Content)
}
}