예제 #1
0
        // messages.search#7e9f2ab peer:InputPeer q:string filter:MessagesFilter min_date:int max_date:int offset:int max_id:int limit:int = messages.Messages;
        // messages.readHistory#eed884c6 peer:InputPeer max_id:int offset:int read_contents:Bool = messages.AffectedHistory;
        // messages.deleteHistory#f4f8fb61 peer:InputPeer offset:int = messages.AffectedHistory;

        // messages.deleteMessages#14f2dd0a id:Vector<int> = Vector<int>;
        public async Task <List <int> > DeleteMessages(List <int> messageIdsToDelete)
        {
            var request = new DeleteMessagesRequest(messageIdsToDelete);

            await SendRpcRequest(request);

            return(request.deletedMessageIds);
        }
        public async Task <IActionResult> Delete(
            [FromBody] DeleteMessagesRequest messagesInfo)
        {
            try
            {
                await messagesService.DeleteMessages(
                    messagesInfo.MessagesId,
                    messagesInfo.ConversationId,
                    ClaimsExtractor.GetUserIdClaim(User.Claims));

                return(Ok(new ResponseApiModel <string>
                {
                    IsSuccessfull = true
                }));
            }
            catch (InvalidDataException ex)
            {
                return(BadRequest(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (UnauthorizedAccessException ex)
            {
                return(StatusCode((int)HttpStatusCode.Forbidden, new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(new ResponseApiModel <bool>
                {
                    IsSuccessfull = false,
                    ErrorMessage = ex.Message
                }));
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseApiModel <bool>
                {
                    IsSuccessfull = false
                }));
            }
        }
예제 #3
0
 public DeleteMessagesRequestHandler(
     Request request,
     ClientConnection clientConnection,
     INodeNoticeService nodeNoticeService,
     IConversationsNoticeService conversationsNoticeService,
     IDeleteMessagesService deleteMessagesService,
     ILoadChatsService loadChatsService,
     IPendingMessagesService pendingMessagesService,
     ILoadChannelsService loadChannelsService,
     ILoadDialogsService loadDialogsService)
 {
     this.request                    = (DeleteMessagesRequest)request;
     this.clientConnection           = clientConnection;
     this.nodeNoticeService          = nodeNoticeService;
     this.conversationsNoticeService = conversationsNoticeService;
     this.deleteMessagesService      = deleteMessagesService;
     this.loadChatsService           = loadChatsService;
     this.pendingMessagesService     = pendingMessagesService;
     this.loadChannelsService        = loadChannelsService;
     this.loadDialogsService         = loadDialogsService;
 }