golang-im聊天
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.

app_push.go 1.6 KiB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. "gim/internal/business/comm/db"
  6. md3 "gim/internal/logic/domain/message/md"
  7. "strings"
  8. )
  9. func getChangeContent(args md3.PushParams, Content string) string {
  10. Content = strings.Replace(Content, "[MasterId]", args.MasterId, -1)
  11. Content = strings.Replace(Content, "[消费发送者-会员昵称]", args.SendUserNickname, -1)
  12. Content = strings.Replace(Content, "[备注]", args.Memo, -1)
  13. Content = strings.Replace(Content, "[时间]", args.Times, -1)
  14. return Content
  15. }
  16. // CommAddPush 公共处理推送数据
  17. func CommAddPush(args md3.PushParams) {
  18. pushPlatform := db.DbSysCfg.SysCfgFindWithDb(args.MasterId, "app_push_platform")["app_push_platform"]
  19. if pushPlatform == "jg" { //极光
  20. args.Content = getChangeContent(args, args.Content)
  21. JgPush(args)
  22. return
  23. }
  24. return
  25. }
  26. func JgPush(args md3.PushParams) {
  27. thirdJgPush := db.DbSysCfg.SysCfgFindWithDb(args.MasterId, "jg_push_app_key", "jg_push_app_secret")
  28. if thirdJgPush["jg_push_app_key"] == "" || thirdJgPush["jg_push_app_secret"] == "" {
  29. return
  30. }
  31. //alia := db.DbUserPushForJg.UserPushForJgGetWithDb(args.MasterId, args.Uid)
  32. var aud = md2.PushAudience{Alias: []string{args.PushAlia}}
  33. var extras interface{}
  34. var param = md2.PushParam{
  35. Platform: "all",
  36. Audience: aud,
  37. Title: args.Title,
  38. Content: args.Content,
  39. Extras: extras,
  40. }
  41. send, _, err := jg_push.Send(thirdJgPush["jg_push_app_key"], thirdJgPush["jg_push_app_secret"], param)
  42. if err != nil {
  43. return
  44. }
  45. if send == "" {
  46. return
  47. }
  48. //TODO::发送成功处理
  49. return
  50. }