...
 
Commits (4)
......@@ -141,6 +141,7 @@ class blog implements Interfaces\Api
!$blog ||
Helpers\Flags::shouldFail($blog) ||
!Core\Security\ACL::_()->read($blog)
|| ($blog->getTimeCreated() > time() && !$blog->canEdit())
) {
break;
}
......@@ -245,13 +246,6 @@ class blog implements Interfaces\Api
}
}
if (!$blog->isPublished()) {
$blog->setAccessId(Access::UNLISTED);
$blog->setDraftAccessId($_POST['access_id']);
} elseif ($blog->getTimePublished() == '') {
$blog->setTimePublished(time());
}
$blog->setLastSave(time());
if (isset($_POST['wire_threshold'])) {
......@@ -298,6 +292,31 @@ class blog implements Interfaces\Api
}
}
if (isset($_POST['time_created'])) {
try {
$timeCreatedDelegate = new Core\Blogs\Delegates\TimeCreatedDelegate();
if ($editing) {
$timeCreatedDelegate->onUpdate($blog, $_POST['time_created'], time());
} else {
$timeCreatedDelegate->onAdd($blog, $_POST['time_created'], time());
}
} catch (\Exception $e) {
return Factory::response([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
if (!$blog->isPublished()) {
$blog->setAccessId(Access::UNLISTED);
$blog->setDraftAccessId($_POST['access_id']);
} elseif ($blog->getTimePublished() == '') {
$blog->setTimePublished($blog->getTimeCreated() ?: time());
}
if (!$blog->canEdit()) {
return Factory::response([
'status' => 'error',
......
......@@ -516,6 +516,18 @@ class newsfeed implements Interfaces\Api
$attachmentPaywallDelegate = new Core\Feeds\Activity\Delegates\AttachmentPaywallDelegate();
$attachmentPaywallDelegate->onUpdate($activity);
if (isset($_POST['time_created']) && ($_POST['time_created'] != $activity->getTimeCreated())) {
try {
$timeCreatedDelegate = new Core\Feeds\Activity\Delegates\TimeCreatedDelegate();
$timeCreatedDelegate->onUpdate($activity, $_POST['time_created'], time());
} catch (\Exception $e) {
return Factory::response([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
$save->setEntity($activity)
->save();
......@@ -529,6 +541,19 @@ class newsfeed implements Interfaces\Api
$activity->setMature(isset($_POST['mature']) && !!$_POST['mature']);
$user = Core\Session::getLoggedInUser();
if (isset($_POST['time_created'])) {
try {
$timeCreatedDelegate = new Core\Feeds\Activity\Delegates\TimeCreatedDelegate();
$timeCreatedDelegate->onAdd($activity, $_POST['time_created'], time());
} catch (\Exception $e) {
return Factory::response([
'status' => 'error',
'message' => $e->getMessage(),
]);
}
}
if ($user->isMature()) {
$activity->setMature(true);
}
......@@ -599,6 +624,8 @@ class newsfeed implements Interfaces\Api
$attachment->setNsfw($activity->getNsfw());
$attachment->set('time_created', $activity->getTimeCreated());
$save->setEntity($attachment)->save();
switch ($attachment->subtype) {
......
<?php
namespace Minds\Controllers\api\v2\feeds;
use Minds\Api\Exportable;
use Minds\Api\Factory;
use Minds\Core;
use Minds\Core\Di\Di;
use Minds\Entities\Factory as EntitiesFactory;
use Minds\Entities\User;
use Minds\Interfaces;
class scheduled implements Interfaces\Api
{
/**
* Equivalent to HTTP GET method
* @param array $pages
* @return mixed|null
* @throws \Exception
*/
public function get($pages)
{
/** @var User $currentUser */
$currentUser = Core\Session::getLoggedinUser();
//
$container_guid = $pages[0] ?? null;
if (!$container_guid) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid container',
]);
}
$container = EntitiesFactory::build($container_guid);
if (!$container || !Core\Security\ACL::_()->read($container, $currentUser)) {
return Factory::response([
'status' => 'error',
'message' => 'Forbidden',
]);
}
$type = '';
switch ($pages[1]) {
case 'activities':
$type = 'activity';
break;
case 'images':
$type = 'object:image';
break;
case 'videos':
$type = 'object:video';
break;
case 'blogs':
$type = 'object:blog';
break;
case 'count':
$type = 'activity';
/** @var Core\Feeds\Scheduled\Manager $manager */
$manager = new Core\Feeds\Scheduled\Manager;
return Factory::response([
'status' => 'success',
'count' => $manager->getScheduledCount(['container_guid' => $container_guid, 'type' => $type])
]);
default:
return Factory::response([
'status' => 'error',
'message' => 'Invalid type',
]);
}
$hardLimit = 5000;
$offset = 0;
if (isset($_GET['offset'])) {
$offset = intval($_GET['offset']);
}
$limit = 12;
if (isset($_GET['limit'])) {
$limit = abs(intval($_GET['limit']));
}
if (($offset + $limit) > $hardLimit) {
$limit = $hardLimit - $offset;
}
if ($limit <= 0) {
return Factory::response([
'status' => 'success',
'entities' => [],
'load-next' => $hardLimit,
'overflow' => true,
]);
}
//
$sync = (bool) ($_GET['sync'] ?? false);
$fromTimestamp = $_GET['from_timestamp'] ?? 0;
$asActivities = (bool) ($_GET['as_activities'] ?? true);
$forcePublic = (bool) ($_GET['force_public'] ?? false);
$query = null;
if (isset($_GET['query'])) {
$query = $_GET['query'];
}
$custom_type = isset($_GET['custom_type']) && $_GET['custom_type'] ? [$_GET['custom_type']] : null;
/** @var Core\Feeds\Top\Manager $manager */
$manager = Di::_()->get('Feeds\Top\Manager');
/** @var Core\Feeds\Top\Entities $entities */
$entities = new Core\Feeds\Top\Entities();
$entities->setActor($currentUser);
$isOwner = false;
if ($currentUser) {
$entities->setActor($currentUser);
$isOwner = $currentUser->guid == $container_guid;
}
$opts = [
'cache_key' => $currentUser ? $currentUser->guid : null,
'container_guid' => $container_guid,
'access_id' => $isOwner && !$forcePublic ? [0, 1, 2, $container_guid] : [2, $container_guid],
'custom_type' => $custom_type,
'limit' => $limit,
'type' => $type,
'algorithm' => 'latest',
'period' => '1y',
'sync' => $sync,
'from_timestamp' => $fromTimestamp,
'query' => $query,
'single_owner_threshold' => 0,
'pinned_guids' => $type === 'activity' ? array_reverse($container->getPinnedPosts()) : null,
'time_created_upper' => false,
];
if (isset($_GET['nsfw'])) {
$nsfw = $_GET['nsfw'] ?? '';
$opts['nsfw'] = explode(',', $nsfw);
}
try {
$result = $manager->getList($opts);
if (!$sync) {
// Remove all unlisted content, if ES document is not in sync, it'll
// also remove pending activities
$result = $result->filter([$entities, 'filter']);
if ($asActivities) {
// Cast to ephemeral Activity entities, if another type
$result = $result->map([$entities, 'cast']);
}
}
return Factory::response([
'status' => 'success',
'entities' => Exportable::_($result),
'load-next' => $result->getPagingToken(),
]);
} catch (\Exception $e) {
error_log($e);
return Factory::response(['status' => 'error', 'message' => $e->getMessage()]);
}
}
public function post($pages)
{
return Factory::response([]);
}
public function put($pages)
{
return Factory::response([]);
}
public function delete($pages)
{
return Factory::response([]);
}
}
......@@ -95,6 +95,8 @@ use Minds\Traits\MagicAttributes;
* @method int getTimeModerated()
* @method Blog setAllowComments(bool $allowComments)
* @method bool getAllowComments()
* @method int getTimeSent()
* @method Blog setTimeSent(int $time_sent)
*/
class Blog extends RepositoryEntity
{
......@@ -240,6 +242,9 @@ class Blog extends RepositoryEntity
/** @var bool */
protected $allowComments = true;
/** @var int */
protected $timeSent;
/**
* Blog constructor.
* @param null $eventsDispatcher
......@@ -582,6 +587,7 @@ class Blog extends RepositoryEntity
'nsfw',
'nsfw_lock',
'allow_comments',
'time_sent',
function ($export) {
return $this->_extendExport($export);
}
......@@ -609,6 +615,7 @@ class Blog extends RepositoryEntity
$output['nsfw'] = $this->getNsfw();
$output['nsfw_lock'] = $this->getNsfwLock();
$output['allow_comments'] = $this->getAllowComments();
$output['time_sent'] = $this->getTimeSent();
$output['header_bg'] = $export['has_header_bg'];
if (!$this->isEphemeral()) {
......
......@@ -41,7 +41,14 @@ class CreateActivity
{
$activities = $this->db->getRow("activity:entitylink:{$blog->getGuid()}");
if (!empty($activities)) {
return false;
foreach ($activities as $guid) {
$activity = new Activity($guid);
$activity->setTimeCreated($blog->getTimeCreated());
$this->saveAction
->setEntity($activity)
->save();
}
return true;
}
$owner = $blog->getOwnerEntity();
......@@ -60,6 +67,7 @@ class CreateActivity
$activity->container_guid = $owner->guid;
$activity->owner_guid = $owner->guid;
$activity->ownerObj = $owner->export();
$activity->setTimeCreated($blog->getTimeCreated());
$this->saveAction
->setEntity($activity)
......
<?php
/**
* TimeCreatedDelegate
* @author juanmsolaro
*/
namespace Minds\Core\Blogs\Delegates;
use Minds\Core\Feeds\Scheduled\EntityTimeCreated;
class TimeCreatedDelegate
{
/** @var Core\Feeds\Scheduled\EntityTimeCreated $entityTimeCreated */
protected $entityTimeCreated;
/**
* TimeCreatedDelegate constructor.
* @param Save $save
*/
public function __construct()
{
$this->entityTimeCreated = new EntityTimeCreated();
}
/**
* Validates time_created date and sets it to activity
* @param $entity
* @param string $time_created
* @return bool
*/
public function onAdd($entity, $time_created, $time_sent)
{
$this->entityTimeCreated->validate($entity, $time_created, $time_sent);
return true;
}
/**
* Validates time_created date and set it to activity
* @param $entity
* @param string $time_created
* @return bool
*/
public function onUpdate($entity, $time_created, $time_sent)
{
$this->entityTimeCreated->validate($entity, $time_created, $time_sent);
return true;
}
}
......@@ -52,6 +52,7 @@ class Entity
'moderatorGuid' => 'moderator_guid',
'timeModerated' => 'time_moderated',
'allowComments' => 'allow_comments',
'timeSent' => 'time_sent'
];
public static $jsonEncodedFields = [
......
......@@ -114,7 +114,7 @@ class Manager
}
$blog
->setTimeCreated(time())
->setTimeCreated($blog->getTimeCreated() ?: time())
->setTimeUpdated(time())
->setLastUpdated(time())
->setLastSave(time());
......
<?php
/**
* ResolverDelegate.
*
* @author juanmsolaro
*/
namespace Minds\Core\Entities\Delegates;
use Minds\Core\Security\ACL;
use Minds\Entities\User;
class FilterEntitiesDelegate
{
/** @var ACL */
protected $acl;
/** @var User */
protected $user;
/** @var int */
protected $time;
public function __construct($user, $time, $acl = null)
{
$this->acl = $acl ?: ACL::_();
$this->user = $user;
$this->time = $time;
}
/**
* Filter entities by read rights and write rights for scheduled activities, images, videos or blogs
* @param array $entities
* @return array
*/
public function filter($entities)
{
return array_values(array_filter($entities, function ($entity) {
$filterByScheduled = false;
if ($this->shouldFilterScheduled($entity->getType())) {
$filterByScheduled = $entity->getTimeCreated() > $this->time
&& !ACL::_()->write($entity, $this->user);
}
return !$filterByScheduled && $this->acl->read($entity, $this->user);
}));
}
private function shouldFilterScheduled($type)
{
return $type == 'activity'
|| $type == 'blog'
|| $type == 'video'
|| $type == 'image';
}
}
......@@ -12,6 +12,7 @@ use Minds\Core\Entities\Delegates\BoostGuidResolverDelegate;
use Minds\Core\Entities\Delegates\CommentGuidResolverDelegate;
use Minds\Core\Entities\Delegates\EntityGuidResolverDelegate;
use Minds\Core\Entities\Delegates\ResolverDelegate;
use Minds\Core\Entities\Delegates\FilterEntitiesDelegate;
use Minds\Core\Security\ACL;
use Minds\Entities\User;
......@@ -128,11 +129,8 @@ class Resolver
});
// Filter out forbidden entities
$sorted = array_filter($sorted, function ($entity) {
return $this->acl->read($entity, $this->user);
//&& !Flags::shouldFail($entity);
});
$filterDelegate = new FilterEntitiesDelegate($this->user, time(), $this->acl);
$sorted = $filterDelegate->filter($sorted);
//
......
<?php
/**
* TimeCreatedDelegate
* @author juanmsolaro
*/
namespace Minds\Core\Feeds\Activity\Delegates;
use Minds\Core\Feeds\Scheduled\EntityTimeCreated;
class TimeCreatedDelegate
{
/** @var Core\Feeds\Scheduled\EntityTimeCreated $entityTimeCreated */
protected $entityTimeCreated;
/**
* TimeCreatedDelegate constructor.
* @param Save $save
*/
public function __construct()
{
$this->entityTimeCreated = new EntityTimeCreated();
}
/**
* Validates time_created date and set it to activity
* @param $entity
* @param string $time_created
* @return bool
*/
public function onAdd($entity, $time_created, $time_sent)
{
$this->entityTimeCreated->validate($entity, $time_created, $time_sent);
return true;
}
/**
* Validates time_created date and set it to activity
* @param $entity
* @param string $time_created
* @return bool
*/
public function onUpdate($entity, $time_created, $time_sent)
{
$this->entityTimeCreated->validate($entity, $time_created, $time_sent);
return true;
}
}
<?php
namespace Minds\Core\Feeds\Scheduled;
class EntityTimeCreated
{
/**
* EntityTimeCreated constructor.
*
*/
public function __construct()
{
}
public function validate($entity, $time_created, $time_sent)
{
if ($time_created > strtotime('+3 Months')) {
throw new \InvalidParameterException();
}
if ($time_created < strtotime('+5 Minutes')) {
$time_created = $time_sent;
}
$entity->setTimeCreated($time_created);
$entity->setTimeSent($time_sent);
}
}
<?php
namespace Minds\Core\Feeds\Scheduled;
class Manager
{
/** @var Repository */
protected $repository;
public function __construct(
$repository = null
) {
$this->repository = $repository ?: new Repository;
}
/**
* @param array $opts
* @return int
*/
public function getScheduledCount(array $opts = [])
{
return $this->repository->getScheduledCount($opts) ;
}
}
<?php
namespace Minds\Core\Feeds\Scheduled;
use Minds\Core\Data\ElasticSearch\Client as ElasticsearchClient;
use Minds\Core\Data\ElasticSearch\Prepared;
use Minds\Core\Di\Di;
use Minds\Helpers\Text;
class Repository
{
/** @var ElasticsearchClient */
protected $client;
protected $index;
public function __construct($client = null, $config = null)
{
$this->client = $client ?: Di::_()->get('Database\ElasticSearch');
$config = $config ?: Di::_()->get('Config');
$this->index = $config->get('elasticsearch')['index'];
}
public function getScheduledCount(array $opts = [])
{
$opts = array_merge([
'container_guid' => null,
'type' => null,
], $opts);
if (!$opts['type']) {
throw new \Exception('Type must be provided');
}
if (!$opts['container_guid']) {
throw new \Exception('Container Guid must be provided');
}
$containerGuids = Text::buildArray($opts['container_guid']);
$query = [
'index' => $this->index,
'type' => $opts['type'],
'body' => [
'query' => [
'bool' => [
'must' => [
[
'range' => [
'@timestamp' => [
'gt' => time() * 1000,
]
]
],
[
'terms' => [
'container_guid' => $containerGuids,
],
]
]
]
]
]
];
$prepared = new Prepared\Count();
$prepared->query($query);
$result = $this->client->request($prepared);
return $result['count'] ?? 0;
}
}
......@@ -53,6 +53,7 @@ class Repository
'exclude_moderated' => false,
'moderation_reservations' => null,
'pinned_guids' => null,
'time_created_upper' => time(),
'exclude' => null,
], $opts);
......@@ -257,6 +258,20 @@ class Repository
];
}
// Filter by time created to cut out scheduled feeds
$time_created_upper = $opts['time_created_upper'] ? 'lte' : 'gt';
if (!isset($body['query']['function_score']['query']['bool']['must'])) {
$body['query']['function_score']['query']['bool']['must'] = [];
}
$body['query']['function_score']['query']['bool']['must'][] = [
'range' => [
'@timestamp' => [
$time_created_upper => ((int) ($opts['time_created_upper'] ?: time())) * 1000,
],
],
];
//
if ($opts['query']) {
$words = explode(' ', $opts['query']);
......
......@@ -43,7 +43,7 @@ class SignedUri
//->setId((string) $uri)
->setExpiration($expires)
->set('uri', (string) $uri)
->set('user_guid', (string) Session::getLoggedInUser()->getGuid())
->set('user_guid', Session::isLoggedIn() ? (string) Session::getLoggedInUser()->getGuid() : null)
->sign(new Sha256, $this->config->get('sessions')['private_key'])
->getToken();
$signedUri = $uri->withQuery("jwtsig=$token");
......
......@@ -40,6 +40,7 @@ class Activity extends Entity
'pending' => false,
'rating' => 2, //open by default
'ephemeral' => false,
'time_sent' => null,
// 'node' => elgg_get_site_url()
]);
}
......@@ -219,6 +220,7 @@ class Activity extends Entity
'ephemeral',
'hide_impressions',
'pinned',
'time_sent',
]);
}
......@@ -275,6 +277,7 @@ class Activity extends Entity
$export['rating'] = $this->getRating();
$export['ephemeral'] = $this->getEphemeral();
$export['ownerObj'] = $this->getOwnerObj();
$export['time_sent'] = $this->getTimeSent();
if ($this->hide_impressions) {
$export['hide_impressions'] = $this->hide_impressions;
......@@ -756,4 +759,23 @@ class Activity extends Entity
{
return "urn:activity:{$this->getGuid()}";
}
/**
* Return time_sent
* @return int
*/
public function getTimeSent()
{
return $this->time_sent;
}
/**
* Set time_sent
* @return Activity
*/
public function setTimeSent($time_sent)
{
$this->time_sent = $time_sent;
return $this;
}
}
......@@ -20,6 +20,7 @@ class Image extends File
$this->attributes['rating'] = 2;
$this->attributes['width'] = 0;
$this->attributes['height'] = 0;
$this->attributes['time_sent'] = null;
}
public function getUrl()
......@@ -193,6 +194,7 @@ class Image extends File
'width',
'height',
'gif',
'time_sent',
]);
}
......@@ -224,6 +226,7 @@ class Image extends File
$export['height'] = $this->height ?: 0;
$export['gif'] = (bool) $this->gif;
$export['urn'] = $this->getUrn();
$export['time_sent'] = $this->getTimeSent();
if (!Helpers\Flags::shouldDiscloseStatus($this) && isset($export['flags']['spam'])) {
unset($export['flags']['spam']);
......@@ -267,6 +270,7 @@ class Image extends File
'access_id' => null,
'container_guid' => null,
'rating' => 2, //open by default
'time_sent' => time(),
], $data);
$allowed = [
......@@ -280,6 +284,7 @@ class Image extends File
'mature',
'boost_rejection_reason',
'rating',
'time_sent',
];
foreach ($allowed as $field) {
......@@ -361,4 +366,23 @@ class Image extends File
{
return "urn:image:{$this->guid}";
}
/**
* Return time_sent
* @return int
*/
public function getTimeSent()
{
return $this->time_sent;
}
/**
* Set time_sent
* @return Image
*/
public function setTimeSent($time_sent)
{
$this->time_sent = $time_sent;
return $this;
}
}
......@@ -24,6 +24,7 @@ class Video extends Object
$this->attributes['subtype'] = "video";
$this->attributes['boost_rejection_reason'] = -1;
$this->attributes['rating'] = 2;
$this->attributes['time_sent'] = null;
}
......@@ -116,7 +117,8 @@ class Video extends Object
'license',
'monetized',
'mature',
'boost_rejection_reason'
'boost_rejection_reason',
'time_sent',
]);
}
......@@ -147,6 +149,7 @@ class Video extends Object
$export['thumbs:down:count'] = Helpers\Counters::get($this->guid, 'thumbs:down');
$export['description'] = (new Core\Security\XSS())->clean($this->description); //videos need to be able to export html.. sanitize soon!
$export['rating'] = $this->getRating();
$export['time_sent'] = $this->getTimeSent();
if (!Helpers\Flags::shouldDiscloseStatus($this) && isset($export['flags']['spam'])) {
unset($export['flags']['spam']);
......@@ -189,6 +192,7 @@ class Video extends Object
'access_id' => null,
'container_guid' => null,
'rating' => 2, //open by default
'time_sent' => time(),
], $data);
$allowed = [
......@@ -201,6 +205,7 @@ class Video extends Object
'mature',
'boost_rejection_reason',
'rating',
'time_sent'
];
foreach ($allowed as $field) {
......@@ -268,4 +273,23 @@ class Video extends Object
{
return "urn:video:{$this->getGuid()}";
}
/**
* Return time_sent
* @return int
*/
public function getTimeSent()
{
return $this->time_sent;
}
/**
* Set time_sent
* @return Image
*/
public function setTimeSent($time_sent)
{
$this->time_sent = $time_sent;
return $this;
}
}
......@@ -80,6 +80,10 @@ class CreateActivitySpec extends ObjectBehavior
->shouldBeCalled()
->willReturn(1000);
$blog->getTimeCreated()
->shouldBeCalled()
->willReturn(9999);
$this->db->getRow("activity:entitylink:9999")
->shouldBeCalled()
->willReturn([]);
......@@ -97,19 +101,31 @@ class CreateActivitySpec extends ObjectBehavior
->shouldReturn(true);
}
public function it_should_not_save_when_previous_activity(
public function it_should_save_when_previous_activity(
Blog $blog
) {
$blog->getGuid()
->shouldBeCalled()
->willReturn(9999);
$blog->getTimeCreated()
->shouldBeCalled()
->willReturn(9999);
$this->db->getRow("activity:entitylink:9999")
->shouldBeCalled()
->willReturn(['activity1']);
$this->saveAction->setEntity(Argument::type(Activity::class))
->shouldBeCalled()
->willReturn($this->saveAction);
$this->saveAction->save()
->shouldBeCalled()
->willReturn(true);
$this
->save($blog)
->shouldReturn(false);
->shouldReturn(true);
}
}
......@@ -153,6 +153,10 @@ class ManagerSpec extends ObjectBehavior
$blog->getSubtype()
->willReturn('blog');
$blog->getTimeCreated()
->shouldBeCalled()
->willReturn(9999);
$blog->setTimeCreated(Argument::type('int'))
->shouldBeCalled()
->willReturn($blog);
......
<?php
namespace Spec\Minds\Core\Feeds\Scheduled;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Feeds\Scheduled\Manager;
use Minds\Core\Feeds\Scheduled\Repository;
use Minds\Core\Search\Search;
use PhpSpec\ObjectBehavior;
class ManagerSpec extends ObjectBehavior
{
/** @var Repository */
protected $repository;
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Search */
protected $search;
public function let(
Repository $repository
) {
$this->repository = $repository;
$this->beConstructedWith($repository);
}
public function it_is_initializable()
{
$this->shouldHaveType(Manager::class);
}
public function it_should_get_scheduled_count()
{
$argument = ['container_guid' => 9999, 'type' => 'activity'];
$this->repository->getScheduledCount($argument)
->shouldBeCalled()
->willReturn(1);
$this->getScheduledCount($argument);
}
}
<?php
namespace Spec\Minds\Core\Feeds\Scheduled;
use Minds\Core\Config;
use Minds\Core\Data\ElasticSearch\Client;
use Minds\Core\Data\ElasticSearch\Prepared\Count;
use Minds\Core\Feeds\Scheduled\Repository;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RepositorySpec extends ObjectBehavior
{
/** @var Client */
protected $client;
/** @var Config */
protected $config;
public function let(Client $client, Config $config)
{
$this->client = $client;
$this->config = $config;
$config->get('elasticsearch')
->shouldBeCalled()
->willReturn(['index' => 'minds']);
$this->beConstructedWith($client, $config);
}
public function it_is_initializable()
{
$this->shouldHaveType(Repository::class);
}
public function it_should_count_scheduled_activities()
{
$opts = ['container_guid' => 9999, 'type' => 'activity'];
$this->client->request(Argument::type(Count::class))
->shouldBeCalled()
->willReturn([
"count" => 1,
"_shards" => [
"total" => 5,
"successful" => 5,
"skipped" => 0,
"failed" => 0
]
]);
$this->getScheduledCount($opts);
}
}