mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-24 10:22:36 +08:00
getui
This commit is contained in:
parent
59cc45eaab
commit
4efdabc1ff
@ -165,6 +165,7 @@ longconnsvr:
|
|||||||
websocketMaxMsgLen: 4096
|
websocketMaxMsgLen: 4096
|
||||||
websocketTimeOut: 10
|
websocketTimeOut: 10
|
||||||
|
|
||||||
|
## 推送只能开启一个
|
||||||
push:
|
push:
|
||||||
tpns: #腾讯推送,暂未测试 暂不要使用
|
tpns: #腾讯推送,暂未测试 暂不要使用
|
||||||
ios:
|
ios:
|
||||||
@ -173,11 +174,20 @@ push:
|
|||||||
android:
|
android:
|
||||||
accessID: 111
|
accessID: 111
|
||||||
secretKey: 111
|
secretKey: 111
|
||||||
|
enable: false
|
||||||
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
jpns: #极光推送 在极光后台申请后,修改以下四项,必须修改
|
||||||
appKey: cf47465a368f24c659608e7e
|
appKey: cf47465a368f24c659608e7e
|
||||||
masterSecret: 02204efe3f3832947a236ee5
|
masterSecret: 02204efe3f3832947a236ee5
|
||||||
pushUrl: "https://api.jpush.cn/v3/push"
|
pushUrl: "https://api.jpush.cn/v3/push"
|
||||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||||
|
enable: false
|
||||||
|
getui: #个推推送,暂未测试 暂不要使用
|
||||||
|
pushUrl: "https://restapi.getui.com/v2/$appId"
|
||||||
|
sign: ""
|
||||||
|
appKey: ""
|
||||||
|
enable: true
|
||||||
|
intent: ""
|
||||||
|
|
||||||
manager:
|
manager:
|
||||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||||
|
@ -43,6 +43,7 @@ func GetGroupById(c *gin.Context) {
|
|||||||
resp.ProfilePhoto = respPb.CMSGroup.GroupInfo.FaceURL
|
resp.ProfilePhoto = respPb.CMSGroup.GroupInfo.FaceURL
|
||||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||||
|
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ func GetGroups(c *gin.Context) {
|
|||||||
GroupMasterName: v.GroupMasterName,
|
GroupMasterName: v.GroupMasterName,
|
||||||
GroupMasterId: v.GroupMasterId,
|
GroupMasterId: v.GroupMasterId,
|
||||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||||
IsBanChat: false,
|
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
|
||||||
IsBanPrivateChat: false,
|
IsBanPrivateChat: false,
|
||||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||||
})
|
})
|
||||||
@ -114,7 +115,7 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
GroupMasterName: v.GroupMasterName,
|
GroupMasterName: v.GroupMasterName,
|
||||||
GroupMasterId: v.GroupMasterId,
|
GroupMasterId: v.GroupMasterId,
|
||||||
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
CreateTime: (utils.UnixSecondToTime(int64(v.GroupInfo.CreateTime))).String(),
|
||||||
IsBanChat: false,
|
IsBanChat: constant.GroupIsBanChat(v.GroupInfo.Status),
|
||||||
IsBanPrivateChat: false,
|
IsBanPrivateChat: false,
|
||||||
ProfilePhoto: v.GroupInfo.FaceURL,
|
ProfilePhoto: v.GroupInfo.FaceURL,
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,148 @@
|
|||||||
package getui
|
package getui
|
||||||
|
|
||||||
type Getui struct {
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
GetuiClient *Getui
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
GetuiClient = newGetuiClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Getui) Push(userIDList []string, alert, detailContent, platform string) (resp string, err error) {
|
type Getui struct{}
|
||||||
return "", nil
|
|
||||||
|
type GetuiCommonResp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Getui) Auth(apiKey, secretKey string, timeStamp int64) (token string, err error) {
|
type AuthReq struct {
|
||||||
return "", nil
|
Sign string `json:"sign"`
|
||||||
|
Timestamp string `json:"timestamp"`
|
||||||
|
Appkey string `json:"appkey"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AuthResp struct {
|
||||||
|
ExpireTime string `json:"expire_time"`
|
||||||
|
Token string `json:"token"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushReq struct {
|
||||||
|
RequestID string `json:"request_id"`
|
||||||
|
Audience struct {
|
||||||
|
Cid []string `json:"cid"`
|
||||||
|
} `json:"audience"`
|
||||||
|
PushMssage struct {
|
||||||
|
Notification Notification `json:"notification"`
|
||||||
|
} `json:"push_message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Notification struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
ClickType string `json:"click_type"`
|
||||||
|
Intent string `json:"intent"`
|
||||||
|
Url string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushResp struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func newGetuiClient() *Getui {
|
||||||
|
return &Getui{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Getui) Push(userIDList []string, alert, detailContent, platform, operationID string) (resp string, err error) {
|
||||||
|
token, err := db.DB.GetGetuiToken()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, utils.OperationIDGenerator(), "GetGetuiToken", err.Error())
|
||||||
|
}
|
||||||
|
if token == "" || err != nil {
|
||||||
|
token, expireTime, err := g.Auth(config.Config.Push.Getui.AppKey, config.Config.Push.Getui.Sign, operationID, time.Now().Unix())
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "Auth failed")
|
||||||
|
}
|
||||||
|
log.NewInfo(operationID, "getui", utils.GetSelfFuncName(), token, expireTime, err)
|
||||||
|
err = db.DB.SetGetuiToken(token, expireTime-time.Now().Unix()-20)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "Auth failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pushReq := PushReq{
|
||||||
|
RequestID: utils.OperationIDGenerator(),
|
||||||
|
Audience: struct {
|
||||||
|
Cid []string `json:"cid"`
|
||||||
|
}{Cid: []string{userIDList[0]}},
|
||||||
|
}
|
||||||
|
pushReq.PushMssage.Notification = Notification{
|
||||||
|
Title: alert,
|
||||||
|
Body: alert,
|
||||||
|
ClickType: "none",
|
||||||
|
}
|
||||||
|
if config.Config.Push.Getui.Intent != "" {
|
||||||
|
pushReq.PushMssage.Notification.Intent = config.Config.Push.Getui.Intent
|
||||||
|
pushReq.PushMssage.Notification.ClickType = "intent"
|
||||||
|
}
|
||||||
|
pushResp := PushResp{}
|
||||||
|
err = g.request(pushReq, token, &pushResp, operationID)
|
||||||
|
if err != nil {
|
||||||
|
return "", utils.Wrap(err, "")
|
||||||
|
}
|
||||||
|
respBytes, err := json.Marshal(pushResp)
|
||||||
|
return string(respBytes), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Getui) Auth(appKey, sign, operationID string, timeStamp int64) (token string, expireTime int64, err error) {
|
||||||
|
log.NewInfo(operationID, utils.GetSelfFuncName(), appKey, sign, timeStamp)
|
||||||
|
reqAuth := AuthReq{
|
||||||
|
Sign: sign,
|
||||||
|
Timestamp: strconv.Itoa(int(timeStamp)),
|
||||||
|
Appkey: appKey,
|
||||||
|
}
|
||||||
|
respAuth := AuthResp{}
|
||||||
|
err = g.request(reqAuth, "", &respAuth, operationID)
|
||||||
|
expire, err := strconv.Atoi(respAuth.ExpireTime)
|
||||||
|
return respAuth.Token, int64(expire), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Getui) request(content interface{}, token string, returnStruct interface{}, operationID string) error {
|
||||||
|
con, err := json.Marshal(content)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
client := &http.Client{}
|
||||||
|
req, err := http.NewRequest("POST", config.Config.Push.Getui.PushUrl, bytes.NewBuffer(con))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Set(token, token)
|
||||||
|
req.Header.Set("content-type", "application/json")
|
||||||
|
req.Header.Set("content-type", "charset=utf-8")
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
result, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.NewInfo(operationID, "getui", utils.GetSelfFuncName(), string(result))
|
||||||
|
if err := json.Unmarshal(result, returnStruct); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,29 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type JPushResp struct {
|
var (
|
||||||
|
JPushClient *JPush
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
JPushClient = newGetuiClient()
|
||||||
}
|
}
|
||||||
|
|
||||||
type JPush struct {
|
type JPush struct{}
|
||||||
|
|
||||||
|
func newGetuiClient() *JPush {
|
||||||
|
return &JPush{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func JGAccountListPush(accounts []string, alert, detailContent, platform string) ([]byte, error) {
|
func (j *JPush) Auth(apiKey, secretKey string, timeStamp int64) (token string, err error) {
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *JPush) Push(accounts []string, alert, detailContent, platform, operationID string) (string, error) {
|
||||||
var pf requestBody.Platform
|
var pf requestBody.Platform
|
||||||
_ = pf.SetPlatform(platform)
|
_ = pf.SetPlatform(platform)
|
||||||
var au requestBody.Audience
|
var au requestBody.Audience
|
||||||
@ -37,25 +52,23 @@ func JGAccountListPush(accounts []string, alert, detailContent, platform string)
|
|||||||
|
|
||||||
con, err := json.Marshal(po)
|
con, err := json.Marshal(po)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.Config.Push.Jpns.PushUrl, bytes.NewBuffer(con))
|
req, err := http.NewRequest("POST", config.Config.Push.Jpns.PushUrl, bytes.NewBuffer(con))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
req.Header.Set("Authorization", common.GetAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret))
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
result, err := ioutil.ReadAll(resp.Body)
|
result, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
return result, nil
|
return string(result), nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
push "Open_IM/internal/push/jpush"
|
pusher "Open_IM/internal/push"
|
||||||
|
"Open_IM/internal/push/getui"
|
||||||
|
jpush "Open_IM/internal/push/jpush"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
@ -99,12 +101,21 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
content = constant.ContentType2PushContent[constant.Common]
|
content = constant.ContentType2PushContent[constant.Common]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var offlinePusher pusher.OfflinePusher
|
||||||
pushResult, err := push.JGAccountListPush(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t))
|
if config.Config.Push.Getui.Enable {
|
||||||
|
offlinePusher = getui.GetuiClient
|
||||||
|
}
|
||||||
|
if config.Config.Push.Jpns.Enable {
|
||||||
|
offlinePusher = jpush.JPushClient
|
||||||
|
}
|
||||||
|
if offlinePusher == nil {
|
||||||
|
offlinePusher = jpush.JPushClient
|
||||||
|
}
|
||||||
|
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, constant.PlatformIDToName(t), pushMsg.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error(), constant.PlatformIDToName(t))
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error(), constant.PlatformIDToName(t))
|
||||||
} else {
|
} else {
|
||||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", string(pushResult), pushMsg.MsgData, constant.PlatformIDToName(t))
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData, constant.PlatformIDToName(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package push
|
package push
|
||||||
|
|
||||||
type offlinePusher interface {
|
type OfflinePusher interface {
|
||||||
auth(apiKey, secretKey string, timeStamp int64) (token string, err error)
|
Push(userIDList []string, alert, detailContent, platform, operationID string) (resp string, err error)
|
||||||
push(userIDList []string, alert, detailContent, platform string) (resp string, err error)
|
|
||||||
}
|
}
|
||||||
|
@ -7,3 +7,7 @@ import (
|
|||||||
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) (bool, error) {
|
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func callbackAfterCreateGroup(req *pbGroup.CreateGroupReq) {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -668,6 +668,7 @@ func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdR
|
|||||||
Status: group.Status,
|
Status: group.Status,
|
||||||
CreatorUserID: group.CreatorUserID,
|
CreatorUserID: group.CreatorUserID,
|
||||||
GroupType: group.GroupType,
|
GroupType: group.GroupType,
|
||||||
|
CreateTime: uint32(group.CreateTime.Unix()),
|
||||||
}
|
}
|
||||||
groupMember, err := imdb.GetGroupMaster(group.GroupID)
|
groupMember, err := imdb.GetGroupMaster(group.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -677,6 +678,7 @@ func (s *groupServer) GetGroupById(_ context.Context, req *pbGroup.GetGroupByIdR
|
|||||||
resp.CMSGroup.GroupMasterName = groupMember.Nickname
|
resp.CMSGroup.GroupMasterName = groupMember.Nickname
|
||||||
resp.CMSGroup.GroupMasterId = groupMember.UserID
|
resp.CMSGroup.GroupMasterId = groupMember.UserID
|
||||||
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
|
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,6 +706,7 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
|||||||
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
||||||
GroupInfo: &open_im_sdk.GroupInfo{
|
GroupInfo: &open_im_sdk.GroupInfo{
|
||||||
@ -713,11 +716,13 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
|
|||||||
OwnerUserID: v.CreatorUserID,
|
OwnerUserID: v.CreatorUserID,
|
||||||
Status: v.Status,
|
Status: v.Status,
|
||||||
CreatorUserID: v.CreatorUserID,
|
CreatorUserID: v.CreatorUserID,
|
||||||
|
CreateTime: uint32(v.CreateTime.Unix()),
|
||||||
},
|
},
|
||||||
GroupMasterName: groupMember.Nickname,
|
GroupMasterName: groupMember.Nickname,
|
||||||
GroupMasterId: groupMember.UserID,
|
GroupMasterId: groupMember.UserID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) {
|
func TagSendMessage(operationID, sendID, recvID, content string, senderPlatformID int32) {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "args: ", sendID, recvID, content, senderPlatformID)
|
||||||
var req pbChat.SendMsgReq
|
var req pbChat.SendMsgReq
|
||||||
var msgData pbCommon.MsgData
|
var msgData pbCommon.MsgData
|
||||||
msgData.SendID = sendID
|
msgData.SendID = sendID
|
||||||
|
@ -8,7 +8,7 @@ type GroupResponse struct {
|
|||||||
CreateTime string `json:"create_time"`
|
CreateTime string `json:"create_time"`
|
||||||
IsBanChat bool `json:"is_ban_chat"`
|
IsBanChat bool `json:"is_ban_chat"`
|
||||||
IsBanPrivateChat bool `json:"is_ban_private_chat"`
|
IsBanPrivateChat bool `json:"is_ban_private_chat"`
|
||||||
ProfilePhoto string `json:"profile_photo"`
|
ProfilePhoto string `json:"profile_photo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupByIdRequest struct {
|
type GetGroupByIdRequest struct {
|
||||||
@ -63,7 +63,6 @@ type SetGroupMemberRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SetGroupMemberRespones struct {
|
type SetGroupMemberRespones struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BanGroupChatRequest struct {
|
type BanGroupChatRequest struct {
|
||||||
@ -88,7 +87,7 @@ type DeleteGroupResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupMembersRequest struct {
|
type GetGroupMembersRequest struct {
|
||||||
GroupId string `form:"group_id" binding:"required"`
|
GroupId string `form:"group_id" binding:"required"`
|
||||||
UserName string `form:"user_name"`
|
UserName string `form:"user_name"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
}
|
}
|
||||||
@ -96,24 +95,24 @@ type GetGroupMembersRequest struct {
|
|||||||
type GroupMemberResponse struct {
|
type GroupMemberResponse struct {
|
||||||
MemberPosition int `json:"member_position"`
|
MemberPosition int `json:"member_position"`
|
||||||
MemberNickName string `json:"member_nick_name"`
|
MemberNickName string `json:"member_nick_name"`
|
||||||
MemberId string `json:"member_id"`
|
MemberId string `json:"member_id"`
|
||||||
JoinTime string `json:"join_time"`
|
JoinTime string `json:"join_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupMembersResponse struct {
|
type GetGroupMembersResponse struct {
|
||||||
GroupMembers []GroupMemberResponse `json:"group_members"`
|
GroupMembers []GroupMemberResponse `json:"group_members"`
|
||||||
ResponsePagination
|
ResponsePagination
|
||||||
MemberNums int `json:"member_nums"`
|
MemberNums int `json:"member_nums"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupMemberRequest struct {
|
type GroupMemberRequest struct {
|
||||||
GroupId string `json:"group_id" binding:"required"`
|
GroupId string `json:"group_id" binding:"required"`
|
||||||
Members []string `json:"members" binding:"required"`
|
Members []string `json:"members" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupMemberOperateResponse struct {
|
type GroupMemberOperateResponse struct {
|
||||||
Success []string `json:"success"`
|
Success []string `json:"success"`
|
||||||
Failed []string `json:"failed"`
|
Failed []string `json:"failed"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddGroupMembersRequest struct {
|
type AddGroupMembersRequest struct {
|
||||||
@ -128,19 +127,18 @@ type RemoveGroupMembersRequest struct {
|
|||||||
GroupMemberRequest
|
GroupMemberRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
type RemoveGroupMembersResponse struct{
|
type RemoveGroupMembersResponse struct {
|
||||||
GroupMemberOperateResponse
|
GroupMemberOperateResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlterGroupInfoRequest struct {
|
type AlterGroupInfoRequest struct {
|
||||||
GroupID string `json:"group_id"`
|
GroupID string `json:"group_id"`
|
||||||
GroupName string `json:"group_name"`
|
GroupName string `json:"group_name"`
|
||||||
Notification string `json:"notification"`
|
Notification string `json:"notification"`
|
||||||
Introduction string `json:"introduction"`
|
Introduction string `json:"introduction"`
|
||||||
ProfilePhoto string `json:"profile_photo"`
|
ProfilePhoto string `json:"profile_photo"`
|
||||||
GroupType int `json:"group_type"`
|
GroupType int `json:"group_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlterGroupInfoResponse struct {
|
type AlterGroupInfoResponse struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,21 @@ type config struct {
|
|||||||
AccessID string `yaml:"accessID"`
|
AccessID string `yaml:"accessID"`
|
||||||
SecretKey string `yaml:"secretKey"`
|
SecretKey string `yaml:"secretKey"`
|
||||||
}
|
}
|
||||||
|
Enable bool `yaml:"enable"`
|
||||||
}
|
}
|
||||||
Jpns struct {
|
Jpns struct {
|
||||||
AppKey string `yaml:"appKey"`
|
AppKey string `yaml:"appKey"`
|
||||||
MasterSecret string `yaml:"masterSecret"`
|
MasterSecret string `yaml:"masterSecret"`
|
||||||
PushUrl string `yaml:"pushUrl"`
|
PushUrl string `yaml:"pushUrl"`
|
||||||
PushIntent string `yaml:"pushIntent"`
|
PushIntent string `yaml:"pushIntent"`
|
||||||
|
Enable bool `yaml:"enable"`
|
||||||
|
}
|
||||||
|
Getui struct {
|
||||||
|
PushUrl string `yaml:"pushUrl"`
|
||||||
|
Sign string `yaml:"sign"`
|
||||||
|
AppKey string `yaml:"appkey"`
|
||||||
|
Enable bool `yaml:"enable"`
|
||||||
|
Intent string `yaml:"intent"`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Manager struct {
|
Manager struct {
|
||||||
|
@ -217,7 +217,7 @@ const (
|
|||||||
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
||||||
|
|
||||||
func GroupIsBanChat(status int32) bool {
|
func GroupIsBanChat(status int32) bool {
|
||||||
if status != GroupBanChat {
|
if status != GroupStatusMuted {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -14,6 +14,7 @@ const (
|
|||||||
userMinSeq = "REDIS_USER_MIN_SEQ:"
|
userMinSeq = "REDIS_USER_MIN_SEQ:"
|
||||||
uidPidToken = "UID_PID_TOKEN_STATUS:"
|
uidPidToken = "UID_PID_TOKEN_STATUS:"
|
||||||
conversationReceiveMessageOpt = "CON_RECV_MSG_OPT:"
|
conversationReceiveMessageOpt = "CON_RECV_MSG_OPT:"
|
||||||
|
GetuiToken = "GETUI"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
|
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
|
||||||
@ -144,3 +145,13 @@ func (d *DataBases) GetMultiConversationMsgOpt(userID string, conversationIDs []
|
|||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) SetGetuiToken(token string, expireTime int64) error {
|
||||||
|
_, err := d.Exec("SET", GetuiToken, token, "ex", expireTime)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DataBases) GetGetuiToken() (string, error) {
|
||||||
|
result, err := redis.String(d.Exec("GET", GetuiToken))
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
@ -38,6 +38,6 @@ func RespHttp200(ctx *gin.Context, err error, data interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// warp error
|
// warp error
|
||||||
func WrapError(err constant.ErrInfo) error {
|
func WrapError(err constant.ErrInfo, msg ...string) error {
|
||||||
return status.Error(codes.Code(err.ErrCode), err.ErrMsg)
|
return status.Error(codes.Code(err.ErrCode), err.ErrMsg+msg[0])
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user