...
 
Commits (6)
......@@ -38,10 +38,10 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
switch ($entity->subtype) {
case "video":
Helpers\Counters::increment($pages[0], 'plays');
// Helpers\Counters::increment($pages[0], 'plays');
if (isset($pages[1]) && $pages[1] == 'play') {
http_response_code(301);
http_response_code(302);
if ($entity->subtype == 'audio') {
\forward($entity->getSourceUrl('128.mp3'));
......
......@@ -5,22 +5,23 @@ namespace Minds\Controllers\api\v2\subscriptions;
use Minds\Api\Factory;
use Minds\Core\Di\Di;
use Minds\Core\Session;
use Minds\Core\Subscriptions\Requests\Manager;
use Minds\Interfaces;
/**
* Incoming subscritions
* Incoming subscriptions
*/
class incoming implements Interfaces\Api
{
public function get($pages): bool
{
if (!isset($pages[0])) {
if (isset($pages[0])) {
return $this->getSingle($pages[0]);
} else {
return $this->getList($pages[0]);
return $this->getList();
}
}
/**
* Return a single request
* @param string $subscriberGuid
......@@ -29,11 +30,12 @@ class incoming implements Interfaces\Api
private function getSingle(string $subscriberGuid): bool
{
// Return a single request
/** @var Manager $manager */
$manager = Di::_()->get('Subscriptions\Requests\Manager');
// Construct URN on the fly
$urn = "urn:subscription-request:" . implode('-', [ Session::getLoggedInUserGuid(), $subscriberGuid ]);
$request = $manager->get($urn);
if (!$request || $request->getPublisherGuid() != Session::getLoggedInUserGuid()) {
......@@ -55,10 +57,11 @@ class incoming implements Interfaces\Api
private function getList(): bool
{
// Return a list of subscription requests
/** @var Manager $manager */
$manager = Di::_()->get('Subscriptions\Requests\Manager');
$requests = $manager->getIncomingList(Session::getLoggedInUserGuid(), []);
return Factory::response([
'requests' => Factory::exportable($requests),
'next' => $requests->getPagingToken(),
......@@ -74,14 +77,15 @@ class incoming implements Interfaces\Api
public function put($pages)
{
// Accept / Deny
/** @var Manager $manager */
$manager = Di::_()->get('Subscriptions\Requests\Manager');
// Construct URN on the fly
$subscriberGuid = $pages[0];
$urn = "urn:subscription-request:" . implode('-', [ Session::getLoggedInUserGuid(), $subscriberGuid ]);
$request = $manager->get($urn);
if (!$request || $request->getPublisherGuid() != Session::getLoggedInUserGuid()) {
return Factory::response([
'status' => 'error',
......
......@@ -97,7 +97,7 @@ class PropagateProperties
{
$this->changed = false;
$attachment = $this->entitiesBuilder->single($activity->get('entity_guid'));
if ($attachment === false) {
if (empty($attachment)) {
return;
}
......
......@@ -55,7 +55,15 @@ abstract class Properties
}
if ($this->actsOnType === [] || in_array($entity->getType(), $this->actsOnType, true)) {
return $this->actsOnSubtype === [] || in_array($entity->getSubtype(), $this->actsOnSubtype, true);
if ($this->actsOnSubtype === []) {
return true;
}
if (!is_callable([$entity, 'getSubtype'], true)) {
return false;
}
return in_array($entity->getSubtype(), $this->actsOnSubtype, true);
}
return false;
......
......@@ -45,7 +45,7 @@ class Manager
'hydrate' => true,
], $opts);
$opts['publisher_guid'] = $user_guid;
$opts['publisher_guid'] = $userGuid;
$response = $this->repository->getList($opts);
if ($opts['hydrate']) {
......@@ -109,7 +109,7 @@ class Manager
if ($existing->isDeclined()) {
throw new SubscriptionRequestAlreadyCompletedException();
}
$this->repository->delete($subscriptionRequest);
$this->notificationsDelegate->onAccept($subscriptionRequest);
......