Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Controller/APIv2.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Activity\GroupHelper;
use OCA\Activity\UserSettings;
use OCA\Activity\ViewInfoCache;
use OCP\Activity\IManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
Expand Down Expand Up @@ -67,6 +68,9 @@ class APIv2 extends OCSController {
protected $loadPreviews;


/** @var IManager */
protected $activityManager;

/** @var Data */
protected $data;

Expand Down Expand Up @@ -99,6 +103,7 @@ class APIv2 extends OCSController {
*
* @param string $appName
* @param IRequest $request
* @param IManager $activityManager
* @param Data $data
* @param GroupHelper $helper
* @param UserSettings $settings
Expand All @@ -111,6 +116,7 @@ class APIv2 extends OCSController {
*/
public function __construct($appName,
IRequest $request,
IManager $activityManager,
Data $data,
GroupHelper $helper,
UserSettings $settings,
Expand All @@ -121,6 +127,7 @@ public function __construct($appName,
View $view,
ViewInfoCache $infoCache) {
parent::__construct($appName, $request);
$this->activityManager = $activityManager;
$this->data = $data;
$this->helper = $helper;
$this->settings = $settings;
Expand Down Expand Up @@ -220,6 +227,7 @@ protected function get($filter, $since, $limit, $previews, $filterObjectType, $f
return new DataResponse(null, Http::STATUS_FORBIDDEN);
}

$this->activityManager->setRequirePNG($this->request->isUserAgent([IRequest::USER_AGENT_CLIENT_IOS]));
try {
$response = $this->data->get(
$this->helper,
Expand All @@ -241,6 +249,7 @@ protected function get($filter, $since, $limit, $previews, $filterObjectType, $f
// No activity settings enabled
return new DataResponse(null, Http::STATUS_NO_CONTENT);
}
$this->activityManager->setRequirePNG(false);

$headers = $this->generateHeaders($response['headers'], $response['has_more'], $response['data']);
if (empty($response['data']) || $this->request->getHeader('If-None-Match') === $headers['ETag']) {
Expand Down
2 changes: 2 additions & 0 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
$defaultTimeZone = date_default_timezone_get();

$deleteItemsForUsers = [];
$this->activityManager->setRequirePNG(true);
foreach ($affectedUsers as $user) {
if (empty($userEmails[$user])) {
// The user did not setup an email address
Expand All @@ -181,6 +182,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
// continue;
}
}
$this->activityManager->setRequirePNG(false);

// Delete all entries we dealt with
$this->deleteSentItems($deleteItemsForUsers, $sendTime);
Expand Down
7 changes: 7 additions & 0 deletions tests/Controller/APIv2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use OCA\Activity\Controller\APIv2;
use OCA\Activity\Exception\InvalidFilterException;
use OCA\Activity\Tests\TestCase;
use OCP\Activity\IManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\IUser;
Expand All @@ -51,6 +52,9 @@ class APIv2Test extends TestCase {
/** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
protected $request;

/** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
protected $activityManager;

/** @var \OCA\Activity\Data|\PHPUnit_Framework_MockObject_MockObject */
protected $data;

Expand Down Expand Up @@ -90,6 +94,7 @@ class APIv2Test extends TestCase {
protected function setUp() {
parent::setUp();

$this->activityManager = $this->createMock(IManager::class);
$this->data = $this->createMock(Data::class);
$this->helper = $this->createMock(GroupHelper::class);
$this->userSettings = $this->createMock(UserSettings::class);
Expand Down Expand Up @@ -118,6 +123,7 @@ protected function getController(array $methods = []) {
return new APIv2(
'activity',
$this->request,
$this->activityManager,
$this->data,
$this->helper,
$this->userSettings,
Expand All @@ -133,6 +139,7 @@ protected function getController(array $methods = []) {
->setConstructorArgs([
'activity',
$this->request,
$this->activityManager,
$this->data,
$this->helper,
$this->userSettings,
Expand Down