Skip to content
Commits on Source (9)
......@@ -25,13 +25,22 @@ class plus implements Interfaces\Api
*/
public function get($pages)
{
$response = [];
$user = Core\Session::getLoggedInUser();
if (!$user) {
return Factory::response([
'status' => 'error',
'message' => 'Invalid user'
]);
}
$plus = new Core\Plus\Subscription();
$plus->setUser(Core\Session::getLoggedInUser());
$response['active'] = $plus->isActive();
$plus->setUser($user);
return Factory::response($response);
return Factory::response([
'active' => $plus->isActive(),
'can_be_cancelled' => $plus->canBeCancelled()
]);
}
public function post($pages)
......
You've received a gift of 1 Minds token! You can spend this token to earn 1,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'] ?>) |
| |
......@@ -13,6 +13,7 @@ class Subscription
{
private $stripe;
private $repo;
/** @var User */
protected $user;
/** @var Manager $subscriptionsManager */
protected $subscriptionsManager;
......@@ -44,13 +45,15 @@ class Subscription
*/
public function isActive()
{
$subscription = $this->getSubscription();
if (!$subscription) {
return false;
}
return $this->user->isPlus();
}
return $subscription->getStatus() == 'active';
/**
* @return bool
*/
public function canBeCancelled()
{
return ((int) $this->user->plus_expires) > time();
}
/**
......
......@@ -1510,3 +1510,18 @@ CREATE MATERIALIZED VIEW minds.pro_by_domain AS
WHERE user_guid IS NOT NULL AND domain IS NOT NULL
PRIMARY KEY (domain, user_guid)
WITH CLUSTERING ORDER BY (user_guid ASC);
CREATE TABLE minds.subscription_requests (
publisher_guid bigint,
subscriber_guid bigint,
timestamp timestamp,
declined boolean,
PRIMARY KEY (publisher_guid, subscriber_guid)
);
CREATE TABLE minds.notification_batches (
user_guid varint,
batch_id text,
primary key (user_guid, batch_id)
);
......@@ -171,7 +171,7 @@ class EntityMapping implements MappingInterface
$fullText .= ' ' . $map['message'];
}
$htRe = '/(^|\s||)#(\w*[a-zA-Z_]+\w*)/';
$htRe = '/(^|\s||)#(\w*[a-zA-Z0-9_]+\w*)/';
$matches = [];
preg_match_all($htRe, $fullText, $matches);
......
......@@ -902,11 +902,11 @@ class User extends \ElggUser
/**
* Is the user a plus user.
*
* @return int
* @return bool
*/
public function isPlus()
{
return (bool) ((int) $this->plus_expires > time());
return $this->isPro() || ((int) $this->plus_expires > time());
}
/**
......
......@@ -75,8 +75,8 @@ class EmailRewards
$validator = $_GET['validator'];
//$key = '.md';
//return;
if ($validator == sha1($campaign . 'gift-30-09-19.mdl' . $topic . $user->guid . Config::_()->get('emails_secret'))) {
$tokens = 2 * (10 ** 18);
if ($validator == sha1($campaign . 'gift-30-10-19.mdl' . $topic . $user->guid . Config::_()->get('emails_secret'))) {
$tokens = 1 * (10 ** 18);
$campaign = $validator; //hack
} else {
return;
......
......@@ -22,41 +22,35 @@ class SubscriptionSpec extends ObjectBehavior
public function it_should_return_if_a_subscription_is_active(
Stripe $stripe,
Repository $repo,
Subscription $subscription
User $user
) {
$this->beConstructedWith($stripe, null, $repo);
$repo->getList(Argument::any())->willReturn([
$subscription
]);
$subscription->getStatus()->willReturn('active');
$user = new User();
$user->guid = 123;
$user->isPlus()
->shouldBeCalled()
->willReturn(true);
$this->setUser($user);
$this->isActive()->shouldBe(true);
$this
->setUser($user)
->isActive()
->shouldBe(true);
}
public function it_should_return_false_if_a_subscription_is_active(
Stripe $stripe,
Repository $repo,
Subscription $subscription
User $user
) {
$this->beConstructedWith($stripe, null, $repo);
$repo->getList(Argument::any())->willReturn([
$subscription
]);
$subscription->getStatus()->willReturn('cancelled');
$user = new User();
$user->guid = 123;
$user->isPlus()
->shouldBeCalled()
->willReturn(false);
$this->setUser($user);
$this->isActive()->shouldBe(false);
$this
->setUser($user)
->isActive()
->shouldBe(false);
}
public function is_should_create_a_new_subscription(
......