feat: directly add customer service friend
Deploy olons-server production / deploy (push) Successful in 3m26s
Deploy olons-server production / deploy (push) Successful in 3m26s
This commit is contained in:
@@ -107,6 +107,11 @@ type Conversation struct {
|
||||
CanSend bool `json:"can_send"`
|
||||
}
|
||||
|
||||
type DirectFriendResult struct {
|
||||
Relationship string `json:"relationship"`
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
func New(cfg config.IMConfig) *Client {
|
||||
timeout := cfg.Timeout
|
||||
if timeout <= 0 {
|
||||
@@ -229,6 +234,18 @@ func (c *Client) CreateFriendRequest(ctx context.Context, token, userID, idempot
|
||||
return &out, err
|
||||
}
|
||||
|
||||
// AddFriendDirect establishes a trusted server-side friendship without
|
||||
// creating a user-visible friend request. The IM internal API authenticates
|
||||
// this operation with the configured internal secret.
|
||||
func (c *Client) AddFriendDirect(ctx context.Context, userID, peerUserID string) (*DirectFriendResult, error) {
|
||||
var out DirectFriendResult
|
||||
path := "/internal/admin-query/tenants/" + url.PathEscape(c.cfg.TenantCode) + "/friends/direct"
|
||||
err := c.internalJSON(ctx, http.MethodPost, path, map[string]any{
|
||||
"user_id": userID, "peer_user_id": peerUserID,
|
||||
}, &out)
|
||||
return &out, err
|
||||
}
|
||||
|
||||
func (c *Client) EnsureP2P(ctx context.Context, token, userID, idempotencyKey string) (*Conversation, error) {
|
||||
var out Conversation
|
||||
err := c.productJSON(ctx, http.MethodPost, "/conversations/p2p", token, idempotencyKey,
|
||||
|
||||
Reference in New Issue
Block a user