mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-07-13 00:21:10 +08:00
add friend
This commit is contained in:
parent
1cc382c728
commit
f0e41367c1
@ -15,14 +15,10 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/openimsdk/protocol/relation"
|
"github.com/openimsdk/protocol/relation"
|
||||||
"github.com/openimsdk/tools/apiresp"
|
|
||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FriendApi struct {
|
type FriendApi struct {
|
||||||
@ -128,24 +124,5 @@ func (o *FriendApi) GetPinnedFriendIDs(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) AddOnewayFriend(c *gin.Context) {
|
func (o *FriendApi) AddOnewayFriend(c *gin.Context) {
|
||||||
// Current generated relation grpc client may not include AddOnewayFriend yet.
|
a2r.Call(c, relation.FriendClient.AddOnewayFriend, o.Client)
|
||||||
// Keep API route compile-safe and return a clear error instead of breaking build.
|
|
||||||
client, ok := any(o.Client).(interface {
|
|
||||||
AddOnewayFriend(ctx context.Context, in *relation.ApplyToAddFriendReq, opts ...grpc.CallOption) (*relation.ApplyToAddFriendResp, error)
|
|
||||||
})
|
|
||||||
if !ok {
|
|
||||||
apiresp.GinError(c, errs.New("add_oneway_friend rpc is not generated in relation_grpc.pb.go"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var req relation.ApplyToAddFriendReq
|
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, err := client.AddOnewayFriend(c, &req)
|
|
||||||
if err != nil {
|
|
||||||
apiresp.GinError(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
apiresp.GinSuccess(c, resp)
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
protocol
2
protocol
@ -1 +1 @@
|
|||||||
Subproject commit ed16bd0c4049d722e7b605c3f314ee661b9bc4e1
|
Subproject commit 90aae1d576466a1fa55eba386d1f7a38ca6062d0
|
||||||
Loading…
x
Reference in New Issue
Block a user