diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/DeleteRemoteFileService.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/DeleteRemoteFileService.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/DeleteRemoteFileService.java new file mode 100644 index 00000000..57f408cc --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/DeleteRemoteFileService.java @@ -0,0 +1,30 @@ +package de.thedevstack.conversationsplus.services.filetransfer.http; + +import de.thedevstack.conversationsplus.entities.Account; +import de.thedevstack.conversationsplus.entities.Message; +import de.thedevstack.conversationsplus.utils.XmppSendUtil; +import de.thedevstack.conversationsplus.xmpp.filetransfer.http.FileTransferHttp; +import de.thedevstack.conversationsplus.xmpp.filetransfer.http.FileTransferHttpDeleteSlotRequestPacketGenerator; +import de.thedevstack.conversationsplus.xmpp.jid.Jid; +import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; + +/** + * Created by steckbrief on 21.08.2016. + */ +public class DeleteRemoteFileService { + public void deleteRemoteFile(Message message) { + if (message.isHttpUploaded()) { + String path = message.getBody(); + if (message.hasFileOnRemoteHost()) { + path = message.getFileParams().url.toString(); + } + + DeleteRemoteFile remoteFile = new DeleteRemoteFile(path, message); + Account account = message.getConversation().getAccount(); + Jid host = account.getXmppConnection().findDiscoItemByFeature(FileTransferHttp.NAMESPACE); + IqPacket request = FileTransferHttpDeleteSlotRequestPacketGenerator.generate(host, path); + + XmppSendUtil.sendIqPacket(account, request, new DeleteTokenReceived(remoteFile)); + } + } +} |