...
 
Commits (13)
......@@ -40,7 +40,13 @@ prepare:fpm:
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 build \
-t $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF \
-f containers/php-fpm/Dockerfile \
--build-arg MINDS_VERSION=$CI_BUILD_REF \
--build-arg SENTRY_DSN=$SENTRY_DSN \
.
- docker push $CI_REGISTRY_IMAGE/fpm:$CI_BUILD_REF
prepare:runners:
......@@ -48,9 +54,25 @@ prepare:runners:
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 build \
-t $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF \
-f containers/php-runners/Dockerfile \
--build-arg MINDS_VERSION=$CI_BUILD_REF \
--build-arg SENTRY_DSN=$SENTRY_DSN \
.
- docker push $CI_REGISTRY_IMAGE/runners:$CI_BUILD_REF
prepare:all:sentry:
stage: prepare
image: getsentry/sentry-cli
script:
- echo "Create a new release $CI_COMMIT_SHA"
- sentry-cli releases new $CI_COMMIT_SHA
- sentry-cli releases set-commits --auto $CI_COMMIT_SHA
- sentry-cli releases finalize $CI_COMMIT_SHA
- echo "Finalized release for $CI_COMMIT_SHA"
review:start:
stage: review
image: minds/helm-eks:latest
......@@ -69,6 +91,7 @@ review:start:
--wait \
$CI_BUILD_REF_SLUG \
./helm-charts/minds"
- sentry-cli releases deploys $CI_COMMIT_SHA new -e review-$CI_COMMIT_REF_SLUG
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
......@@ -112,6 +135,8 @@ staging:fpm:
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Deploy to staging
- aws ecs update-service --service=$ECS_APP_STAGING_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
environment:
name: staging
url: https://www.minds.com/?staging=1
......@@ -136,6 +161,8 @@ canary:fpm:
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Deploy to ECS
- aws ecs update-service --service=$ECS_APP_CANARY_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
only:
refs:
- master
......@@ -162,6 +189,8 @@ production:fpm:
- docker push $CI_REGISTRY_IMAGE/fpm:$IMAGE_LABEL
# Delpoy to ECS
- aws ecs update-service --service=$ECS_APP_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
# Update sentry
- sentry-cli releases deploys $CI_COMMIT_SHA new -e $IMAGE_LABEL
only:
refs:
- master
......@@ -176,15 +205,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:
......
......@@ -146,9 +146,9 @@ class comments implements Interfaces\Api
default:
$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([
......
......@@ -27,12 +27,16 @@ class overview implements Interfaces\Api
->setUser(Session::getLoggedinUser())
->calculate();
$contributionValues = Contributions\ContributionValues::$multipliers;
$response = [
'nextPayout' => $overview->getNextPayout(),
'currentReward' => $overview->getCurrentReward(),
'yourContribution' => $overview->getYourContribution(),
'totalNetworkContribution' => $overview->getTotalNetworkContribution(),
'yourShare' => $overview->getYourShare(),
'yourRewardFactor' => 1,
'contributionValues' => $contributionValues
];
return Factory::response($response);
}
......
......@@ -47,6 +47,7 @@ class feed implements Interfaces\Api
$rating = intval($_GET['rating'] ?? $currentUser->getBoostRating());
$platform = $_GET['platform'] ?? 'other';
$quality = 0;
$isBoostFeed = $_GET['boostfeed'] ?? false;
if ($limit === 0) {
return Factory::response([
......@@ -59,6 +60,10 @@ class feed implements Interfaces\Api
$cacher = Core\Data\cache\factory::build('Redis');
$offset = $cacher->get(Core\Session::getLoggedinUser()->guid . ':boost-offset-rotator');
if ($isBoostFeed) {
$offset = $_GET['from_timestamp'] ?? 0;
}
// Options specific to newly created users (<=1 hour) and iOS users
if ($platform === 'ios') {
......@@ -112,14 +117,21 @@ class feed implements Interfaces\Api
$next = $iterator->getOffset();
if (isset($boosts[1])) { // Always offset to 2rd in list
$next = $boosts[1]->getTimestamp();
if (isset($boosts[1]) && !$isBoostFeed) { // Always offset to 2rd in list if in rotator
if (!$offset) {
$next = $boosts[1]->getTimestamp();
} else {
$next = 0;
}
} elseif ($isBoostFeed) {
$len = count($boosts);
$next = $boosts[$len -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;
......
......@@ -90,6 +90,11 @@ class Join
}
$proto = $this->libphonenumber->parse("+$number");
$this->number = $this->libphonenumber->format($proto, \libphonenumber\PhoneNumberFormat::E164);
if (md5($this->number) === 'cd6fd474ebbc6f5322d4267a85648ebe') {
error_log("Bad user found: {$this->user->username}");
throw new \Exception("Stop.");
}
return $this;
}
......
......@@ -358,6 +358,8 @@ class Events
$twofactor = new TwoFactor();
$secret = $twofactor->createSecret(); //we have a new secret for each request
error_log('2fa - sending SMS to ' . $user->guid);
$this->sms->send($user->telno, $twofactor->getCode($secret));
// create a lookup of a random key. The user can then use this key along side their twofactor code
......
<?php
namespace Minds\Core\Sessions\Delegates;
use Sentry;
use Minds\Core\Sessions\Session;
class SentryScopeDelegate
{
/**
* Pass through a user guid to sentry
* @param Session $session
* @return void
*/
public function onSession(Session $session): void
{
Sentry\configureScope(function (Sentry\State\Scope $scope) use ($session): void {
$scope->setUser([
'id' => (string) $session->getUserGuid(),
]);
});
}
}
......@@ -23,6 +23,9 @@ class Manager
/** @var Cookie $cookie */
private $cookie;
/** @var SentryScopeDelegate $sentryScopeDelegate */
private $sentryScopeDelegate;
/** @var Session $session */
private $session;
......@@ -34,7 +37,8 @@ class Manager
$config = null,
$cookie = null,
$jwtBuilder = null,
$jwtParser = null
$jwtParser = null,
$sentryScopeDelegate = null
)
{
$this->repository = $repository ?: new Repository;
......@@ -42,6 +46,7 @@ class Manager
$this->cookie = $cookie ?: new Cookie;
$this->jwtBuilder = $jwtBuilder ?: new JWT\Builder;
$this->jwtParser = $jwtParser ?: new JWT\Parser;
$this->sentryScopeDelegate = $sentryScopeDelegate ?? new Delegates\SentryScopeDelegate;
}
/**
......@@ -124,6 +129,9 @@ class Manager
// Hack, needs refactoring
Core\Session::generateJWTCookie($session);
// Allow Sentry to attach user metadata
$this->sentryScopeDelegate->onSession($session);
return $this;
}
......
This diff is collapsed.
......@@ -25,4 +25,12 @@ COPY containers/php-fpm/pull-secrets.sh pull-secrets.sh
COPY containers/php-fpm/php.ini /usr/local/etc/php/
COPY containers/php-fpm/opcache.ini /usr/local/etc/php/conf.d/opcache-recommended.ini
COPY containers/php-fpm/apcu.ini /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
COPY containers/php-fpm/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
\ No newline at end of file
COPY containers/php-fpm/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
# Specify the build args
ARG MINDS_VERSION="Unknown"
ENV MINDS_VERSION=${MINDS_VERSION}
ARG SENTRY_DSN=""
ENV SENTRY_DSN=${SENTRY_DSN}
......@@ -21,4 +21,9 @@ catch_workers_output = yes
request_terminate_timeout = 120s
rlimit_files = 65535
\ No newline at end of file
rlimit_files = 65535
clear_env = no
env[MINDS_VERSION] = $MINDS_VERSION
env[MINDS_ENV] = $MINDS_ENV
env[SENTRY_DSN] = $SENTRY_DSN
......@@ -22,4 +22,12 @@ COPY containers/php-runners/pull-secrets.sh pull-secrets.sh
COPY ./containers/php-runners/supervisord.conf /etc
COPY ./containers/php-runners/minds.conf /etc/supervisor/conf.d
ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisord.conf"]
\ No newline at end of file
# Specify the build args
ARG MINDS_VERSION="Unknown"
ENV MINDS_VERSION=${MINDS_VERSION}
ARG SENTRY_DSN=""
ENV SENTRY_DSN=${SENTRY_DSN}
ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisord.conf"]
......@@ -849,7 +849,9 @@ function _elgg_php_exception_handler($exception) {
// make sure the error isn't cached
header("Cache-Control: no-cache, must-revalidate", true);
header('Expires: Fri, 05 Feb 1982 00:00:00 -0500', true);
// @note Do not send a 500 header because it is not a server error
// @note Do not send a 500 header because it is not a server error
Sentry\captureException($exception);
}
/**
......@@ -940,7 +942,9 @@ function fatalErrorShutdownHandler(){
header('Fatal error', true, 500);
echo file_get_contents(dirname(dirname(dirname(__FILE__))) . '/errors/500.html');
}
}
\Sentry\captureLastError();
}
/**
......
......@@ -19,5 +19,13 @@ define('__MINDS_ROOT__', dirname(__FILE__));
*/
require_once(__MINDS_ROOT__ . '/vendor/autoload.php');
// Sentry
Sentry\init([
'dsn' => getenv('SENTRY_DSN'),
'release' => getenv('MINDS_VERSION') ?: 'Unknown',
'environment' => getenv('MINDS_ENV') ?: 'development',
'send_default_pii' => false,
]);
$minds = new Minds\Core\Minds();
$minds->start();