|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package service
-
- import (
- jg_push "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/hdl"
- md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/md"
- "fmt"
- svc "gim/internal/business/comm/service"
- md3 "gim/internal/logic/domain/message/md"
- "gim/pkg/logger"
- "go.uber.org/zap"
-
- "strings"
- )
-
- func getChangeContent(args md3.PushParams, Content string) string {
- Content = strings.Replace(Content, "[MasterId]", args.MasterId, -1)
- Content = strings.Replace(Content, "[消息发送者-会员昵称]", args.SendUserNickname, -1)
- Content = strings.Replace(Content, "[消息发送者-会员头像]", args.SendUserAvatarUrl, -1)
- Content = strings.Replace(Content, "[消息类型]", args.MessageType, -1)
- Content = strings.Replace(Content, "[备注]", args.Memo, -1)
- Content = strings.Replace(Content, "[时间]", args.Times, -1)
- return Content
- }
-
- // CommAddPush 公共处理推送数据
- func CommAddPush(args md3.PushParams) {
- logger.Logger.Debug("CommAddPush",
- zap.String("master_id", args.MasterId),
- zap.String("uid", args.Uid),
- zap.String("push_alia", args.PushAlia),
- zap.String("title", args.Title),
- zap.String("content", args.Content),
- zap.String("push_type", args.PushType),
- zap.String("message_type", args.MessageType),
- zap.String("send_user_nickname", args.SendUserNickname),
- zap.String("send_user_avatar_url", args.SendUserAvatarUrl),
- zap.String("reason", args.Memo),
- zap.String("times", args.Times),
- )
- pushPlatform := svc.SysCfgGet(args.MasterId, "app_push_platform")
- if pushPlatform == "JgPush" { //极光
- args.Content = getChangeContent(args, args.Content)
- JgPush(args)
- return
- }
- return
- }
-
- func JgPush(args md3.PushParams) {
- jgPushAppKey := svc.SysCfgGet(args.MasterId, "jg_push_app_key")
- jgPushAppSecret := svc.SysCfgGet(args.MasterId, "jg_push_app_secret")
- fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_key<<<<<<<<<<<<<<<<<<<<<<", jgPushAppKey)
- fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_secret<<<<<<<<<<<<<<<<<<<<<<", jgPushAppSecret)
- if jgPushAppKey == "" || jgPushAppSecret == "" {
- return
- }
- //alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
- var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
- var extras = map[string]interface{}{
- "master_id": args.MasterId,
- "uid": args.Uid,
- "push_type": args.PushType,
- "message_type": args.MessageType,
- "send_user_nickname": args.SendUserNickname,
- "send_user_avatar_url": args.SendUserAvatarUrl,
- "memo": args.Memo,
- "times": args.Times,
- }
- var intent = map[string]interface{}{
- "url": "#Intent;action=android.intent.action.MAIN;end",
- }
- var param = md2.PushParam{
- Platform: "all",
- Audience: aud,
- Title: args.Title,
- Content: args.Content,
- Extras: extras,
- Intent: intent,
- }
- send, res, err := jg_push.Send(jgPushAppKey, jgPushAppSecret, param)
- logger.Logger.Debug("JgPush_log",
- zap.String("send", send),
- zap.String("res", res),
- zap.String("push_alia", args.PushAlia),
- zap.String("title", param.Title),
- zap.String("content", param.Content),
- zap.String("jg_push_app_key", jgPushAppKey),
- zap.String("jg_push_app_secret", jgPushAppSecret),
- )
- if err != nil {
- fmt.Println("send_error::::", err)
- return
- }
- if send == "" {
- return
- }
- //TODO::发送成功处理
- return
- }
|