This commit is contained in:
wangchuxiao
2022-03-16 20:37:37 +08:00
parent 17fad47ca1
commit 8fef1f975a
9 changed files with 47 additions and 407 deletions
+32
View File
@@ -0,0 +1,32 @@
package apiChat
//
//import (
// apiStruct "Open_IM/pkg/base_info"
// "Open_IM/pkg/common/config"
// "Open_IM/pkg/common/log"
// "Open_IM/pkg/common/token_verify"
// "Open_IM/pkg/grpc-etcdv3/getcdv3"
// pbChat "Open_IM/pkg/proto/chat"
// "Open_IM/pkg/utils"
// "github.com/gin-gonic/gin"
// "net/http"
// "strings"
//)
//
//func DelMsg(c *gin.Context) {
// var (
// req apiStruct.DelMsgReq
// resp apiStruct.DelMsgResp
// reqPb pbChat.
// )
// ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
// if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
// return
// }
// grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
// msgClient := pbChat.NewChatClient(grpcConn)
// //respPb, err := msgClient.DelMsgList()
//}
+5 -1
View File
@@ -7,6 +7,7 @@ import (
"Open_IM/pkg/grpc-etcdv3/getcdv3"
"Open_IM/pkg/proto/chat"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
@@ -39,7 +40,10 @@ func PullMsgBySeqList(c *gin.Context) {
token := c.Request.Header.Get("token")
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
if err != nil {
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error(), token, params.SendID)
}
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
return
}
pbData := open_im_sdk.PullMessageBySeqListReq{}
-50
View File
@@ -1,50 +0,0 @@
package rtc
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
pbRtc "Open_IM/pkg/proto/rtc"
"Open_IM/pkg/utils"
"context"
"encoding/json"
"time"
"github.com/livekit/protocol/auth"
//lksdk "github.com/livekit/server-sdk-go"
)
type RtcService struct {
}
func (r *RtcService) GetJoinToken(_ context.Context, req *pbRtc.GetJoinTokenReq) (resp *pbRtc.GetJoinTokenResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp = &pbRtc.GetJoinTokenResp{}
canPublish := true
canSubscribe := true
at := auth.NewAccessToken(req.ApiKey, req.ApiSecret)
grant := &auth.VideoGrant{
RoomJoin: true,
Room: req.Room,
CanPublish: &canPublish,
CanSubscribe: &canSubscribe,
}
byte, err := json.Marshal(req.MetaData)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "json marshal failed", err.Error())
resp.CommonResp = &pbRtc.CommonResp{ErrCode: constant.ErrArgs.ErrCode, ErrMsg: constant.ErrArgs.ErrMsg}
return
}
at.AddGrant(grant).
SetIdentity(req.Identity).
// optional
SetName("participant-name").
SetValidFor(time.Hour).SetMetadata(string(byte))
jwt, err := at.ToJWT()
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "toJwt failed", err.Error(), "jwt: ", jwt)
}
resp.Jwt = jwt
resp.CommonResp = &pbRtc.CommonResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
return resp, err
}
+1 -1
View File
@@ -214,7 +214,7 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
return resp, nil
}
chat.SetConversationNotification(req.OperationID, req.OwnerUserID)
log.NewError(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
resp.CommonResp = &pbUser.CommonResp{}
return resp, nil
}