MCPcopy Create free account
hub / github.com/LockGit/gochat / PushRoom

Function PushRoom

api/handler/push.go:72–101  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

70}
71
72func PushRoom(c *gin.Context) {
73 var formRoom FormRoom
74 if err := c.ShouldBindBodyWith(&formRoom, binding.JSON); err != nil {
75 tools.FailWithMsg(c, err.Error())
76 return
77 }
78 authToken := formRoom.AuthToken
79 msg := formRoom.Msg
80 roomId := formRoom.RoomId
81 checkAuthReq := &proto.CheckAuthRequest{AuthToken: authToken}
82 authCode, fromUserId, fromUserName := rpc.RpcLogicObj.CheckAuth(checkAuthReq)
83 if authCode == tools.CodeFail {
84 tools.FailWithMsg(c, "rpc fail get self info")
85 return
86 }
87 req := &proto.Send{
88 Msg: msg,
89 FromUserId: fromUserId,
90 FromUserName: fromUserName,
91 RoomId: roomId,
92 Op: config.OpRoomSend,
93 }
94 code, msg := rpc.RpcLogicObj.PushRoom(req)
95 if code == tools.CodeFail {
96 tools.FailWithMsg(c, "rpc push room msg fail!")
97 return
98 }
99 tools.SuccessWithMsg(c, "ok", msg)
100 return
101}
102
103type FormCount struct {
104 RoomId int `form:"roomId" json:"roomId" binding:"required"`

Callers

nothing calls this directly

Calls 4

FailWithMsgFunction · 0.92
SuccessWithMsgFunction · 0.92
CheckAuthMethod · 0.45
PushRoomMethod · 0.45

Tested by

no test coverage detected