Commit 137b0e3b authored by Marcelo Rivera's avatar Marcelo Rivera

Merge remote-tracking branch 'upstream/master' into...

Merge remote-tracking branch 'upstream/master' into sprint/HipsterHedgehog.feat.remove-frequency-from-onboarding-modal
parents afc57f9c 10072639
1 merge request!243[Sprint/HipsterHedgehog] (feat): remove creator frequency from onboarding modal
Pipeline #69082531 canceled with stages
in 8 seconds
......@@ -6,6 +6,8 @@ services:
stages:
- build
- test
- prepare
- review
- deploy
cache:
......@@ -27,23 +29,84 @@ build:
test:
stage: test
image: php:7.1.11-fpm-alpine3.4 # TODO: Fix cassandra driver conflicts
image: minds/php-tests:latest
script:
- apk update && apk add libpng-dev freetype-dev libjpeg-turbo-dev
- docker-php-ext-install mbstring
- docker-php-ext-install bcmath
- docker-php-ext-install gd
- bin/phpspec run
prepare:fpm:
stage: prepare
image: minds/ci:latest
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker build -t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF -f containers/php-fpm/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
prepare:runners:
stage: prepare
image: minds/ci:latest
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker build -t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF -f containers/php-runners/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF
review:start:
stage: review
image: minds/helm-eks:latest
script:
- aws eks update-kubeconfig --name=sandbox
- git clone --branch=sandbox-wip https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/minds/helm-charts.git
- "helm upgrade \
--install \
--reuse-values \
--set phpfpm.image.repository=$CI_REGISTRY_IMAGE/fpm \
--set phpfpm.image.tag=$CI_BUILD_REF \
--set runners.image.repository=$CI_REGISTRY_IMAGE/runners \
--set runners.image.tag=$CI_BUILD_REF \
--set domain=$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN \
--set elasticsearch.clusterName=$CI_BUILD_REF_SLUG-elasticsearch \
--wait \
$CI_BUILD_REF_SLUG \
./helm-charts/minds"
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
on_stop: review:stop
except:
refs:
- master
- test/gitlab-ci
review:stop:
stage: review
image: minds/helm-eks:latest
script:
- aws eks update-kubeconfig --name=sandbox
- helm del --purge $CI_BUILD_REF_SLUG
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
action: stop
variables:
GIT_STRATEGY: none
when: manual
except:
refs:
- master
- test/gitlab-ci
deploy:fpm:
stage: deploy
image: docker:latest
image: minds/ci:latest
script:
- apk add --no-cache curl jq python py-pip
- pip install awscli
- docker build -t $REPOSITORY_URL_FPM -f containers/php-fpm/Dockerfile .
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
# Push to production registry
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $REPOSITORY_URL_FPM
- docker push $REPOSITORY_URL_FPM
# Push to gitlab register
- docker tag $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF $CI_REGISTRY_IMAGE/fpm:latest
- docker push $CI_REGISTRY_IMAGE/fpm:latest
- aws ecs update-service --service=$SERVICE_FPM --force-new-deployment --region us-east-1 --cluster=$CLUSTER
only:
refs:
......@@ -54,17 +117,21 @@ deploy:fpm:
deploy:runners:
stage: deploy
image: docker:latest
image: minds/ci:latest
script:
- apk add --no-cache curl jq python py-pip
- pip install awscli
- docker build -t $REPOSITORY_URL_RUNNERS -f containers/php-runners/Dockerfile .
- $(aws ecr get-login --no-include-email --region us-east-1)
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF
# Push to production register
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $REPOSITORY_URL_RUNNERS
- docker push $REPOSITORY_URL_RUNNERS
# Push gitlab registry
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest
- docker push $CI_REGISTRY_IMAGE/runners:latest
- aws ecs update-service --service=$SERVICE_RUNNERS --force-new-deployment --region us-east-1 --cluster=$CLUSTER
only:
refs:
- master
- test/gitlab-ci
environment:
name: production
\ No newline at end of file
name: production
......@@ -85,6 +85,7 @@ class Analytics extends Cli\Controller implements Interfaces\CliControllerInterf
}
public function sync_graphs()
{
error_reporting(E_ALL);
ini_set('display_errors', 1);
......@@ -120,11 +121,14 @@ class Analytics extends Cli\Controller implements Interfaces\CliControllerInterf
foreach ($aggregates as $aggregate) {
$this->out("Syncing {$aggregate}");
$manager->sync([
'aggregate' => $aggregate,
'all' => true,
]);
try {
$manager->sync([
'aggregate' => $aggregate,
'all' => true,
]);
} catch (\Exception $e) {
}
}
$this->out('Completed caching site metrics');
......
......@@ -62,7 +62,7 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac
try {
if ($installType == "all" || $installType == "cassandra") {
$this->out('- Provisioning Cassandra: ', $this::OUTPUT_INLINE);
$this->out('- Provisioning Cassandra:', $this::OUTPUT_INLINE);
$isCleanCassandra = $this->getopt("cleanCassandra") != null;
$provisioner->provisionCassandra(null, $isCleanCassandra);
$this->out('OK');
......@@ -71,44 +71,33 @@ class Install extends Cli\Controller implements Interfaces\CliControllerInterfac
$provisioner->reloadStorage();
$this->out('OK');
}
} catch (Exception $e) {
// REVNOTE: This seems unused, currently. None of the database provisioners currently
// throw ProvisionException. We should maybe catch general exceptions (log them) and continue,
// and not ProvisionExceptions. I considered removing this altogether, but it is useful to continue
// past server errors in an setup.
if ($this->getOpt('graceful-storage-provision')) {
$this->out($e->getMessage());
$this->out('Error in cassandra setup. Continuing.');
} else {
throw $e;
}
} catch (Exception $ex) {
$this->out('Something BAD happened while provisioning Cassandra' . $ex->getMessage());
}
try {
if ($installType == "all" || $installType == "cockroach") {
$this->out('- Provisioning Cockroach:', $this::OUTPUT_INLINE);
$this->out('- Provisioning Cockroach:');
$isCleanCockroach = $this->getopt("cleanCockroach") != null;
$provisioner->provisionCockroach(null, $isCleanCockroach);
$this->out('OK');
}
} catch (Exception $e) {
// See REVNOTE above.
if ($this->getOpt('graceful-storage-provision')) {
$this->out($e->getMessage());
$this->out('Error in cockroach setup. Continuing.');
} else {
throw $e;
}
}
} catch (Exception $ex) {
$this->out('Something BAD happened while provisioning Cockroach' . $ex->getMessage());
}
if (($installType == "all") || ($installType == "site")) {
$this->out('- Setting up site:', $this::OUTPUT_INLINE);
$provisioner->setupSite();
$this->out('OK');
$this->out('- Setting up administrative user (ignore warnings, if any):', $this::OUTPUT_INLINE);
$provisioner->setupFirstAdmin();
$this->out('OK');
try {
$this->out('- Setting up administrative user (ignore warnings, if any):', $this::OUTPUT_INLINE);
$provisioner->setupFirstAdmin();
$this->out('OK');
} catch (\Exception $ex) {
$this->out('Could not setup initial user');
}
}
$this->out(['Done!', 'Open your browser and go to ' . $provisioner->getSiteUrl()], $this::OUTPUT_PRE);
......
......@@ -182,6 +182,10 @@ class notifications implements Interfaces\Api
$return = [];
// Formatting for legacy notification handling in frontend
foreach ($notifications as $key => $entity) {
if ($entity->getToGuid() != Core\Session::getLoggedInUser()->guid) {
error_log('[notification]: Mismatch of to_guid with uuid ' . $entity->getUuid());
continue;
}
$entityObj = Entities\Factory::build($entity->getEntityGuid());
$fromObj = Entities\Factory::build($entity->getFromGuid());
$toObj = Core\Session::getLoggedInUser();
......
......@@ -7,6 +7,7 @@ use Minds\Api\Factory;
use Minds\Interfaces;
use Minds\Core\Di\Di;
use Minds\Core\Session;
use Minds\Core;
use Minds\Entities\Activity;
class firehose implements Interfaces\Api, Interfaces\ApiAdminPam
......@@ -20,6 +21,9 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam
*/
public function get($pages)
{
/** @var User $currentUser */
$currentUser = Core\Session::getLoggedinUser();
$algorithm = $pages[0] ?? null;
if (!$algorithm) {
......@@ -34,18 +38,12 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam
case 'activities':
$type = 'activity';
break;
case 'channels':
$type = 'user';
break;
case 'images':
$type = 'object:image';
break;
case 'videos':
$type = 'object:video';
break;
case 'groups':
$type = 'group';
break;
case 'blogs':
$type = 'object:blog';
break;
......@@ -113,6 +111,13 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam
return Factory::response(['status' => 'error', 'message' => $e->getMessage()]);
}
if ($type !== 'activity') {
/** @var Core\Feeds\Top\Entities $entities */
$entities = new Core\Feeds\Top\Entities();
$entities->setActor($currentUser);
$activities = $activities->map([$entities, 'cast']);
}
return Factory::response([
'status' => 'success',
'entities' => Exportable::_($activities)
......@@ -135,14 +140,8 @@ class firehose implements Interfaces\Api, Interfaces\ApiAdminPam
$moderator = Session::getLoggedinUser();
$manager = Di::_()->get('Feeds\Firehose\Manager');
if (isset($_POST['reason'])) {
$reasonCode = $_POST['reason'];
}
if (isset($_POST['subreason_code'])) {
$reasonCode = $_POST['subreason'];
}
$manager->save($entity, $moderator, $reasonCode, $subReasonCode);
$manager->save($entity, $moderator);
return Factory::response([]);
}
......
......@@ -122,15 +122,6 @@ class ActiveUsers implements AggregateInterface
$query = [
'index' => $this->index,
'size' => 0,
"stored_fields" => [
"*"
],
"docvalue_fields" => [
(object) [
"field" => "@timestamp",
"format" => "date_time"
]
],
'body' => [
'query' => [
'bool' => [
......@@ -226,15 +217,6 @@ class ActiveUsers implements AggregateInterface
$query = [
'index' => $this->index,
'size' => 0,
"stored_fields" => [
"*"
],
"docvalue_fields" => [
(object) [
"field" => "@timestamp",
"format" => "date_time"
]
],
'body' => [
'query' => [
'bool' => [
......@@ -300,9 +282,6 @@ class ActiveUsers implements AggregateInterface
private function getMonthlyPageviews($from, $to, $user_guid)
{
$must = [
[
"match_all" => (object) []
],
[
"range" => [
"@timestamp" => [
......@@ -324,15 +303,6 @@ class ActiveUsers implements AggregateInterface
$query = [
'index' => $this->index,
'size' => 0,
"stored_fields" => [
"*"
],
"docvalue_fields" => [
(object) [
"field" => "@timestamp",
"format" => "date_time"
]
],
'body' => [
'query' => [
'bool' => [
......@@ -344,7 +314,7 @@ class ActiveUsers implements AggregateInterface
"date_histogram" => [
"field" => "@timestamp",
"interval" => "1M",
"min_doc_count" => 1
//"min_doc_count" => 1
],
"aggs" => [
"mau_logged_in" => [
......@@ -352,7 +322,7 @@ class ActiveUsers implements AggregateInterface
"field" => "user_guid.keyword"
]
],
"mau_unique" => [
"mau_unique" => [
"cardinality" => [
"field" => "cookie_id.keyword"
]
......@@ -386,7 +356,7 @@ class ActiveUsers implements AggregateInterface
$prepared->query($query);
$result = $this->client->request($prepared);
$response = [
[
'name' => 'MAU',
......
......@@ -89,6 +89,10 @@ use Minds\Traits\MagicAttributes;
* @method bool isEphemeral()
* @method Blog setHidden(bool $value)
* @method bool isHidden()
* @method Blog setModeratorGuid(int $moderatorGuid)
* @method int getModeratorGuid()
* @method Blog setTimeModerated(int $timeModerated)
* @method int getTimeModerated()
*/
class Blog extends RepositoryEntity
{
......@@ -222,8 +226,15 @@ class Blog extends RepositoryEntity
/** @var array */
protected $nsfw = [];
/** @var array */
protected $nsfwLock = [];
/** @var int */
protected $moderatorGuid;
/** @var int */
protected $timeModerated;
/**
* Blog constructor.
* @param null $eventsDispatcher
......@@ -631,4 +642,13 @@ class Blog extends RepositoryEntity
return $output;
}
/**
* Return the URN
* @return string
*/
public function getUrn()
{
return "urn:blog:{$this->getGuid()}";
}
}
......@@ -49,6 +49,8 @@ class Entity
'boostRejectionReason' => 'boost_rejection_reason',
'ownerObj' => 'ownerObj',
'nsfw' => 'nsfw',
'moderatorGuid' => 'moderator_guid',
'timeModerated' => 'time_moderated'
];
static $jsonEncodedFields = [
......
......@@ -94,11 +94,11 @@ class MissedSinceLogin implements EmailBatchInterface
->setValue(true)
->setOffset($this->offset);
$blogs = $this->getTrendingBlogs();
//$blogs = $this->getTrendingBlogs();
$i = 0;
foreach ($iterator as $user) {
$user = new \Minds\Entities\User('ottman');
$user = new \Minds\Entities\User('mark');
++$i;
echo "\n[$i]: $user->guid ($iterator->offset)";
......@@ -107,13 +107,13 @@ class MissedSinceLogin implements EmailBatchInterface
// return true;
//}
$campaign = new Campaigns\WithBlogs();
$campaign = new Campaigns\MissedSinceLogin();
$campaign
->setUser($user)
//->setTemplateKey($this->templatePath)
//->setSubject($this->subject)
->setBlogs($blogs)
->setTemplateKey($this->templatePath)
->setSubject($this->subject)
//->setBlogs($blogs)
->send();
echo ' sent';
......
......@@ -64,6 +64,7 @@ class MissedSinceLogin extends EmailCampaign
$this->template->setTemplate('default.tpl');
$this->template->setBody("./Templates/$this->templateKey.tpl");
$this->template->toggleMarkdown(true);
$this->template->set('user', $this->user);
$this->template->set('username', $this->user->username);
......@@ -75,7 +76,6 @@ class MissedSinceLogin extends EmailCampaign
$this->template->set('entities', $this->entities);
$this->user = new \Minds\Entities\User('jack');
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
......
You've received a gift of 5 Minds tokens! You can spend these tokens to earn 5,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'] ?>) |
| |
Please login to check your token balance. Remember, 1 token = 1,000 extra views on the content of your choice by using [Boost](https://www.minds.com/boost?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator']?>). You can also send tokens to your favourite channels to support them.
| |
|:--:|
| [![Read More](https://cdn-assets.minds.com/emails/view-balance.png){=150x}](https://ndl.minds.com/wallet/tokens/transactions?__e_ct_guid=<?= $vars['guid']?>&campaign=<?= $vars['campaign']?>&topic=<?= $vars['topic'] ?>&validator=<?= $vars['validator']?>){=50x} |
| |
Thank you for your contribution!
......@@ -21,13 +21,17 @@ class Manager
'emailweb.xyz',
'buydiscountdeal.com',
'palantirmails.com',
'vincentralpark.com',
'vincentralpark.com',
'clickmail.info',
'marketlink.info',
'atnextmail.com',
'hostguru.top',
'daymailonline.com',
'uber-mail.com',
'mailmetal.com',
'email-24x7.com',
'getsimpleemail.com',
'mailsoul.com',
];
public function __construct($service = null, $spamBlocksManager = null)
......
......@@ -4,6 +4,8 @@ namespace Minds\Core\Feeds\Firehose;
use Minds\Entities\User;
use Minds\Entities\Entity;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Data\Call;
use Minds\Core\Entities\Actions\Save;
use Minds\Core\Di\Di;
use Minds\Core\Feeds\Top\Manager as TopFeedsManager;
......@@ -14,22 +16,34 @@ class Manager
protected $topFeedsManager;
/** @var ModerationCache */
protected $moderationCache;
/** @var EntitiesBuilder $entitiesBuilder */
protected $entitiesBuilder;
/** @var Call */
protected $db;
/** @var Save */
protected $save;
public function __construct(
TopFeedsManager $topFeedsManager = null,
ModerationCache $moderationCache = null
ModerationCache $moderationCache = null,
EntitiesBuilder $entitiesBuilder = null,
Call $db = null,
Save $save = null
) {
$this->topFeedsManager = $topFeedsManager ?: Di::_()->get('Feeds\Top\Manager');
$this->moderationCache = $moderationCache ?: new ModerationCache();
$this->entitiesBuilder = $entitiesBuilder ?: Di::_()->get('EntitiesBuilder');
$this->db = $db ?: new Call('entities_by_time');
$this->save = $save ?: new Save(); //Mockable, else instantiate a new one on save.
}
/**
* Gets the top feed and filters out any entities that have been moderated
* It caches entities for 1 hour in redis so moderators don't do double work.
*
* @param array $opts filtering options
* Pass in a moderation_user to cache the returned entities for that user
*
*
* @param array $opts filtering options
* Pass in a moderation_user to cache the returned entities for that user
*
* @return array entities that don't contain moderator_guids
*/
public function getList(array $opts = [])
......@@ -53,35 +67,54 @@ class Manager
}
return $response->filter(function ($entity) {
return $entity->get('moderator_guid') === null;
return (!$entity->getModeratorGuid());
});
}
/**
* Marks an entity as moderated.
*
* @param $entity the entity to mark as moderated, typeless because images do not inherit entity
* @param User $user the moderator
* @param int $reasonCode providing a reason code will cause it be reported
* @param int $subreaonCode report subreason
* @param int $time
* @param $entity the entity to mark as moderated, typeless because images do not inherit entity
* @param User $user the moderator
* @param int $time
*/
public function save(
$entity,
User $moderator,
int $reasonCode = null,
int $subreasonCode = null,
int $time = null)
{
if (!$time) {
$time = time();
}
//Save the entity
$this->saveEntity($entity, $moderator, $time);
if (method_exists($entity, 'getType')
&& $entity->getType() == 'activity'
&& $entity->get('entity_guid')
) {
$attachment = $this->entitiesBuilder->single($entity->get('entity_guid'));
$this->saveEntity($attachment, $moderator, $time);
}
//Moderate parents
foreach ($this->db->getRow('activity:entitylink:'.$entity->getGUID()) as $parentGuid => $ts) {
$activity = $this->entitiesBuilder->single($parentGuid);
$this->saveEntity($activity, $moderator, $time);
}
}
private function saveEntity(
$entity,
User $moderator,
int $time = null)
{
$entity->setModeratorGuid($moderator->getGUID());
$entity->setTimeModerated($time);
$action = (new Save())
->setEntity($entity)
->save();
$this->save
->setEntity($entity)
->save();
}
}
......@@ -122,7 +122,7 @@ class CassandraRepository
public function add($notification)
{
if (!$notification->getUuid()) {
$notification->setUuid((new Timeuuid($notification->getUuid() ?? time() * 1000))->uuid());
$notification->setUuid((new Timeuuid())->uuid());
}
$statement = 'INSERT INTO notifications (
......
......@@ -50,6 +50,10 @@ class Counters
*/
public function getCount(array $options = [])
{
// return Helpers\Counters::get($this->user, 'notifications:count', false);
// TODO: Remove below once settled
$query = "SELECT uuid, read_timestamp FROM notifications
WHERE to_guid = ?
ORDER BY created_timestamp DESC
......@@ -86,7 +90,7 @@ class Counters
*/
public function increaseCounter()
{
//Helpers\Counters::increment($this->user, 'notifications:count');
Helpers\Counters::increment($this->user, 'notifications:count');
}
/**
......@@ -96,6 +100,10 @@ class Counters
*/
public function resetCounter()
{
Helpers\Counters::clear($this->user, 'notifications:count');
// TODO: Remove below once settled
$query = "BEGIN;
UPDATE notifications
SET read_timestamp = NOW()
......
......@@ -75,7 +75,7 @@ class Events
->setToGuid($params['to'])
->setFromGuid($from_user->getGuid())
->setEntityGuid($entityGuid)
->setEntityUrn($entity->getUrn())
->setEntityUrn(method_exists($entity, 'getUrn') ? $entity->getUrn() : "urn:entity:$entityGuid")
->setType($params['notification_view'])
->setData($data);
......
......@@ -160,7 +160,7 @@ class Manager
} catch (\Exception $e) {
error_log($e);
if (php_sapi_name() === 'cli') {
exit;
//exit;
}
}
}
......
......@@ -38,7 +38,7 @@ class CassandraProvisioner implements ProvisionerInterface
$client->execute($statement);
}
} catch (\Exception $e) {
var_dump($e); exit;
error_log("Error provisioning cassandra: " . $e->getMessage());
}
return true;
......
......@@ -41,8 +41,12 @@ class CockroachProvisioner implements ProvisionerInterface
if (trim($query) === '') {
continue;
}
$statement = $adminDb->prepare($query);
$statement->execute();
try {
$statement = $adminDb->prepare($query);
$statement->execute();
} catch (\Exception $ex) {
error_log("Error running cockroach statement: " . $ex->getMessage());
}
}
}
}
......@@ -43,10 +43,20 @@ class ReportsAppealSummon implements QueueRunner
return;
}
echo "Summoning for {$appeal->getReport()->getUrn()}..." . PHP_EOL;
// Reydrate each loop
$reportsManager = Di::_()->get('Moderation\Manager');
$appeal->setReport($reportsManager->getReport($appeal->getReport()->getUrn()));
if ($appeal->getReport()->getState() !== 'appealed') {
echo "{$appeal->getReport()->getUrn()} is already appealed..." . PHP_EOL;
return;
}
echo "Summoning for {$appeal->getReport()->getUrn()}..." . PHP_EOL;
/** @var Manager $manager */
$manager = Di::_()->get('Moderation\Summons\Manager');
$missing = $manager->summon($appeal, [
'include_only' => $cohort ?: null,
]);
......
......@@ -70,7 +70,7 @@ class Manager
'include_only' => null,
'active_threshold' => 5 * 60,
'jury_size' => 12,
'awaiting_ttl' => 300,
'awaiting_ttl' => 120,
], $opts);
// Get a fresh report to collect completed jurors
......@@ -133,7 +133,7 @@ class Manager
// Pick up to missing size
$cohort = $this->cohort->pick([
'size' => $poolSize,
'size' => $poolSize * 500, // 500 users
'for' => $appeal->getOwnerGuid(),
'except' => $alreadyInvolvedGuids,
'except_hashes' => $alreadyInvolvedPhoneHashes,
......@@ -143,7 +143,11 @@ class Manager
// Build Summonses
$sent = 0;
foreach ($cohort as $juror) {
if (++$sent > $poolSize) {
break;
}
$summons = new Summons();
$summons
->setReportUrn($reportUrn)
......@@ -154,6 +158,7 @@ class Manager
$this->repository->add($summons);
$this->socketDelegate->onSummon($summons);
echo "\nSummoning $juror for $reportUrn";
}
//
......
......@@ -187,7 +187,10 @@ class Pool
$result = $this->elasticsearch->request($prepared);
foreach ($result['aggregations']['entities']['buckets'] as $bucket) {
$buckets = $result['aggregations']['entities']['buckets'];
shuffle($buckets);
echo "\n" . count($buckets) . " returned";
foreach ($buckets as $bucket) {
yield $bucket['key'];
}
}
......
......@@ -33,6 +33,8 @@ class EntityMapping implements MappingInterface
'nsfw' => [ 'type' => 'integer' ],
'paywall' => [ 'type' => 'boolean', '$exportField' => 'paywall' ],
'rating' => [ 'type' => 'integer', '$exportField' => 'rating' ],
'moderator_guid' => [ 'type' => 'text'],
'@moderated' => [ 'type' => 'date'],
];
/** @var mixed $entity */
......
......@@ -33,6 +33,8 @@ class ObjectBlogMapping extends EntityMapping implements MappingInterface
'license' => [ 'type' => 'text', '$exportGetter' => 'getLicense' ],
'rating' => [ 'type' => 'integer', '$exportField' => 'rating' ],
'nsfw' => [ 'type' => 'array', '$exportGetter' => 'getNsfw' ],
'moderator_guid' => [ 'type' => 'text' ],
'@moderated' => [ 'type' => 'date' ],
];
/** @var Blog $entity */
......@@ -158,8 +160,14 @@ class ObjectBlogMapping extends EntityMapping implements MappingInterface
$map['rating'] = (int) $this->entity->getRating();
//
if ($this->entity->getModeratorGuid()) {
$map['moderator_guid'] = $this->entity->getModeratorGuid();
}
if ($this->entity->getTimeModerated()) {
$map['@moderated'] = $this->entity->getTimeModerated() * 1000;
}
//
return $map;
}
......
......@@ -7,6 +7,15 @@ use Minds\Interfaces\Flaggable;
/**
* File Entity
* @todo Do not inherit from ElggFile
* @package Minds\Entities\File
* @method array getExportableValues()
* @method mixed|null getFlag(string $flag)
* @method File setFlag(string $flag, mixed $value)
* @method void save(bool $index)
* @method array getWireTotals()
* @method mixed getWireThreshold()
* @method File setWireThreshold(int $wire_threshold)
* @method int getModeratorGUID()
*/
class File extends \ElggFile implements Flaggable
{
......@@ -21,6 +30,8 @@ class File extends \ElggFile implements Flaggable
$this->attributes['flags'] = [];
$this->attributes['wire_threshold'] = 0;
$this->attributes['moderator_guid'] = null;
$this->attributes['time_moderated'] = null;
}
/**
......@@ -31,7 +42,9 @@ class File extends \ElggFile implements Flaggable
{
return array_merge(parent::getExportableValues(), [
'flags',
'wire_threshold'
'wire_threshold',
'moderator_guid',
'time_moderated'
]);
}
......@@ -141,4 +154,40 @@ class File extends \ElggFile implements Flaggable
$this->wire_threshold = $wire_threshold;
return $this;
}
/**
* Returns the user who moderated
* @return int moderator guid
*/
public function getModeratorGuid() {
return $this->moderator_guid;
}
/**
* Sets the user who moderated
* @param int $moderatorGuid
* @return File
*/
public function setModeratorGuid(int $moderatorGuid) {
$this->moderator_guid = $moderatorGuid;
return $this;
}
/**
* Returns when the file was moderated
* @return int time_moderated timestamp
*/
public function getTimeModerated() {
return $this->time_moderated;
}
/**
* Sets when the file was moderated
* @param int $timeModerated
* @return File
*/
public function setTimeModerated(int $timeModerated) {
$this->time_moderated = $timeModerated;
return $this;
}
}
......@@ -74,7 +74,7 @@ class EmailRewards
$validator = $_GET['validator'];
//$key = '.md';
//return;
if ($validator == sha1($campaign . 'gift-24-05-19.md' . $topic . $user->guid . Config::_()->get('emails_secret'))) {
if ($validator == sha1($campaign . 'gift-25-06-19.mdl' . $topic . $user->guid . Config::_()->get('emails_secret'))) {
$tokens = 5 * (10 ** 18);
$campaign = $validator; //hack
} else {
......
......@@ -8,8 +8,13 @@ use Minds\Core\Feeds\Firehose\Manager;
use Minds\Common\Repository\Response;
use Minds\Entities\Activity;
use Minds\Entities\Entity;
use Minds\Core\Blogs\Blog;
use Minds\Entities\Image;
use Minds\Core\Feeds\Top\Manager as TopFeedsManager;
use Minds\Core\Feeds\Firehose\ModerationCache;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Data\Call;
use Minds\Core\Entities\Actions\Save;
class ManagerSpec extends ObjectBehavior
{
......@@ -19,6 +24,12 @@ class ManagerSpec extends ObjectBehavior
protected $topFeedsManager;
/** @var ModerationCache */
protected $moderationCache;
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Call */
protected $db;
/** @var Save */
protected $save;
protected $guids = [
'968599624820461570', '966142563226488850', '966145446911152135',
......@@ -30,16 +41,26 @@ class ManagerSpec extends ObjectBehavior
public function let(
User $user,
TopFeedsManager $topFeedsManager,
ModerationCache $moderationCache)
{
ModerationCache $moderationCache,
EntitiesBuilder $entitiesBuilder,
Call $db,
Save $save
) {
$this->user = $user;
$this->topFeedsManager = $topFeedsManager;
$this->moderationCache = $moderationCache;
$this->entitiesBuilder = $entitiesBuilder;
$this->db = $db;
$this->save = $save;
$this->user->getGUID()->willReturn(123);
$this->user->getGUID()->willReturn('123');
$this->beConstructedWith(
$this->topFeedsManager,
$this->moderationCache
$this->moderationCache,
$this->entitiesBuilder,
$this->db,
$this->save
);
}
......@@ -97,32 +118,79 @@ class ManagerSpec extends ObjectBehavior
public function it_should_save_moderated_activites(Entity $activity)
{
$time = time();
$activity->getNsfw()->shouldBeCalled()->willReturn([]);
$activity->getNsfwLock()->shouldBeCalled()->willReturn([]);
$activity->getOwnerEntity()->shouldBeCalled()->willReturn(null);
$activity->getContainerEntity()->shouldBeCalled()->willReturn(null);
$activity->setNsfw([])->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setModeratorGuid('123')->shouldBeCalled();
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->save()->shouldBeCalled();
$this->save($activity, $this->user, null, null, $time);
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_reported_activites(Entity $activity)
{
$time = time();
$activity->getNsfw()->shouldBeCalled()->willReturn([]);
$activity->getNsfwLock()->shouldBeCalled()->willReturn([]);
$activity->getOwnerEntity()->shouldBeCalled()->willReturn(null);
$activity->getContainerEntity()->shouldBeCalled()->willReturn(null);
$activity->setNsfw([])->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->setModeratorGuid('123')->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_an_attachment(Entity $activity, Image $image)
{
$time = time();
$image->setModeratorGuid(123)->shouldBeCalled();
$image->setTimeModerated($time)->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$this->entitiesBuilder->single(1)->shouldBeCalled()->willReturn($image);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(1);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->save()->shouldBeCalled();
$activity->setModeratorGuid(123)->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($image)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_a_blog(Blog $blog)
{
$time = time();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$blog->getType()->shouldBeCalled()->willReturn('object');
$blog->getGuid()->shouldBeCalled()->willReturn(1);
$blog->setTimeModerated($time)->shouldBeCalled();
$blog->setModeratorGuid('123')->shouldBeCalled();
$this->save->save()->shouldBeCalled();
$this->save->setEntity($blog)->shouldBeCalled()->willReturn($this->save);
$this->save($blog, $this->user, $time);
}
$this->save($activity, $this->user, 1, 1, $time);
public function it_should_save_a_linked_entity(Entity $activity, Entity $parent)
{
$time = time();
$parent->setTimeModerated($time)->shouldBeCalled();
$parent->setModeratorGuid('123')->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()
->willReturn([2 => $parent]);
$this->entitiesBuilder->single(2)->shouldBeCalled()->willReturn($parent);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->setModeratorGuid('123')->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($parent)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
private function getMockActivities(bool $moderated = false)
......
......@@ -27,7 +27,7 @@ class EventsSpec extends ObjectBehavior
expect(Dispatcher::trigger('notification', 'mock', [
'to' => [ $to_user_a->guid, $to_user_b->guid ],
'from' => $from_user,
'entity' => $entity,
'entity' => $entity->getWrappedObject(),
'notification_view' => 'mock_test',
'description' => 'I am a mock',
'params' => [ 'message' => 'I am foobar' ],
......
......@@ -36,7 +36,8 @@ class ObjectBlogMappingSpec extends ObjectBehavior
$blog->getTags()->willReturn([ 'art' ]);
$blog->getRating()->willReturn(1);
$blog->getNsfw()->willReturn([ 1 ]);
$blog->getModeratorGuid()->willReturn('3');
$blog->getTimeModerated()->willReturn($now);
$this
->setEntity($blog)
->map([
......@@ -64,6 +65,8 @@ class ObjectBlogMappingSpec extends ObjectBehavior
'public' => true,
'tags' => [ 'art', 'test', 'hashtag' ],
'rating' => 1,
'moderator_guid' => '3',
'@moderated' => $now * 1000
]);
}
}
......@@ -15,6 +15,8 @@
* @property int $access_id Specifies the visibility level of this entity
* @property int $time_created A UNIX timestamp of when the entity was created (read-only, set on first save)
* @property int $time_updated A UNIX timestamp of when the entity was last updated (automatically updated on save)
* @property int $moderator_guid The GUID of the moderator
* @property int $moderated_at A UNIX timestamp of when the entity was moderated
* @property-read string $enabled
*/
abstract class ElggEntity extends ElggData implements
......@@ -1631,11 +1633,19 @@ abstract class ElggEntity extends ElggData implements
return "urn:entity:{$this->getGuid()}";
}
/** gets the guid of the moderator
* @return int
*/
public function getModeratorGuid() {
return $this->moderator_guid;
}
/**
* Marks the user as moderated by a user
* @param int $moderatorGuid the moderator
*/
public function setModeratorGuid($moderatorGuid)
public function setModeratorGuid(int $moderatorGuid)
{
$this->moderator_guid = $moderatorGuid;
}
......@@ -1644,8 +1654,16 @@ abstract class ElggEntity extends ElggData implements
* Marks the time as when an entity was moderated
* @param int $timeModerated unix timestamp when the entity was moderated
*/
public function setTimeModerated($timeModerated)
public function setTimeModerated(int $timeModerated)
{
$this->time_moderated = $timeModerated;
}
}
/**
* Gets the time moderated
* @return int
*/
public function getTimeModerated() {
return $this->time_moderated;
}
}
......@@ -13,10 +13,6 @@ ADD --chown=www-data . /var/www/Minds/engine
RUN rm -f /var/www/Minds/engine/settings.php
# Install awscli
RUN apk update && apk add --no-cache py-pip && pip install --upgrade pip && pip install awscli
# Copy secrets script
COPY containers/php-fpm/pull-secrets.sh pull-secrets.sh
......
......@@ -8,10 +8,6 @@ ADD --chown=www-data . /var/www/Minds/engine
RUN rm -f /var/www/Minds/engine/settings.php
# Install awscli
RUN apk update && apk add --no-cache py-pip && pip install --upgrade pip && pip install awscli
# Setup our supervisor service
RUN apk add --no-cache \
......
......@@ -8,10 +8,6 @@ ADD --chown=www-data . /var/www/Minds/engine
RUN rm -f /var/www/Minds/engine/settings.php
# Install awscli
RUN apk update && apk add --no-cache py-pip && pip install --upgrade pip && pip install awscli
# Setup our supervisor service
RUN apk add --no-cache \
......
......@@ -84,6 +84,10 @@ RUN apk add --update --no-cache nodejs
RUN apk add --no-cache ffmpeg
# Install awscli
RUN apk update && apk add --no-cache py-pip && pip install --upgrade pip && pip install awscli
# PHP INI
COPY php.ini /usr/local/etc/php/
......
......@@ -8,10 +8,6 @@ ADD --chown=www-data . /var/www/Minds/engine
RUN rm -f /var/www/Minds/engine/settings.php
# Install awscli
RUN apk update && apk add --no-cache py-pip && pip install --upgrade pip && pip install awscli
# Setup our supervisor service
RUN apk add --no-cache \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment