mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
getui
This commit is contained in:
parent
3d5e3ce6cf
commit
cbe3abeab0
@ -183,10 +183,12 @@ push:
|
||||
enable: false
|
||||
getui: #个推推送,暂未测试 暂不要使用
|
||||
pushUrl: "https://restapi.getui.com/v2/$appId"
|
||||
sign: ""
|
||||
masterSecret: ""
|
||||
appKey: ""
|
||||
enable: true
|
||||
intent: ""
|
||||
enable: true
|
||||
|
||||
|
||||
|
||||
manager:
|
||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"bytes"
|
||||
"crypto/sha512"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@ -71,7 +73,7 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, platform, operat
|
||||
log.NewError(operationID, utils.OperationIDGenerator(), "GetGetuiToken", err.Error())
|
||||
}
|
||||
if token == "" || err != nil {
|
||||
token, expireTime, err := g.Auth(config.Config.Push.Getui.AppKey, config.Config.Push.Getui.Sign, operationID, time.Now().Unix())
|
||||
token, expireTime, err := g.Auth(+operationID, time.Now().Unix())
|
||||
if err != nil {
|
||||
return "", utils.Wrap(err, "Auth failed")
|
||||
}
|
||||
@ -105,12 +107,17 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, platform, operat
|
||||
return string(respBytes), err
|
||||
}
|
||||
|
||||
func (g *Getui) Auth(appKey, sign, operationID string, timeStamp int64) (token string, expireTime int64, err error) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), appKey, sign, timeStamp)
|
||||
func (g *Getui) Auth(operationID string, timeStamp int64) (token string, expireTime int64, err error) {
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), timeStamp)
|
||||
h := sha512.New()
|
||||
h.Write([]byte(config.Config.Push.Getui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.Getui.MasterSecret))
|
||||
sum := h.Sum(nil)
|
||||
sign := hex.EncodeToString(sum)
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "sha256 result", sign)
|
||||
reqAuth := AuthReq{
|
||||
Sign: sign,
|
||||
Timestamp: strconv.Itoa(int(timeStamp)),
|
||||
Appkey: appKey,
|
||||
Appkey: config.Config.Push.Getui.AppKey,
|
||||
}
|
||||
respAuth := AuthResp{}
|
||||
err = g.request(reqAuth, "", &respAuth, operationID)
|
||||
|
@ -103,6 +103,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
||||
}
|
||||
var offlinePusher pusher.OfflinePusher
|
||||
if config.Config.Push.Getui.Enable {
|
||||
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), config.Config.Push.Getui)
|
||||
offlinePusher = getui.GetuiClient
|
||||
}
|
||||
if config.Config.Push.Jpns.Enable {
|
||||
|
@ -162,11 +162,11 @@ type config struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
}
|
||||
Getui struct {
|
||||
PushUrl string `yaml:"pushUrl"`
|
||||
Sign string `yaml:"sign"`
|
||||
AppKey string `yaml:"appkey"`
|
||||
Enable bool `yaml:"enable"`
|
||||
Intent string `yaml:"intent"`
|
||||
PushUrl string `yaml:"pushUrl"`
|
||||
AppKey string `yaml:"appkey"`
|
||||
Enable bool `yaml:"enable"`
|
||||
Intent string `yaml:"intent"`
|
||||
MasterSecret string `yaml:"masterSecret"`
|
||||
}
|
||||
}
|
||||
Manager struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user