diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 033688f7e..0fea4b0f8 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -85,6 +85,7 @@ func main() { chatGroup.POST("/newest_seq", apiChat.GetSeq) chatGroup.POST("/send_msg", apiChat.SendMsg) chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList) + //chatGroup.POST("/del_msg", apiChat) } //Manager managementGroup := r.Group("/manager") diff --git a/cmd/rpc/open_im_rtc/main.go b/cmd/rpc/open_im_rtc/main.go deleted file mode 100644 index e093a361f..000000000 --- a/cmd/rpc/open_im_rtc/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "Open_IM/internal/rpc/rtc" - "Open_IM/pkg/common/log" - rtcPb "Open_IM/pkg/proto/rtc" - "Open_IM/pkg/utils" - "google.golang.org/grpc" - "google.golang.org/grpc/reflection" - "net" -) - -func main() { - lis, err := net.Listen("tcp", "0.0.0.0:11300") - if err != nil { - log.NewError("", utils.GetSelfFuncName(), err.Error()) - } // 创建 RPC 服务容器 - grpcServer := grpc.NewServer() - rtcPb.RegisterRtcServiceServer(grpcServer, &rtc.RtcService{}) - - reflection.Register(grpcServer) - - if err := grpcServer.Serve(lis); err != nil { - log.NewError("", utils.GetSelfFuncName(), err.Error()) - } - log.NewInfo("", utils.GetSelfFuncName(), "start success") -} \ No newline at end of file diff --git a/internal/api/chat/del_msg.go b/internal/api/chat/del_msg.go new file mode 100644 index 000000000..6cdda51ed --- /dev/null +++ b/internal/api/chat/del_msg.go @@ -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() +//} diff --git a/internal/api/chat/pull_msg.go b/internal/api/chat/pull_msg.go index 0872319c6..515e9b743 100644 --- a/internal/api/chat/pull_msg.go +++ b/internal/api/chat/pull_msg.go @@ -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{} diff --git a/internal/rpc/rtc/rtc.go b/internal/rpc/rtc/rtc.go deleted file mode 100644 index e9dff0c9d..000000000 --- a/internal/rpc/rtc/rtc.go +++ /dev/null @@ -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 -} diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 5b37c3172..6b4472f01 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -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 } diff --git a/pkg/base_info/msg.go b/pkg/base_info/msg.go new file mode 100644 index 000000000..d7aa11a82 --- /dev/null +++ b/pkg/base_info/msg.go @@ -0,0 +1,8 @@ +package base_info + +type DelMsgReq struct { + OperationID string `json:"operationID"` +} + +type DelMsgResp struct { +} diff --git a/pkg/proto/rtc/rtc.pb.go b/pkg/proto/rtc/rtc.pb.go deleted file mode 100644 index a1b439537..000000000 --- a/pkg/proto/rtc/rtc.pb.go +++ /dev/null @@ -1,301 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: rtc/rtc.proto - -package rtc // import "./rtc" - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import sdk_ws "Open_IM/pkg/proto/sdk_ws" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type CommonResp struct { - ErrCode int32 `protobuf:"varint,1,opt,name=errCode" json:"errCode,omitempty"` - ErrMsg string `protobuf:"bytes,2,opt,name=errMsg" json:"errMsg,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CommonResp) Reset() { *m = CommonResp{} } -func (m *CommonResp) String() string { return proto.CompactTextString(m) } -func (*CommonResp) ProtoMessage() {} -func (*CommonResp) Descriptor() ([]byte, []int) { - return fileDescriptor_rtc_058fd4200139f42f, []int{0} -} -func (m *CommonResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CommonResp.Unmarshal(m, b) -} -func (m *CommonResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CommonResp.Marshal(b, m, deterministic) -} -func (dst *CommonResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_CommonResp.Merge(dst, src) -} -func (m *CommonResp) XXX_Size() int { - return xxx_messageInfo_CommonResp.Size(m) -} -func (m *CommonResp) XXX_DiscardUnknown() { - xxx_messageInfo_CommonResp.DiscardUnknown(m) -} - -var xxx_messageInfo_CommonResp proto.InternalMessageInfo - -func (m *CommonResp) GetErrCode() int32 { - if m != nil { - return m.ErrCode - } - return 0 -} - -func (m *CommonResp) GetErrMsg() string { - if m != nil { - return m.ErrMsg - } - return "" -} - -type GetJoinTokenReq struct { - ApiKey string `protobuf:"bytes,1,opt,name=apiKey" json:"apiKey,omitempty"` - ApiSecret string `protobuf:"bytes,2,opt,name=apiSecret" json:"apiSecret,omitempty"` - Room string `protobuf:"bytes,3,opt,name=room" json:"room,omitempty"` - Identity string `protobuf:"bytes,4,opt,name=identity" json:"identity,omitempty"` - MetaData *sdk_ws.ParticipantMetaData `protobuf:"bytes,5,opt,name=metaData" json:"metaData,omitempty"` - OperationID string `protobuf:"bytes,6,opt,name=operationID" json:"operationID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetJoinTokenReq) Reset() { *m = GetJoinTokenReq{} } -func (m *GetJoinTokenReq) String() string { return proto.CompactTextString(m) } -func (*GetJoinTokenReq) ProtoMessage() {} -func (*GetJoinTokenReq) Descriptor() ([]byte, []int) { - return fileDescriptor_rtc_058fd4200139f42f, []int{1} -} -func (m *GetJoinTokenReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetJoinTokenReq.Unmarshal(m, b) -} -func (m *GetJoinTokenReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetJoinTokenReq.Marshal(b, m, deterministic) -} -func (dst *GetJoinTokenReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetJoinTokenReq.Merge(dst, src) -} -func (m *GetJoinTokenReq) XXX_Size() int { - return xxx_messageInfo_GetJoinTokenReq.Size(m) -} -func (m *GetJoinTokenReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetJoinTokenReq.DiscardUnknown(m) -} - -var xxx_messageInfo_GetJoinTokenReq proto.InternalMessageInfo - -func (m *GetJoinTokenReq) GetApiKey() string { - if m != nil { - return m.ApiKey - } - return "" -} - -func (m *GetJoinTokenReq) GetApiSecret() string { - if m != nil { - return m.ApiSecret - } - return "" -} - -func (m *GetJoinTokenReq) GetRoom() string { - if m != nil { - return m.Room - } - return "" -} - -func (m *GetJoinTokenReq) GetIdentity() string { - if m != nil { - return m.Identity - } - return "" -} - -func (m *GetJoinTokenReq) GetMetaData() *sdk_ws.ParticipantMetaData { - if m != nil { - return m.MetaData - } - return nil -} - -func (m *GetJoinTokenReq) GetOperationID() string { - if m != nil { - return m.OperationID - } - return "" -} - -type GetJoinTokenResp struct { - CommonResp *CommonResp `protobuf:"bytes,1,opt,name=CommonResp" json:"CommonResp,omitempty"` - Jwt string `protobuf:"bytes,2,opt,name=jwt" json:"jwt,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetJoinTokenResp) Reset() { *m = GetJoinTokenResp{} } -func (m *GetJoinTokenResp) String() string { return proto.CompactTextString(m) } -func (*GetJoinTokenResp) ProtoMessage() {} -func (*GetJoinTokenResp) Descriptor() ([]byte, []int) { - return fileDescriptor_rtc_058fd4200139f42f, []int{2} -} -func (m *GetJoinTokenResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetJoinTokenResp.Unmarshal(m, b) -} -func (m *GetJoinTokenResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetJoinTokenResp.Marshal(b, m, deterministic) -} -func (dst *GetJoinTokenResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetJoinTokenResp.Merge(dst, src) -} -func (m *GetJoinTokenResp) XXX_Size() int { - return xxx_messageInfo_GetJoinTokenResp.Size(m) -} -func (m *GetJoinTokenResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetJoinTokenResp.DiscardUnknown(m) -} - -var xxx_messageInfo_GetJoinTokenResp proto.InternalMessageInfo - -func (m *GetJoinTokenResp) GetCommonResp() *CommonResp { - if m != nil { - return m.CommonResp - } - return nil -} - -func (m *GetJoinTokenResp) GetJwt() string { - if m != nil { - return m.Jwt - } - return "" -} - -func init() { - proto.RegisterType((*CommonResp)(nil), "rtc.CommonResp") - proto.RegisterType((*GetJoinTokenReq)(nil), "rtc.GetJoinTokenReq") - proto.RegisterType((*GetJoinTokenResp)(nil), "rtc.GetJoinTokenResp") -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// Client API for RtcService service - -type RtcServiceClient interface { - GetJoinToken(ctx context.Context, in *GetJoinTokenReq, opts ...grpc.CallOption) (*GetJoinTokenResp, error) -} - -type rtcServiceClient struct { - cc *grpc.ClientConn -} - -func NewRtcServiceClient(cc *grpc.ClientConn) RtcServiceClient { - return &rtcServiceClient{cc} -} - -func (c *rtcServiceClient) GetJoinToken(ctx context.Context, in *GetJoinTokenReq, opts ...grpc.CallOption) (*GetJoinTokenResp, error) { - out := new(GetJoinTokenResp) - err := grpc.Invoke(ctx, "/rtc.RtcService/GetJoinToken", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for RtcService service - -type RtcServiceServer interface { - GetJoinToken(context.Context, *GetJoinTokenReq) (*GetJoinTokenResp, error) -} - -func RegisterRtcServiceServer(s *grpc.Server, srv RtcServiceServer) { - s.RegisterService(&_RtcService_serviceDesc, srv) -} - -func _RtcService_GetJoinToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetJoinTokenReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RtcServiceServer).GetJoinToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/rtc.RtcService/GetJoinToken", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RtcServiceServer).GetJoinToken(ctx, req.(*GetJoinTokenReq)) - } - return interceptor(ctx, in, info, handler) -} - -var _RtcService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "rtc.RtcService", - HandlerType: (*RtcServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetJoinToken", - Handler: _RtcService_GetJoinToken_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "rtc/rtc.proto", -} - -func init() { proto.RegisterFile("rtc/rtc.proto", fileDescriptor_rtc_058fd4200139f42f) } - -var fileDescriptor_rtc_058fd4200139f42f = []byte{ - // 343 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x6b, 0xdb, 0x40, - 0x10, 0xc5, 0x51, 0xfd, 0xa7, 0xd6, 0xa8, 0xc5, 0x66, 0x69, 0x8b, 0x30, 0x3d, 0xa8, 0x3e, 0x14, - 0x9f, 0x24, 0x70, 0x8f, 0x86, 0x1e, 0x6c, 0x43, 0x71, 0x83, 0x49, 0x58, 0x27, 0x97, 0x5c, 0xc4, - 0x66, 0x3d, 0x98, 0x8d, 0x91, 0x76, 0x33, 0xbb, 0xd8, 0xf8, 0xc3, 0xe6, 0xbb, 0x04, 0x6d, 0x64, - 0x5b, 0x09, 0xb9, 0xcd, 0xfb, 0xed, 0xec, 0x0c, 0xef, 0x0d, 0x7c, 0x25, 0x27, 0x33, 0x72, 0x32, - 0x35, 0xa4, 0x9d, 0x66, 0x2d, 0x72, 0x72, 0xf8, 0xeb, 0xda, 0x60, 0x99, 0x2f, 0x57, 0x99, 0xd9, - 0x6d, 0x33, 0xcf, 0x33, 0xbb, 0xd9, 0xe5, 0x07, 0x9b, 0x1d, 0xec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0x4e, 0x96, 0x00, 0xdc, 0xc9, 0x35, 0xd2, 0x5e, 0x49, 0x64, 0x53, 0xf8, 0xd2, 0x5c, - 0xc2, 0xbe, 0xf9, 0x61, 0xef, 0x62, 0x1d, 0x7e, 0xff, 0x80, 0x5a, 0x33, 0x8b, 0xee, 0xc3, 0xb4, - 0x3a, 0xfc, 0x94, 0x9c, 0x7c, 0xe8, 0xfa, 0xab, 0xfe, 0x79, 0x09, 0x00, 0x00, 0xff, 0xff, 0x1a, - 0x27, 0x45, 0x90, 0x0e, 0x02, 0x00, 0x00, -} diff --git a/pkg/proto/rtc/rtc.proto b/pkg/proto/rtc/rtc.proto deleted file mode 100644 index f27a0b721..000000000 --- a/pkg/proto/rtc/rtc.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; -import "Open_IM/pkg/proto/sdk_ws/ws.proto"; -option go_package = "./rtc;rtc"; -package rtc; - -message CommonResp{ - int32 errCode = 1; - string errMsg = 2; -} - -message GetJoinTokenReq{ - string apiKey = 1; - string apiSecret = 2; - string room = 3; - string identity = 4; - server_api_params.ParticipantMetaData metaData = 5; - string operationID = 6; -} - -message GetJoinTokenResp{ - CommonResp CommonResp = 1; - string jwt = 2; -} - -service RtcService { - rpc GetJoinToken(GetJoinTokenReq) returns(GetJoinTokenResp); -}