public override async Task <GetGroupMessagesResponse> GetGroupMessages(GetGroupMessagesRequest request, ServerCallContext context) { DbUserModel dbUserModel = context.UserState["user"] as DbUserModel; if (dbUserModel == null) { return new GetGroupMessagesResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; Room room = await Room.GetRoomFromGuid(request.RoomId); if (room == null) { return new GetGroupMessagesResponse() { Status = ResponseFactory.createResponse(ResponseType.ROOM_DOES_NOT_EXIST) } } ; GroupChat groupChat = await room.GetGroupChatById(request.GroupId); if (groupChat == null) { return new GetGroupMessagesResponse() { Status = ResponseFactory.createResponse(ResponseType.CHAT_GROUP_DOES_NOT_EXIST) } } ; if (!groupChat.IsPlayerInGroup(dbUserModel)) { return new GetGroupMessagesResponse() { Status = ResponseFactory.createResponse(ResponseType.PERMISSION_DENIED) } } ; return(new GetGroupMessagesResponse() { Status = ResponseFactory.createResponse(ResponseType.SUCCESS), Group = await groupChat.asMessageGroup(request.Pagination) }); }