public function deleteByConvAndFileID(Attachment $file) { $sql = <<<SQL \t\t\t\tDELETE \t\t\t\tFROM \t\t\t\t\t`*PREFIX*chat_attachments` \t\t\t\tWHERE \t\t\t\t\t`conv_id` = ? \t\t\t\tAND \t\t\t\t\t`file_id`= ? SQL; $this->execute($sql, array($file->getConvId(), $file->getFileId())); }
public function execute() { $fileId = $this->app->getFileId($this->requestData['path']); $file = new Attachment(); $file->setConvId($this->requestData['conv_id']); $file->setFileId($fileId); $this->attachmentMapper->deleteByConvAndFileID($file); $this->sendPushMessage($this->requestData['path']); $users = $this->userMapper->findUsersInConv($this->requestData['conv_id']); foreach ($users as $user) { if ($user !== $this->app->getUserId()) { $this->unShare($fileId, $user); } } }
/** * Inserts the attachment into the DB * @param $ownerId ownCloud user id * @param $path path of the file * @param $fileId * @param $timestamp * @param $convId */ private function insertInDatabase($ownerId, $path, $fileId, $timestamp, $convId) { $attachment = new Attachment(); $attachment->setOwner($ownerId); $attachment->setPath($path); $attachment->setFileId($fileId); $attachment->setTimestamp($timestamp); $attachment->setConvId($convId); $this->attachmentMapper->insertUnique($attachment); }