You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

109 lines
3.4 KiB

  1. package service
  2. import (
  3. jg_push "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/hdl"
  4. md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git/md"
  5. svc "egg-im/internal/business/comm/service"
  6. "egg-im/internal/business/comm/utils"
  7. md3 "egg-im/internal/logic/domain/message/md"
  8. "egg-im/pkg/logger"
  9. "fmt"
  10. "go.uber.org/zap"
  11. "strings"
  12. )
  13. func getChangeContent(args md3.PushParams, Content string) string {
  14. Content = strings.Replace(Content, "[消息发送者-会员昵称]", args.SendUserNickname, -1)
  15. Content = strings.Replace(Content, "[消息发送者-会员头像]", args.SendUserAvatarUrl, -1)
  16. //Content = strings.Replace(Content, "[消息类型]", args.MessageType, -1)
  17. //Content = strings.Replace(Content, "[备注]", args.Memo, -1)
  18. Content = strings.Replace(Content, "[时间]", args.Times, -1)
  19. return Content
  20. }
  21. // CommAddPush 公共处理推送数据
  22. func CommAddPush(args md3.PushParams) {
  23. logger.Logger.Debug("CommAddPush",
  24. zap.String("uid", args.Uid),
  25. zap.String("push_alia", args.PushAlia),
  26. zap.String("title", args.Title),
  27. zap.String("content", args.Content),
  28. zap.String("push_type", args.PushType),
  29. zap.String("message_type", args.MessageType),
  30. zap.String("send_user_nickname", args.SendUserNickname),
  31. zap.String("send_user_avatar_url", args.SendUserAvatarUrl),
  32. zap.String("reason", args.Memo),
  33. zap.String("times", args.Times),
  34. )
  35. pushPlatform := svc.SysCfgGet("app_push_platform")
  36. if pushPlatform == "JgPush" { //极光
  37. //args.Content = getChangeContent(args, args.Content)
  38. JgPush(args)
  39. return
  40. }
  41. return
  42. }
  43. func JgPush(args md3.PushParams) {
  44. jgPushAppKey := svc.SysCfgGet("jg_push_app_key")
  45. jgPushAppSecret := svc.SysCfgGet("jg_push_app_secret")
  46. fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_key<<<<<<<<<<<<<<<<<<<<<<", jgPushAppKey)
  47. fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_secret<<<<<<<<<<<<<<<<<<<<<<", jgPushAppSecret)
  48. if jgPushAppKey == "" || jgPushAppSecret == "" {
  49. return
  50. }
  51. var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
  52. var extras = map[string]interface{}{
  53. "uid": args.Uid,
  54. "push_type": args.PushType,
  55. "message_type": args.MessageType,
  56. "send_user_nickname": args.SendUserNickname,
  57. "send_user_avatar_url": args.SendUserAvatarUrl,
  58. "memo": args.Memo,
  59. "times": args.Times,
  60. }
  61. var intent = map[string]interface{}{
  62. "url": "#Intent;action=android.intent.action.MAIN;end",
  63. }
  64. var param = md2.PushParam{
  65. Platform: "all",
  66. Audience: aud,
  67. Title: args.Title,
  68. Content: strings.Replace(args.Content, "\n\u0006", "", -1),
  69. Extras: extras,
  70. Intent: intent,
  71. }
  72. send, res, err := jg_push.Send(jgPushAppKey, jgPushAppSecret, param)
  73. utils.FilePutContents("JgPush", utils.SerializeStr(map[string]interface{}{
  74. "send": send,
  75. "res": res,
  76. "push_alia": args.PushAlia,
  77. "title": param.Title,
  78. "content": param.Content,
  79. "jg_push_app_key": jgPushAppKey,
  80. "jg_push_app_secret": jgPushAppSecret,
  81. }))
  82. logger.Logger.Debug("JgPush_log",
  83. zap.String("send", send),
  84. zap.String("res", res),
  85. zap.String("push_alia", args.PushAlia),
  86. zap.String("title", param.Title),
  87. zap.String("content", param.Content),
  88. zap.String("jg_push_app_key", jgPushAppKey),
  89. zap.String("jg_push_app_secret", jgPushAppSecret),
  90. )
  91. if err != nil {
  92. fmt.Println("send_error::::", err)
  93. return
  94. }
  95. if send == "" {
  96. return
  97. }
  98. //TODO::发送成功处理
  99. return
  100. }