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.
47 lines
1.4 KiB
47 lines
1.4 KiB
2 years ago
|
package check
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
2 years ago
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||
|
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||
|
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||
2 years ago
|
"google.golang.org/grpc"
|
||
2 years ago
|
)
|
||
|
|
||
|
type ConversationChecker struct {
|
||
|
zk discoveryRegistry.SvcDiscoveryRegistry
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewConversationChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *ConversationChecker {
|
||
|
return &ConversationChecker{zk: zk}
|
||
|
}
|
||
|
|
||
2 years ago
|
func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
|
||
2 years ago
|
cc, err := c.getConn()
|
||
|
if err != nil {
|
||
2 years ago
|
return err
|
||
2 years ago
|
}
|
||
2 years ago
|
_, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req)
|
||
|
return err
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) {
|
||
|
return c.zk.GetConn(config.Config.RpcRegisterName.OpenImConversationName)
|
||
|
}
|
||
2 years ago
|
|
||
|
func (c *ConversationChecker) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||
2 years ago
|
cc, err := c.getConn()
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
var req conversation.GetConversationReq
|
||
|
req.OwnerUserID = userID
|
||
|
req.ConversationID = conversationID
|
||
|
sConversation, err := conversation.NewConversationClient(cc).GetConversation(ctx, &req)
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
return sConversation.GetConversation().RecvMsgOpt, err
|
||
2 years ago
|
}
|