parent
068c2d4729
commit
aa3169f72c
@ -0,0 +1,22 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
aesKey "github.com/OpenIMSDK/protocol/aeskey"
|
||||
"github.com/OpenIMSDK/tools/a2r"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
||||
)
|
||||
|
||||
type AesKeyApi rpcclient.AesKey
|
||||
|
||||
func NewAesKeyApi(client rpcclient.AesKey) AesKeyApi {
|
||||
return AesKeyApi(client)
|
||||
}
|
||||
|
||||
func (a *AesKeyApi) GetKey(c *gin.Context) {
|
||||
a2r.Call(aesKey.AesKeyClient.AcquireAesKey, a.Client, c)
|
||||
}
|
||||
|
||||
func (a *AesKeyApi) GetKeys(c *gin.Context) {
|
||||
a2r.Call(aesKey.AesKeyClient.AcquireAesKeys, a.Client, c)
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package rpcclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
aesKey "github.com/OpenIMSDK/protocol/aeskey"
|
||||
"github.com/OpenIMSDK/tools/discoveryregistry"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type AesKey struct {
|
||||
conn grpc.ClientConnInterface
|
||||
Client aesKey.AesKeyClient
|
||||
Discov discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func NewAesKey(discov discoveryregistry.SvcDiscoveryRegistry) *AesKey {
|
||||
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAesKeyName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
client := aesKey.NewAesKeyClient(conn)
|
||||
return &AesKey{Discov: discov, Client: client, conn: conn}
|
||||
}
|
||||
|
||||
type AesKeyRpcClient AesKey
|
||||
|
||||
func NewAesKeyRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) AesKeyRpcClient {
|
||||
return AesKeyRpcClient(*NewAesKey(discov))
|
||||
}
|
||||
|
||||
func (a *AesKeyRpcClient) AcquireAesKey(ctx context.Context, conversationType int32, userID, friendUserID, groupID string) (*aesKey.AcquireAesKeyResp, error) {
|
||||
return a.Client.AcquireAesKey(ctx, &aesKey.AcquireAesKeyReq{ConversationType: conversationType, OwnerUserID: userID, FriendUserID: friendUserID, GroupID: groupID})
|
||||
}
|
||||
|
||||
func (a *AesKeyRpcClient) AcquireAesKeys(ctx context.Context, userID string) (*aesKey.AcquireAesKeysResp, error) {
|
||||
return a.Client.AcquireAesKeys(ctx, &aesKey.AcquireAesKeysReq{UserID: userID})
|
||||
}
|
Loading…
Reference in new issue