-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package api | ||
|
||
import ( | ||
aesKey "github.com/OpenIMSDK/protocol/aeskey" | ||
Check failure on line 4 in internal/api/aesKey.go GitHub Actions / Build OpenIM Docker Image
|
||
"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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) | ||
} |