golang-im聊天
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

app_push.go 3.3 KiB

2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
2 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. "fmt"
  6. svc "gim/internal/business/comm/service"
  7. md3 "gim/internal/logic/domain/message/md"
  8. "gim/pkg/logger"
  9. "go.uber.org/zap"
  10. "strings"
  11. )
  12. func getChangeContent(args md3.PushParams, Content string) string {
  13. Content = strings.Replace(Content, "[MasterId]", args.MasterId, -1)
  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("master_id", args.MasterId),
  25. zap.String("uid", args.Uid),
  26. zap.String("push_alia", args.PushAlia),
  27. zap.String("title", args.Title),
  28. zap.String("content", args.Content),
  29. zap.String("push_type", args.PushType),
  30. zap.String("message_type", args.MessageType),
  31. zap.String("send_user_nickname", args.SendUserNickname),
  32. zap.String("send_user_avatar_url", args.SendUserAvatarUrl),
  33. zap.String("reason", args.Memo),
  34. zap.String("times", args.Times),
  35. )
  36. pushPlatform := svc.SysCfgGet(args.MasterId, "app_push_platform")
  37. if pushPlatform == "JgPush" { //极光
  38. args.Content = getChangeContent(args, args.Content)
  39. JgPush(args)
  40. return
  41. }
  42. return
  43. }
  44. func JgPush(args md3.PushParams) {
  45. jgPushAppKey := svc.SysCfgGet(args.MasterId, "jg_push_app_key")
  46. jgPushAppSecret := svc.SysCfgGet(args.MasterId, "jg_push_app_secret")
  47. fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_key<<<<<<<<<<<<<<<<<<<<<<", jgPushAppKey)
  48. fmt.Println(">>>>>>>>>>>>>>>>>>>>jg_push_app_secret<<<<<<<<<<<<<<<<<<<<<<", jgPushAppSecret)
  49. if jgPushAppKey == "" || jgPushAppSecret == "" {
  50. return
  51. }
  52. //alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
  53. var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
  54. var extras = map[string]interface{}{
  55. "master_id": args.MasterId,
  56. "uid": args.Uid,
  57. "push_type": args.PushType,
  58. "message_type": args.MessageType,
  59. "send_user_nickname": args.SendUserNickname,
  60. "send_user_avatar_url": args.SendUserAvatarUrl,
  61. "memo": args.Memo,
  62. "times": args.Times,
  63. }
  64. var intent = map[string]interface{}{
  65. "url": "#Intent;action=android.intent.action.MAIN;end",
  66. }
  67. var param = md2.PushParam{
  68. Platform: "all",
  69. Audience: aud,
  70. Title: args.Title,
  71. Content: args.Content,
  72. Extras: extras,
  73. Intent: intent,
  74. }
  75. send, res, err := jg_push.Send(jgPushAppKey, jgPushAppSecret, param)
  76. logger.Logger.Debug("JgPush_log",
  77. zap.String("send", send),
  78. zap.String("res", res),
  79. zap.String("push_alia", args.PushAlia),
  80. zap.String("title", param.Title),
  81. zap.String("content", param.Content),
  82. zap.String("jg_push_app_key", jgPushAppKey),
  83. zap.String("jg_push_app_secret", jgPushAppSecret),
  84. )
  85. if err != nil {
  86. fmt.Println("send_error::::", err)
  87. return
  88. }
  89. if send == "" {
  90. return
  91. }
  92. //TODO::发送成功处理
  93. return
  94. }