Merge branch 'refs/heads/feature-im'
This commit is contained in:
commit
bb901e8f40
|
|
@ -80,7 +80,7 @@ func GetMsgGroupByIndex(group_id, index int) ([]GroupMessage, error) {
|
|||
|
||||
func GetGroupRequestUsers(user_id int) []FriendRequest {
|
||||
var users []FriendRequest
|
||||
DB.Debug().Raw("select id,im_id,name,email FROM (SELECT im_id,from_user_id,group_id FROM (( SELECT id as im_id,from_user_id,group_id FROM messages WHERE type=? and status=? ) as m JOIN groups as g on g.id=m.group_id ) where g.auth_id=? ) as e JOIN users as u ON e.from_user_id=u.id", proto.MSG_TYPE_GROUP_INVI, 0, user_id).Scan(&users)
|
||||
DB.Debug().Raw("select id,im_id,name,email FROM (SELECT im_id,from_user_id,group_id FROM (( SELECT id as im_id,from_user_id,group_id FROM messages WHERE type=? and status=? ) as m JOIN groups as g on g.id=m.group_id ) where g.auth_id=? ) as e JOIN users as u ON e.from_user_id=u.id", proto.MSG_TYPE_GROUP_ADD, 0, user_id).Scan(&users)
|
||||
return users
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,32 +160,32 @@ func DelFriendOrGroup(c *gin.Context) {
|
|||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
||||
}
|
||||
} else if req.Type == 4 {
|
||||
//群管理员删除群成员
|
||||
if req.GroupID == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed,group_id is null"})
|
||||
return
|
||||
}
|
||||
//获取群
|
||||
group := dao.FindGroupByID(req.GroupID)
|
||||
if len(group) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed group not found"})
|
||||
return
|
||||
}
|
||||
//判断是否是群主
|
||||
if group[0].AuthID != cid {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "no permission", "code": proto.ParameterError, "message": "不是群主"})
|
||||
return
|
||||
}
|
||||
err2 := service.QuitGroupService(req.To_user_id, req.GroupID)
|
||||
if err2 == nil {
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
||||
}
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||
}
|
||||
} else if req.Type == 4 {
|
||||
//群管理员删除群成员
|
||||
if req.GroupID == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed,group_id is null"})
|
||||
return
|
||||
}
|
||||
//获取群
|
||||
group := dao.FindGroupByID(req.GroupID)
|
||||
if len(group) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed group not found"})
|
||||
return
|
||||
}
|
||||
//判断是否是群主
|
||||
if group[0].AuthID != cid {
|
||||
c.JSON(http.StatusOK, gin.H{"error": "no permission", "code": proto.ParameterError, "message": "不是群主"})
|
||||
return
|
||||
}
|
||||
err2 := service.QuitGroupService(req.To_user_id, req.GroupID)
|
||||
if err2 == nil {
|
||||
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success"})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": err2.Error(), "code": proto.OperationFailed, "message": "failed"})
|
||||
}
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"error": err.Error(), "code": proto.ParameterError, "message": "failed"})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue