Skip to content
Commits on Source (38)
......@@ -9,6 +9,7 @@ stages:
- prepare
- review
- deploy:staging
- qa
- deploy:canary
- deploy:production
......@@ -22,7 +23,7 @@ build:
stage: build
script:
- apk update && apk add --no-cache git
- sh tools/setup.sh
- sh tools/setup.sh production
cache:
paths:
- vendor
......@@ -127,6 +128,17 @@ review:stop:
- master
- test/gitlab-ci
qa:manual:
stage: qa
script:
- echo "Manually approved"
when: manual
only:
refs:
- master
- test/gitlab-ci
allow_failure: false
staging:fpm:
stage: deploy:staging
image: minds/ci:latest
......
......@@ -119,6 +119,7 @@ class authenticate implements Interfaces\Api, Interfaces\ApiIgnorePam
public function delete($pages)
{
/** @var Core\Sessions\Manager $sessions */
$sessions = Di::_()->get('Sessions\Manager');
if (isset($pages[0]) && $pages[0] === 'all') {
......
......@@ -362,7 +362,7 @@ class blog implements Interfaces\Api
}
if ($saved) {
if ($blog->isPublished() && $blog->getAccessId() == Access::PUBLIC) {
if ($blog->isPublished() && in_array($blog->getAccessId(), [Access::PUBLIC, Access::LOGGED_IN], false)) {
if (!$editing || ($editing && !$alreadyPublished) || ($editing && $oldAccessId == Access::UNLISTED)) {
(new CreateActivity())->save($blog);
}
......
......@@ -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'));
......
......@@ -514,9 +514,6 @@ class newsfeed implements Interfaces\Api
$activity->indexes = ["activity:$activity->owner_guid:edits"]; //don't re-index on edit
(new Core\Translation\Storage())->purge($activity->guid);
$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();
......@@ -532,6 +529,8 @@ class newsfeed implements Interfaces\Api
$save->setEntity($activity)
->save();
(new Core\Entities\PropagateProperties())->from($activity);
$activity->setExportContext(true);
return Factory::response(['guid' => $activity->guid, 'activity' => $activity->export(), 'edited' => true]);
}
......
......@@ -67,46 +67,49 @@ class views implements Interfaces\Api
]);
break;
case 'activity':
$activity = new Entities\Activity($pages[1]);
case 'entity':
$entity = Entities\Factory::build($pages[1]);
if (!$activity->guid) {
if (!$entity) {
return Factory::response([
'status' => 'error',
'message' => 'Could not find activity post'
'message' => 'Could not the entity'
]);
}
try {
Core\Analytics\App::_()
if ($entity->type === 'activity') {
try {
Core\Analytics\App::_()
->setMetric('impression')
->setKey($activity->guid)
->setKey($entity->guid)
->increment();
if ($activity->remind_object) {
Core\Analytics\App::_()
if ($entity->remind_object) {
Core\Analytics\App::_()
->setMetric('impression')
->setKey($activity->remind_object['guid'])
->setKey($entity->remind_object['guid'])
->increment();
Core\Analytics\App::_()
Core\Analytics\App::_()
->setMetric('impression')
->setKey($activity->remind_object['owner_guid'])
->setKey($entity->remind_object['owner_guid'])
->increment();
}
}
Core\Analytics\User::_()
Core\Analytics\User::_()
->setMetric('impression')
->setKey($activity->owner_guid)
->setKey($entity->owner_guid)
->increment();
} catch (\Exception $e) {
error_log($e->getMessage());
} catch (\Exception $e) {
error_log($e->getMessage());
}
}
try {
$viewsManager->record(
(new Core\Analytics\Views\View())
->setEntityUrn($activity->getUrn())
->setOwnerGuid((string) $activity->getOwnerGuid())
->setEntityUrn($entity->getUrn())
->setOwnerGuid((string) $entity->getOwnerGuid())
->setClientMeta($_POST['client_meta'] ?? [])
);
} catch (\Exception $e) {
......@@ -114,7 +117,7 @@ class views implements Interfaces\Api
}
Di::_()->get('Referrals\Cookie')
->setEntity($activity)
->setEntity($entity)
->create();
break;
......
......@@ -124,10 +124,14 @@ class feed implements Interfaces\Api
// $next = 0;
// }
$len = count($boosts);
$next = $boosts[$len -1]->getTimestamp();
if ($boosts[$len -1]) {
$next = $boosts[$len -1]->getTimestamp();
}
} elseif ($isBoostFeed) {
$len = count($boosts);
$next = $boosts[$len -1]->getTimestamp();
if ($boosts[$len -1]) {
$next = $boosts[$len -1]->getTimestamp();
}
}
// $ttl = 1800; // 30 minutes
......
......@@ -34,6 +34,13 @@ class channel implements Interfaces\Api
$channel->fullExport = true; //get counts
$channel->exportCounts = true;
if (!$channel->isPro()) {
return Factory::response([
'status' => 'error',
'message' => 'E_NOT_PRO'
]);
}
/** @var Manager $manager */
$manager = Di::_()->get('Pro\Manager');
$manager->setUser($channel);
......
......@@ -13,6 +13,12 @@ class emails implements Interfaces\Api
public function get($pages)
{
$user = Core\Session::getLoggedInUser();
if (!$user) {
return Factory::response([
'status' => 'error',
'message' => 'User must be logged in.'
]);
}
$campaigns = [ 'when', 'with', 'global' ];
......
......@@ -78,6 +78,9 @@ class Sums
public function getContractBalance($contract = '', $onlySpend = false)
{
if (!$this->user) {
return 0;
}
$cql = "SELECT SUM(amount) as balance from blockchain_transactions_mainnet WHERE user_guid = ? AND wallet_address = ?";
$values = [
new Varint($this->user->guid),
......
<?php
namespace Minds\Core\Blogs;
use Minds\Core\Di\Provider;
class BlogsProvider extends Provider
{
public function register()
{
$this->di->bind('Blogs\Manager', function () {
return new Manager();
});
}
}
<?php
namespace Minds\Core\Blogs\Delegates;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
/**
* Class PropagateProperties
* @package Minds\Core\Blogs\Delegates
*/
class PropagateProperties extends Properties
{
protected $actsOnSubtype = ['blog'];
/**
* Propagate Entity properties to activity
* @param $from
* @param Activity $to
* @return Activity
*/
public function toActivity($from, Activity $to): Activity
{
if ($this->valueHasChanged($from->getTitle(), $to->get('title'))) {
$to->set('title', $from->getTitle());
}
$blurb = strip_tags($from->getBody());
if ($this->valueHasChanged($blurb, $to->get('blurb'))) {
$to->set('blurb', $blurb);
}
if ($this->valueHasChanged($from->getUrl(), $to->getURL())) {
$to->setURL($from->getUrl());
}
if ($this->valueHasChanged($from->getIconUrl(), $to->get('thumbnail_src'))) {
$to->set('thumbnail_src', $from->getIconUrl());
}
return $to;
}
/**
* Propagate activity properties to entity
* @param Activity $from
* @param $to
* @return mixed
*/
public function fromActivity(Activity $from, $to)
{
return $to;
}
}
......@@ -8,19 +8,11 @@ use Minds\Core\Events\EventsDispatcher;
class Events
{
/** @var Legacy\Entity */
protected $legacyEntity;
/** @var Manager */
protected $manager;
/** @var EventsDispatcher */
protected $eventsDispatcher;
public function __construct($legacyEntity = null, $manager = null, $eventsDispatcher = null)
public function __construct($eventsDispatcher = null)
{
$this->legacyEntity = $legacyEntity ?: new Legacy\Entity();
$this->manager = $manager ?: new Manager();
$this->eventsDispatcher = $eventsDispatcher ?: Di::_()->get('EventsDispatcher');
}
......@@ -31,7 +23,7 @@ class Events
$params = $event->getParameters();
if ($params['row']->type == 'object' && $params['row']->subtype == 'blog') {
$blog = $this->legacyEntity->build($params['row']);
$blog = (new Legacy\Entity())->build($params['row']);
$blog->setEphemeral(false);
$event->setResponse($blog);
......@@ -42,7 +34,8 @@ class Events
$this->eventsDispatcher->register('entity:save', 'object:blog', function (Event $event) {
$blog = $event->getParameters()['entity'];
$event->setResponse($this->manager->update($blog));
$manager = Di::_()->get('Blogs\Manager');
$event->setResponse($manager->update($blog));
});
}
}
......@@ -9,6 +9,7 @@
namespace Minds\Core\Blogs;
use Minds\Core\Di\Di;
use Minds\Core\Entities\PropagateProperties;
use Minds\Core\Security\Spam;
class Manager
......@@ -31,6 +32,9 @@ class Manager
/** @var Delegates\Search */
protected $search;
/** @var PropagateProperties */
protected $propagateProperties;
/**
* Manager constructor.
* @param null $repository
......@@ -39,6 +43,7 @@ class Manager
* @param null $feeds
* @param null $spam
* @param null $search
* @param PropagateProperties $propagateProperties
* @throws \Exception
*/
public function __construct(
......@@ -47,7 +52,8 @@ class Manager
$slug = null,
$feeds = null,
$spam = null,
$search = null
$search = null,
PropagateProperties $propagateProperties = null
) {
$this->repository = $repository ?: new Repository();
$this->paywallReview = $paywallReview ?: new Delegates\PaywallReview();
......@@ -55,6 +61,7 @@ class Manager
$this->feeds = $feeds ?: new Delegates\Feeds();
$this->spam = $spam ?: Di::_()->get('Security\Spam');
$this->search = $search ?: new Delegates\Search();
$this->propagateProperties = $propagateProperties ?? Di::_()->get('PropagateProperties');
}
/**
......@@ -170,6 +177,7 @@ class Manager
}
$this->paywallReview->queue($blog);
$this->propagateProperties->from($blog);
}
return $saved;
......
......@@ -3,6 +3,7 @@
namespace Minds\Core\Blogs;
use Minds\Core;
use Minds\Core\Di\Di;
use Minds\Entities;
use Minds\Helpers;
use Minds\Helpers\Counters;
......@@ -10,13 +11,8 @@ use Zend\Diactoros\ServerRequestFactory;
class SEO
{
/** @var Manager */
protected $manager;
public function __construct(
$manager = null
) {
$this->manager = $manager ?: new Manager();
}
public function setup()
......@@ -104,7 +100,7 @@ class SEO
});
}
public function viewHandler($slugs = [])
public function viewHandler($slugs = [], $manager = null)
{
if (!is_numeric($slugs[0]) && isset($slugs[1]) && is_numeric($slugs[1])) {
$guid = $slugs[1];
......@@ -112,7 +108,10 @@ class SEO
$guid = $slugs[0];
}
$blog = $this->manager->get($guid);
if (is_null($manager)) {
$manager = Di::_()->get('Blogs\Manager');
}
$blog = $manager->get($guid);
if (!$blog || !$blog->getTitle() || Helpers\Flags::shouldFail($blog) || !Core\Security\ACL::_()->read($blog)) {
header("HTTP/1.0 404 Not Found");
return [
......
......@@ -13,20 +13,15 @@ use Minds\Core\Events\Event;
class Events
{
/** @var Manager */
protected $manager;
/** @var Dispatcher */
protected $eventsDispatcher;
/**
* Events constructor.
* @param Manager $manager
* @param Dispatcher $eventsDispatcher
*/
public function __construct($manager = null, $eventsDispatcher = null)
public function __construct($eventsDispatcher = null)
{
$this->manager = $manager ?: Di::_()->get('Channels\Manager');
$this->eventsDispatcher = $eventsDispatcher ?: Di::_()->get('EventsDispatcher');
}
......@@ -35,8 +30,8 @@ class Events
// User entity deletion
$this->eventsDispatcher->register('entity:delete', 'user', function (Event $event) {
$user = $event->getParameters()['entity'];
$event->setResponse($this->manager->setUser($user)->delete());
$manager = Di::_()->get('Channels\Manager');
$event->setResponse($manager->setUser($user)->delete());
});
}
}
......@@ -19,25 +19,16 @@ use Minds\Core\Security\ACL;
class Events
{
/** @var Manager */
protected $manager;
/** @var Dispatcher */
protected $eventsDispatcher;
/** @var Votes\Manager */
protected $votesManager;
/**
* Events constructor.
* @param Manager $manager
* @param Dispatcher $eventsDispatcher
*/
public function __construct($manager = null, $eventsDispatcher = null, $votesManager = null)
public function __construct($eventsDispatcher = null)
{
$this->manager = $manager ?: new Manager();
$this->eventsDispatcher = $eventsDispatcher ?: Di::_()->get('EventsDispatcher');
$this->votesManager = $votesManager ?: new Votes\Manager();
}
public function register()
......@@ -46,23 +37,24 @@ class Events
$this->eventsDispatcher->register('entity:resolve', 'comment', function (Event $event) {
$luid = $event->getParameters()['luid'];
$event->setResponse($this->manager->getByLuid($luid));
$manager = new Manager();
$event->setResponse($manager->getByLuid($luid));
});
// Entity save
$this->eventsDispatcher->register('entity:save', 'comment', function (Event $event) {
$comment = $event->getParameters()['entity'];
$event->setResponse($this->manager->update($comment));
$manager = new Manager();
$event->setResponse($manager->update($comment));
});
// Votes Module
$this->eventsDispatcher->register('vote:action:has', 'comment', function (Event $event) {
$votesManager = new Votes\Manager();
$event->setResponse(
$this->votesManager
$votesManager
->setVote($event->getParameters()['vote'])
->has()
);
......@@ -81,8 +73,9 @@ class Events
$vote->getDirection()
);
$votesManager = new Votes\Manager();
$event->setResponse(
$this->votesManager
$votesManager
->setVote($event->getParameters()['vote'])
->cast()
);
......@@ -101,8 +94,9 @@ class Events
$vote->getDirection()
);
$votesManager = new Votes\Manager();
$event->setResponse(
$this->votesManager
$votesManager
->setVote($event->getParameters()['vote'])
->cancel()
);
......
......@@ -2,11 +2,12 @@
/**
* Minds Data Client Factory
*/
namespace Minds\Core\data;
namespace Minds\Core\Data;
class Client
{
private static $default = '\Minds\Core\Data\cassandra\client';
private static $default = '\Minds\Core\Data\Cassandra\Client';
private static $clients = [];
/**
......
You've received a gift of 2 Minds tokens! You can spend these tokens to earn 2,000 extra views on your content with [Boost](https://www.minds.com/boost?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator'] ?>) or to tip your favorite content creators with [Wire](https://www.minds.com/wire?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator'] ?>).
Please use the button below to claim your gift (note: you will need to open the link in a web browser, the mobile app is not yet supported):
| |
|:--:|
| [![Claim Gift](https://cdn-assets.minds.com/emails/claim-gift.png){=150x}](https://www.minds.com/wallet/tokens/transactions?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator'] ?>) |
| |
......@@ -14,8 +14,6 @@ use Minds\Helpers\MagicAttributes;
/**
* Save Action
* @method Save setEntity($entity)
* @method bool save(...$args)
*/
class Save
{
......