style: add format

Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
This commit is contained in:
Xinwei Xiong(cubxxw-openim)
2023-07-03 16:29:22 +08:00
parent 187ee9a375
commit 166ddb1e34
170 changed files with 4816 additions and 1279 deletions
+3 -2
View File
@@ -6,12 +6,13 @@ import (
firebase "firebase.google.com/go"
"firebase.google.com/go/messaging"
"github.com/redis/go-redis/v9"
"google.golang.org/api/option"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/redis/go-redis/v9"
"google.golang.org/api/option"
)
const SinglePushCountLimit = 400
+2 -1
View File
@@ -4,9 +4,10 @@ import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/OpenIMSDK/Open-IM-Server/internal/push/offlinepush"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
"github.com/stretchr/testify/assert"
)
func Test_Push(t *testing.T) {
+11 -2
View File
@@ -99,7 +99,9 @@ func (g *Client) Push(ctx context.Context, userIDs []string, title, content stri
func (g *Client) Auth(ctx context.Context, timeStamp int64) (token string, expireTime int64, err error) {
h := sha256.New()
h.Write([]byte(config.Config.Push.GeTui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.GeTui.MasterSecret))
h.Write(
[]byte(config.Config.Push.GeTui.AppKey + strconv.Itoa(int(timeStamp)) + config.Config.Push.GeTui.MasterSecret),
)
sign := hex.EncodeToString(h.Sum(nil))
reqAuth := AuthReq{
Sign: sign,
@@ -150,7 +152,14 @@ func (g *Client) request(ctx context.Context, url string, input interface{}, tok
return g.postReturn(ctx, config.Config.Push.GeTui.PushUrl+url, header, input, resp, 3)
}
func (g *Client) postReturn(ctx context.Context, url string, header map[string]string, input interface{}, output RespI, timeout int) error {
func (g *Client) postReturn(
ctx context.Context,
url string,
header map[string]string,
input interface{},
output RespI,
timeout int,
) error {
err := http2.PostReturn(ctx, url, header, input, output, timeout)
if err != nil {
return err
+10 -1
View File
@@ -60,5 +60,14 @@ func (j *JPush) Push(ctx context.Context, userIDs []string, title, content strin
}
func (j *JPush) request(ctx context.Context, po body.PushObj, resp interface{}, timeout int) error {
return http2.PostReturn(ctx, config.Config.Push.Jpns.PushUrl, map[string]string{"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret)}, po, resp, timeout)
return http2.PostReturn(
ctx,
config.Config.Push.Jpns.PushUrl,
map[string]string{
"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret),
},
po,
resp,
timeout,
)
}