-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getting consecutive storage info
The issue is that OC_Helper is using Filesystem internally and Filesystem, will only use the same View for each users, so we were basically only calculating the size once when processing multiple users. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
- Loading branch information
1 parent
bed70d1
commit 7e4f22e
Showing
8 changed files
with
245 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* @copyright Copyright 2021 Carl Schwan <carl@carlschwan.eu> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\MonthlyStatusEmail\Command; | ||
|
||
use OCP\IUserManager; | ||
use OCP\IUser; | ||
use OC\Core\Command\Base; | ||
use OCA\MonthlyStatusEmail\Service\MailSender; | ||
use OCA\MonthlyStatusEmail\Service\NotificationTrackerService; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class SendAllMail extends Base { | ||
/** @var IUserManager $userManager */ | ||
private $userManager; | ||
/** @var NotificationTrackerService */ | ||
private $service; | ||
/** @var MailSender */ | ||
private $mailSender; | ||
|
||
public function __construct( | ||
NotificationTrackerService $service, | ||
IUserManager $userManager, | ||
MailSender $mailSender | ||
) { | ||
parent::__construct(); | ||
$this->userManager = $userManager; | ||
$this->service = $service; | ||
$this->mailSender = $mailSender; | ||
} | ||
|
||
protected function configure() { | ||
$this | ||
->setName('monthly_status_email:send-all') | ||
->setDescription('Send the notification mail to all users'); | ||
parent::configure(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$this->userManager->callForSeenUsers(function (IUser $user) use ($output) { | ||
$trackedNotification = $this->service->find($user->getUID()); | ||
|
||
$to = $user->getEMailAddress(); | ||
if ($to === null) { | ||
// We don't have any email address, not sure what to do here. | ||
$output->writeln('<error>User doesn\'t have an email address</error>'); | ||
return; | ||
} | ||
$ret = $this->mailSender->sendMonthlyMailTo($trackedNotification); | ||
if ($ret) { | ||
$output->writeln('Email sent to ' . ($user->getDisplayName() ?? $user->getUID())); | ||
} else { | ||
$output->writeln('Failure sending email to ' . $user->getDisplayName()); | ||
} | ||
}); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace { | ||
use OCP\IServerContainer; | ||
|
||
class OC { | ||
static $CLI = false; | ||
/** @var IServerContainer */ | ||
static $server; | ||
} | ||
} | ||
|
||
namespace OC\Files\Node { | ||
use OCP\Files\FileInfo; | ||
abstract class Node implements \OCP\Files\Node { | ||
/** @return FileInfo|\ArrayAccess */ | ||
public function getFileInfo() {} | ||
|
||
/** @return \OCP\Files\Mount\IMountPoint */ | ||
public function getMountPoint() {} | ||
} | ||
} | ||
|
||
namespace OC\Hooks { | ||
class Emitter { | ||
public function emit(string $class, string $value, array $option) {} | ||
/** Closure $closure */ | ||
public function listen(string $class, string $value, $closure) {} | ||
} | ||
class BasicEmitter extends Emitter { | ||
} | ||
} | ||
|
||
namespace OC\Core\Command { | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
class Base { | ||
public const OUTPUT_FORMAT_PLAIN = 'plain'; | ||
public const OUTPUT_FORMAT_JSON = 'json'; | ||
public const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty'; | ||
|
||
public function __construct() {} | ||
protected function configure() {} | ||
public function run(InputInterface $input, OutputInterface $output) {} | ||
public function setName(string $name) {} | ||
public function getHelper(string $name) {} | ||
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = ' - ') { | ||
} | ||
} | ||
} | ||
|
||
namespace OC\Files\ObjectStore { | ||
class NoopScanner {} | ||
} | ||
|
||
namespace Symfony\Component\Console\Helper { | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
class Table { | ||
public function __construct(OutputInterface $text) {} | ||
public function setHeaders(array $header) {} | ||
public function setRows(array $rows) {} | ||
public function render() {} | ||
} | ||
} | ||
|
||
namespace Symfony\Component\Console\Input { | ||
class InputInterface { | ||
public function getOption(string $key) {} | ||
public function getArgument(string $key) {} | ||
} | ||
class InputArgument { | ||
const REQUIRED = 0; | ||
const OPTIONAL = 1; | ||
const IS_ARRAY = 1; | ||
} | ||
class InputOption { | ||
const VALUE_NONE = 1; | ||
const VALUE_REQUIRED = 1; | ||
} | ||
} | ||
|
||
namespace Symfony\Component\Console\Question { | ||
class ConfirmationQuestion { | ||
public function __construct(string $text, bool $default) {} | ||
} | ||
} | ||
|
||
namespace Symfony\Component\Console\Output { | ||
class OutputInterface { | ||
public const VERBOSITY_VERBOSE = 1; | ||
public function writeln(string $text, int $flat = 0) {} | ||
} | ||
} | ||
|
||
namespace OC\Files { | ||
class View { | ||
public function __construct(string $path) {} | ||
public function unlink($path) {} | ||
public function getDirectoryContent($path) {} | ||
} | ||
} |