mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
getui
This commit is contained in:
+23
-10
@@ -10,14 +10,29 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type JPushResp struct {
|
||||
var (
|
||||
JPushClient *JPush
|
||||
)
|
||||
|
||||
func init() {
|
||||
JPushClient = newGetuiClient()
|
||||
}
|
||||
|
||||
type JPush struct {
|
||||
type JPush struct{}
|
||||
|
||||
func newGetuiClient() *JPush {
|
||||
return &JPush{}
|
||||
}
|
||||
|
||||
func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) {
|
||||
func (j *JPush) Auth(apiKey, secretKey string, timeStamp int64) (token string, err error) {
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (j *JPush) Push(accounts []string, alert, detailContent, platform, operationID string) (string, error) {
|
||||
var pf requestBody.Platform
|
||||
_ = pf.SetPlatform(platform)
|
||||
var au requestBody.Audience
|
||||
@@ -37,25 +52,23 @@ func JGAccountListPush(accounts []string, alert, detailContent, platform string)
|
||||
|
||||
con, err := json.Marshal(po)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
req, err := http.NewRequest("POST", config.Config.Push.Jpns.PushUrl, bytes.NewBuffer(con))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", err
|
||||
}
|
||||
return result, nil
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user