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.
Open-IM-Server/internal/api/conversation.go

68 lines
2.0 KiB

2 years ago
package api
import (
"context"
2 years ago
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
2 years ago
"github.com/gin-gonic/gin"
"google.golang.org/grpc"
2 years ago
)
1 year ago
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
1 year ago
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
// if err != nil {
// panic(err)
// }
return &Conversation{discov: discov}
2 years ago
}
type Conversation struct {
1 year ago
conn *grpc.ClientConn
discov discoveryregistry.SvcDiscoveryRegistry
2 years ago
}
2 years ago
func (o *Conversation) client(ctx context.Context) (conversation.ConversationClient, error) {
1 year ago
c, err := o.discov.GetConn(ctx, config.Config.RpcRegisterName.OpenImConversationName)
if err != nil {
return nil, err
}
return conversation.NewConversationClient(c), nil
2 years ago
}
func (o *Conversation) GetAllConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetAllConversations, o.client, c)
}
func (o *Conversation) GetConversation(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetConversation, o.client, c)
}
func (o *Conversation) GetConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.GetConversations, o.client, c)
}
2 years ago
// deprecated
2 years ago
func (o *Conversation) SetConversation(c *gin.Context) {
a2r.Call(conversation.ConversationClient.SetConversation, o.client, c)
}
2 years ago
// deprecated
2 years ago
func (o *Conversation) BatchSetConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.client, c)
}
func (o *Conversation) SetRecvMsgOpt(c *gin.Context) {
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.client, c)
}
func (o *Conversation) ModifyConversationField(c *gin.Context) {
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.client, c)
}
2 years ago
2 years ago
func (o *Conversation) SetConversations(c *gin.Context) {
a2r.Call(conversation.ConversationClient.SetConversations, o.client, c)
}