...
 
Commits (19)
......@@ -176,15 +176,16 @@ production:runners:
stage: deploy:production
image: minds/ci:latest
script:
- IMAGE_LABEL="production"
- $(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 $ECR_REPOSITORY_URL_RUNNERS
- docker push $ECR_REPOSITORY_URL_RUNNERS:production
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL_RUNNERS:$IMAGE_LABEL
# Push gitlab registry
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:latest
- docker push $CI_REGISTRY_IMAGE/runners:latest
- docker tag $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL
- docker push $CI_REGISTRY_IMAGE/runners:$IMAGE_LABEL
- aws ecs update-service --service=$ECS_RUNNERS_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
only:
refs:
......
......@@ -222,6 +222,11 @@ class channel implements Interfaces\Api
}
}
if (isset($_POST['nsfw']) && is_array($_POST['nsfw'])) {
$nsfw = array_unique(array_merge($_POST['nsfw'], $owner->getNsfwLock()));
$update['nsfw'] = json_encode($nsfw);
$owner->setNsfw($nsfw);
}
if (isset($_POST['tags']) && $_POST['tags']) {
$update['tags'] = json_encode($_POST['tags']);
......
......@@ -144,11 +144,11 @@ class comments implements Interfaces\Api
break;
case is_numeric($pages[0]):
default:
$entity = new \Minds\Entities\Entity($pages[0]);
$entity = Core\Di\Di::_()->get('EntitiesBuilder')->single($pages[0]);
if ($entity instanceof Entities\Activity && $entity->remind_object) {
$entity = (object) $entity->remind_object;
}
// if ($entity instanceof Entities\Activity && $entity->remind_object) {
// $entity = (object) $entity->remind_object;
// }
if (!$pages[0] || !$entity || $entity->type == 'comment') {
return Factory::response([
......@@ -157,12 +157,12 @@ class comments implements Interfaces\Api
]);
}
if (!$entity->getAllowComments()) {
if (method_exists($entity, 'getAllowComments') && !$entity->getAllowComments()) {
return Factory::response([
'status' => 'error',
'message' => 'Comments are disabled for this post'
]);
}
}
if (!$_POST['comment'] && !$_POST['attachment_guid']) {
return Factory::response([
......@@ -171,13 +171,6 @@ class comments implements Interfaces\Api
]);
}
if ($entity instanceof Entities\Activity && !$entity->commentsEnabled) {
return Factory::response([
'status' => 'error',
'message' => 'Comments are disabled for this post'
]);
}
/*if (!Security\ACL::_()->write($entity)) {
return Factory::response([
'status' => 'error',
......@@ -207,7 +200,13 @@ class comments implements Interfaces\Api
$comment->setParentGuidL2($_POST['parentGuidL2']);
}
if ($entity->type == 'group') {
if ($entity instanceof Entities\Group) {
if ($entity->isConversationDisabled()) {
return Factory::response([
'status' => 'error',
'message' => 'Conversation has been disabled for this group',
]);
}
$comment->setGroupConversation(true);
}
......
......@@ -94,6 +94,17 @@ class forgotpassword implements Interfaces\Api, Interfaces\ApiIgnorePam
break;
}
try {
if (!validate_password($_POST['password'])) {
$response['status'] = "error";
$response['message'] = "Password must have more than 8 characters. Including uppercase, numbers, special characters (ie. !,#,@), and cannot have spaces.";
}
} catch (\Exception $e) {
$response['status'] = "error";
$response['message'] = "Password must have more than 8 characters. Including uppercase, numbers, special characters (ie. !,#,@), and cannot have spaces.";
break;
}
//$user->salt = Core\Security\Password::salt();
$user->password = Core\Security\Password::generate($user, $_POST['password']);
$user->password_reset_code = "";
......
......@@ -184,6 +184,10 @@ class group implements Interfaces\Api
$group->setVideoChatDisabled($_POST['videoChatDisabled']);
}
if (isset($_POST['conversationDisabled'])) {
$group->setConversationDisabled($_POST['conversationDisabled']);
}
if (isset($_POST['tags'])) {
$tags = $_POST['tags'];
$sanitized_tags = [];
......
......@@ -335,6 +335,7 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
}
// Create activity post
/** @var Core\Media\Feeds $feeds */
$feeds = Di::_()->get('Media\Feeds')->setEntity($entity);
if (
......
......@@ -116,10 +116,10 @@ class feed implements Interfaces\Api
$next = $boosts[1]->getTimestamp();
}
$ttl = 1800; // 30 minutes
if (($next / 1000) < strtotime('48 hours ago')) {
$ttl = 300; // 5 minutes;
}
// $ttl = 1800; // 30 minutes
// if (($next / 1000) < strtotime('48 hours ago')) {
$ttl = 150; // 2.5 minutes;
// }
$cacher->set(Core\Session::getLoggedinUser()->guid . ':boost-offset-rotator', $next, $ttl);
break;
......
<?php
/**
* Pageview analytics
*/
namespace Minds\Controllers\api\v2\mwa;
use Minds\Api\Factory;
use Minds\Core;
use Minds\Core\Di\Di;
use Minds\Common\Cookie;
use Minds\Entities;
use Minds\Helpers\Counters;
use Minds\Interfaces;
class pv implements Interfaces\Api, Interfaces\ApiIgnorePam
{
public function get($pages)
{
return Factory::response([]);
}
public function post($pages)
{
if (!isset($_POST['url'])) {
return Factory::response([
'status' => 'error',
'message' => 'You must provide a url'
]);
}
if (!isset($_COOKIE['mwa'])) {
//@TODO make this more unique
$id = uniqid(true);
$cookie = new Cookie();
$cookie
->setName('mwa')
->setValue($id)
->setExpire(time() + (60 * 60 * 24 * 30 * 12))
->setPath('/')
->create();
$_COOKIE['mwa'] = $id;
}
$url = strtok($_POST['url'], '?');
$event = new Core\Analytics\Metrics\Event();
$event
->setType('action')
->setProduct('platform')
->setAction('pageview')
->setRouteUri($url)
->setUserAgent($_SERVER['HTTP_USER_AGENT'])
->setCookieId($_COOKIE['mwa']);
if (isset($_POST['referrer']) && $_POST['referrer']) {
$event->setReferrerUri((string) $_POST['referrer']);
}
if (Core\Session::isLoggedIn()) {
$event->setLoggedIn(true);
}
$event->push();
return Factory::response([]);
}
public function put($pages)
{
return Factory::response([]);
}
public function delete($pages)
{
return Factory::response([]);
}
}
<?php
/**
* @author: eiennohi.
*/
namespace Minds\Core\Media\Delegates;
use Minds\Core\Data\Call;
use Minds\Entities\Image;
use Minds\Entities\Video;
class UpdateActivities
{
/** @var Call */
private $indexDb;
private $entityDb;
public function __construct($indexDb = null, $entityDb = null)
{
$this->indexDb = $indexDb ?: new Call('entities_by_time');
$this->entityDb = $entityDb ?: new Call('entities');
}
/**
* @param Image|Video $entity
*/
public function updateActivities($entity)
{
foreach ($this->indexDb->getRow("activity:entitylink:{$entity->guid}") as $guid => $ts) {
$this->entityDb->insert($guid, ['message' => $entity->title]);
$parameters = $entity->getActivityParameters();
$this->entityDb->insert($guid, ['custom_type' => $parameters[0]]);
$this->entityDb->insert($guid, ['custom_data' => json_encode($parameters[1])]);
}
}
}
<?php
namespace Minds\Core\Media;
use Minds\Core;
use Minds\Entities;
use Minds\Helpers;
use Minds\Core\Media;
class Feeds
{
private $indexDb;
private $entityDb;
private $updateActivitiesDelegate;
protected $entity;
public function __construct($indexDb, $entityDb)
public function __construct($updateActivitiesDelegate = null)
{
$this->indexDb = $indexDb;
$this->entityDb = $entityDb;
$this->updateActivitiesDelegate = $updateActivitiesDelegate ?: new Delegates\UpdateActivities();
}
public function setEntity($entity)
......@@ -54,11 +54,7 @@ class Feeds
throw new \Exception('Entity not set');
}
foreach ($this->indexDb->getRow("activity:entitylink:{$this->entity->guid}") as $guid => $ts) {
$this->entityDb->insert($guid, [ 'message' => $this->entity->title ]);
}
return true;
$this->updateActivitiesDelegate->updateActivities($this->entity);
}
public function dispatch(array $targets = [])
......
......@@ -17,7 +17,7 @@ class MediaProvider extends Provider
}, ['useFactory' => true]);
$this->di->bind('Media\Feeds', function ($di) {
return new Feeds(new Core\Data\Call('entities_by_time'), new Core\Data\Call('entities'));
return new Feeds();
}, ['useFactory' => true]);
$this->di->bind('Media\Repository', function ($di) {
......
......@@ -101,6 +101,10 @@ class Manager
// TODO: make this a bulk request vs sequential
foreach ($response as $suggestion) {
$entity = $suggestion->getEntity() ?: $this->entitiesBuilder->single($suggestion->getEntityGuid());
if ($entity->getDeleted()) {
error_log("Deleted entity ".$entity->guid." has been omitted from suggestions t-".time());
break;
}
$suggestion->setEntity($entity);
}
......
......@@ -41,6 +41,7 @@ class Group extends NormalizedEntity
protected $mature = false;
protected $rating = 1;
protected $videoChatDisabled = 0; // enable by default
protected $conversationDisabled = 0; // enable by default
protected $pinned_posts = [];
protected $nsfw = [];
protected $nsfw_lock = [];
......@@ -63,6 +64,7 @@ class Group extends NormalizedEntity
'mature',
'rating',
'videoChatDisabled',
'conversationDisabled',
'pinned_posts',
];
......@@ -103,6 +105,7 @@ class Group extends NormalizedEntity
'rating' => $this->rating,
'mature' => $this->mature,
'videoChatDisabled' => $this->videoChatDisabled,
'conversationDisabled' => $this->conversationDisabled,
'pinned_posts' => $this->pinned_posts,
'nsfw' => $this->getNSFW(),
'nsfw_lock' => $this->getNSFWLock()
......@@ -403,6 +406,24 @@ class Group extends NormalizedEntity
return $this;
}
/**
* @return bool
*/
public function isConversationDisabled()
{
return (bool) $this->conversationDisabled;
}
/**
* @param $value
* @return $this
*/
public function setConversationDisabled($value)
{
$this->conversationDisabled = $value ? 1 : 0;
return $this;
}
/**
* Gets `owner_guids`
* @return mixed
......
......@@ -71,8 +71,6 @@ abstract class ElggEntity extends ElggData implements
$this->attributes['tags'] = null;
$this->attributes['nsfw'] = [];
$this->attributes['nsfw_lock'] = [];
$this->attributes['nsfw'] = [];
$this->attributes['nsfw_lock'] = [];
$this->attributes['moderator_guid'] = null;
$this->attributes['time_moderated'] = null;
$this->attributes['allow_comments'] = true;
......