...
 
Commits (2)
image: minds/php:latest
services:
- docker:dind
image: minds/php:7.3
stages:
- build
......@@ -16,7 +13,7 @@ stages:
build:
stage: build
script:
- apk update && apk add --no-cache git
- apk add --no-cache git
- sh tools/setup.sh production
artifacts:
name: '$CI_COMMIT_REF_SLUG'
......@@ -26,19 +23,21 @@ build:
test:
stage: test
image: minds/php-tests:latest
image: minds/php:7.3
script:
- bin/phpspec run
- php -n -c Spec/php-test.ini bin/phpspec run
lint:
stage: test
image: minds/php-tests:latest
image: minds/php:7.3
script:
- bin/php-cs-fixer fix --allow-risky=yes --verbose --dry-run
prepare:fpm:
stage: prepare
image: minds/ci:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- |
......@@ -53,6 +52,8 @@ prepare:fpm:
prepare:runners:
stage: prepare
image: minds/ci:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- |
......@@ -136,6 +137,8 @@ qa:manual:
staging:fpm:
stage: deploy:staging
image: minds/ci:latest
services:
- docker:dind
script:
- IMAGE_LABEL="staging"
- $(aws ecr get-login --no-include-email --region us-east-1)
......@@ -162,6 +165,8 @@ staging:fpm:
canary:fpm:
stage: deploy:canary
image: minds/ci:latest
services:
- docker:dind
script:
- IMAGE_LABEL="canary"
- $(aws ecr get-login --no-include-email --region us-east-1)
......@@ -190,6 +195,8 @@ canary:fpm:
production:fpm:
stage: deploy:production
image: minds/ci:latest
services:
- docker:dind
script:
- IMAGE_LABEL="production"
- $(aws ecr get-login --no-include-email --region us-east-1)
......@@ -218,6 +225,8 @@ production:fpm:
production:runners:
stage: deploy:production
image: minds/ci:latest
services:
- docker:dind
script:
- IMAGE_LABEL="production"
- $(aws ecr get-login --no-include-email --region us-east-1)
......
......@@ -40,12 +40,14 @@ class CustomerSync extends Cli\Controller implements Interfaces\CliControllerInt
$guid = $data[29];
try {
$insert = new Core\Data\Cassandra\Prepared\Custom();
$insert->query("INSERT INTO user_index_to_guid (key, column1, value) VALUES (?, ?, ?)",
[
$insert->query(
"INSERT INTO user_index_to_guid (key, column1, value) VALUES (?, ?, ?)",
[
"$guid:payments",
"customer_id",
$id
]);
]
);
$this->db->request($insert);
$this->out("$guid with customer id $id done");
} catch (\Exception $e) {
......
......@@ -56,18 +56,21 @@ class SubscriptionSync extends Cli\Controller implements Interfaces\CliControlle
$amount = ($result->quantity * $result->plan->amount) / 100;
$insert = new Core\Data\Cassandra\Prepared\Custom();
$insert->query("INSERT INTO plans (user_guid, plan, entity_guid, amount) VALUES (?, ?, ?, ?)",
[
$insert->query(
"INSERT INTO plans (user_guid, plan, entity_guid, amount) VALUES (?, ?, ?, ?)",
[
$plan['user_guid'],
$plan['plan'],
$plan['entity_guid'],
(int) $amount
]);
]
);
$this->db->request($insert);
if ($plan['plan'] == 'exclusive') {
$query = new Core\Data\Cassandra\Prepared\Custom();
$query->query("INSERT INTO wire
$query->query(
"INSERT INTO wire
(receiver_guid, sender_guid, method, timestamp, entity_guid, wire_guid, amount, recurring, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
[
......@@ -80,7 +83,8 @@ class SubscriptionSync extends Cli\Controller implements Interfaces\CliControlle
new \Cassandra\Decimal($amount),
true,
'success'
]);
]
);
$this->db->request($query);
}
......
......@@ -36,8 +36,12 @@ class report implements Interfaces\Api
/** @var Core\Reports\Repository $repository */
$repository = Di::_()->get('Reports\Repository');
$done = $repository->create($pages[0], Core\Session::getLoggedinUser(),
$reason, $reason_note);
$done = $repository->create(
$pages[0],
Core\Session::getLoggedinUser(),
$reason,
$reason_note
);
return Factory::response([
'done' => $done
......
......@@ -85,7 +85,7 @@ class media implements Interfaces\Api, Interfaces\ApiIgnorePam
Security\ACL::$ignore = $ignore;
}
/* No break */
/* no break */
default:
$entity->fullExport = true;
$response['entity'] = $entity->export();
......
......@@ -299,28 +299,6 @@ class merchant implements Interfaces\Api
$response['uploaded'] = true;
}
break;
case "charge":
$sale = (new Payments\Sale)
->setId($pages[1]);
try {
Payments\Factory::build('braintree', ['gateway'=>'merchants'])->chargeSale($sale);
} catch (\Exception $e) {
var_dump($e);
exit;
}
exit;
break;
case "void":
$sale = (new Payments\Sale)
->setId($pages[1]);
Payments\Factory::build('braintree', ['gateway'=>'merchants'])->voidSale($sale);
break;
case "refund":
$sale = (new Payments\Sale)
->setId($pages[1]);
Payments\Factory::build('braintree', ['gateway'=>'merchants'])->refundSale($sale);
break;
}
return Factory::response($response);
......
......@@ -379,7 +379,7 @@ class newsfeed implements Interfaces\Api
->setTitle($embeded->title)
->setBlurb($embeded->description)
->export()
)
)
->setMessage($message);
}
$save->setEntity($activity)
......@@ -417,7 +417,7 @@ class newsfeed implements Interfaces\Api
->setTitle($embeded->title)
->setBlurb($embeded->description)
->export()
)
)
->setMessage($message);
}
$save->setEntity($activity)
......
<?php
/**
* Minds Payments API:: braintree
*
* @version 1
* @author Mark Harding
*/
namespace Minds\Controllers\api\v1\payments;
use Minds\Core;
use Minds\Helpers;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Core\Payments;
class braintree implements Interfaces\Api
{
/**
* Returns merchant information
* @param array $pages
*
* API:: /v1/merchant/:slug
*/
public function get($pages)
{
$response = [];
switch ($pages[0]) {
case "token":
$gateway = isset($pages[1]) ? $pages[1] : 'default';
$response['token'] = Payments\Factory::build('braintree', ['gateway'=>$gateway])->getToken();
break;
}
return Factory::response($response);
}
public function post($pages)
{
$response = [];
switch ($pages[0]) {
case "charge":
$amount = $_POST['amount'];
$fee = $amount * 0.05 + 0.30; //5% + $.30
if (!isset($_POST['merchant'])) {
$merchant = Core\Session::getLoggedInUser();
}
$sale = (new Payments\Sale())
->setAmount($amount)
->setMerchant($merchant)
->setFee($fee)
->setCustomerId(Core\Session::getLoggedInUser()->guid)
->setNonce($_POST['nonce']);
try {
$result = Payments\Factory::build('braintree', ['gateway'=>'merchants'])->setSale($sale);
} catch (\Exception $e) {
$response['status'] = "error";
$response['message'] = $e->getMessage();
}
break;
case "charge-master":
$amount = $_POST['amount'];
$sale = (new Payments\Sale())
->setAmount($amount)
->setCustomerId(Core\Session::getLoggedInUser()->guid)
->setSettle(true)
->setFee(0)
->setNonce($_POST['nonce']);
try {
$result = Payments\Factory::build('braintree', ['gateway'=>'merchants'])->setSale($sale);
} catch (\Exception $e) {
$response['status'] = "error";
$response['message'] = $e->getMessage();
}
break;
}
return Factory::response($response);
}
public function put($pages)
{
return Factory::response([]);
}
public function delete($pages)
{
return Factory::response([]);
}
}
......@@ -97,9 +97,6 @@ class subscriptions implements Interfaces\Api
}
$stripe = Core\Di\Di::_()->get('StripePayments');
$stripe->cancelSubscription($subscription);
} else {
$braintree = Payments\Factory::build("Braintree", ['gateway'=>'default']);
$braintree->cancelSubscription($subscription);
}
}
......
<?php
/**
* Minds Webhook: Braintree
*
* @version 1
* @author Mark Harding
*/
namespace Minds\Controllers\api\v1\webhooks;
use Minds\Core;
use Minds\Entities;
use Minds\Interfaces;
use Minds\Api\Factory;
use Minds\Helpers;
use Minds\Core\Payments;
use Braintree_WebhookNotification;
class braintree implements Interfaces\Api, Interfaces\ApiIgnorePam
{
/**
* NOT AVAILABLE
*/
public function get($pages)
{
return Factory::response(['status'=>'error', 'message'=>'GET is not supported for this endpoint']);
}
/**
*/
public function post($pages)
{
error_log("[webhooks]:: hit first entrace point");
/*$gateway = isset($pages[0]) ? $pages[0] : 'default';
$bt = Payments\Factory::build('braintree', ['gateway'=>$gateway]);
$hooks = new Payments\Hooks();
$hooks->loadDefaults();
$webhooks = new Payments\Braintree\Webhooks($hooks, $bt);
$webhooks->setSignature($_POST['bt_signature'])
->setPayload($_POST['bt_payload'])
->run();*/
}
public function put($pages)
{
}
public function delete($pages)
{
}
}
......@@ -48,24 +48,9 @@ class stripe implements Interfaces\Api, Interfaces\ApiIgnorePam
$hooks->run();
// Do something with $event_json
http_response_code(200); // PHP 5.4 or greater
exit;
/*$gateway = isset($pages[0]) ? $pages[0] : 'default';
$bt = Payments\Factory::build('braintree', ['gateway'=>$gateway]);
$hooks = new Payments\Hooks();
$hooks->loadDefaults();
$webhooks = new Payments\Braintree\Webhooks($hooks, $bt);
$webhooks->setSignature($_POST['bt_signature'])
->setPayload($_POST['bt_payload'])
->run();*/
return Factory::response([]);
}
......
......@@ -48,8 +48,10 @@ class peer implements Interfaces\Api
case 'inbox':
default:
$review->setType(Core\Session::getLoggedinUser()->guid);
$boosts = $review->getReviewQueue(isset($_GET['limit']) ? $_GET['limit'] : 12,
isset($_GET['offset']) ? $_GET['offset'] : "");
$boosts = $review->getReviewQueue(
isset($_GET['limit']) ? $_GET['limit'] : 12,
isset($_GET['offset']) ? $_GET['offset'] : ""
);
$response['boosts'] = Factory::exportable($boosts['data']);
......
......@@ -56,6 +56,7 @@ class banners implements Interfaces\FS
$f->owner_guid = $entity->owner_guid ?: $entity->getOwnerObj()->guid;
$f->setFilename("group/{$entity->getGuid()}.jpg");
$f->open('read');
// no break
case "object":
break;
}
......
......@@ -74,11 +74,11 @@ class TokenSaleEvent implements BlockchainEventInterface
$purchase = $this->manager->getPurchase($transaction->getData()['phone_number_hash'], $transaction->getTx());
if (!$purchase) {
echo "purchase not found";
error_log("purchase not found");
return; //purchase not found
}
var_dump($log);
error_log(print_r($log, true));
//is the requested amount below what has already been recorded
if ($transaction->getAmount() > $purchase->getUnissuedAmount()) {
return; //requested more than can issue
......
......@@ -96,7 +96,6 @@ class WithdrawEvent implements BlockchainEventInterface
try {
$this->manager->complete($request, $transaction);
} catch (\Exception $e) {
var_dump($e);
error_log(print_r($e, true));
}
}
......
......@@ -85,11 +85,13 @@ class Pending
public function delete($type, $tx_id)
{
$query = new Core\Data\Cassandra\Prepared\Custom();
$query->query("DELETE FROM blockchain_pending WHERE type = ? AND tx_id = ?",
$query->query(
"DELETE FROM blockchain_pending WHERE type = ? AND tx_id = ?",
[
(string) $type,
(string) $tx_id
]);
]
);
try {
return (bool) $this->db->request($query);
......
......@@ -46,14 +46,16 @@ class Sums
$query = new Custom();
if ($this->user) {
$query->query("SELECT
$query->query(
"SELECT
SUM(amount) as balance
FROM blockchain_transactions_mainnet_by_address
WHERE user_guid = ?
AND wallet_address = 'offchain'",
[
new Varint((int) $this->user->guid)
]);
]
);
$query->setOpts([
'consistency' => \Cassandra::CONSISTENCY_ALL
]);
......
......@@ -49,14 +49,16 @@ class TestnetSums
throw new \Exception('User is not set');
}
$query->query("SELECT
$query->query(
"SELECT
SUM(amount) as balance
FROM blockchain_transactions_by_address
WHERE user_guid = ?
AND wallet_address = 'offchain'",
[
new Varint((int) $this->user->guid)
]);
]
);
$query->setOpts([
'consistency' => \Cassandra::CONSISTENCY_ALL
]);
......
......@@ -47,7 +47,8 @@ class Navigation
->setVisibility(0); //only show for loggedin
$link = new Item();
NavigationManager::add($link
NavigationManager::add(
$link
->setPriority(4)
->setIcon('subject')
->setName('Blogs')
......
......@@ -244,8 +244,10 @@ class Iterator implements \Iterator
foreach ($boosts as $boost) {
$owner_guids[] = $boost->owner_guid;
}
$blocked = array_flip(Core\Security\ACL\Block::_()->isBlocked($owner_guids,
Core\Session::getLoggedInUserGuid()));
$blocked = array_flip(Core\Security\ACL\Block::_()->isBlocked(
$owner_guids,
Core\Session::getLoggedInUserGuid()
));
foreach ($boosts as $i => $boost) {
if (isset($blocked[$boost->owner_guid])) {
......
......@@ -97,10 +97,12 @@ class Repository
return $this;
}
foreach ($this->categories as $category) {
$query->query("INSERT INTO categories
$query->query(
"INSERT INTO categories
(type, category, filter, guid)
VALUES (?, ?, ?, ?)",
[ $this->type, $category, $this->filter, (string) $guid ]);
[ $this->type, $category, $this->filter, (string) $guid ]
);
try {
$result = $this->db->request($query);
} catch (\Exception $e) {
......@@ -116,9 +118,11 @@ class Repository
return $this;
}
foreach ($this->categories as $category) {
$query->query("DELETE FROM categories
$query->query(
"DELETE FROM categories
WHERE type = ? AND category = ? AND filter = ? AND guid = ?",
[ $this->type, $category, $this->filter, (string) $guid ]);
[ $this->type, $category, $this->filter, (string) $guid ]
);
try {
$result = $this->db->request($query);
} catch (\Exception $e) {
......
......@@ -161,13 +161,15 @@ class Call
array_push(self::$keys, $key);
$options = array_merge(
[
[
'multi' => false,
'offset' => "",
'finish' => "",
'limit' => 500,
'reversed' => true
], $options);
],
$options
);
$query = new Cassandra\Prepared\Custom();
......
......@@ -41,13 +41,13 @@ class Client implements Interfaces\ClientInterface
try {
$statement = $this->session->prepare($cql['string']);
$future = $this->session->executeAsync(
$statement,
@new Driver\ExecutionOptions(array_merge(
[
$statement,
@new Driver\ExecutionOptions(array_merge(
[
'arguments' => $cql['values']
],
$request->getOpts()
))
$request->getOpts()
))
);
if ($silent) {
return $future;
......
......@@ -75,14 +75,16 @@ class DataProvider extends Provider
$sslmode = isset($config['sslmode']) ? $config['sslmode'] : 'disable';
$username = isset($config['username']) ? $config['username'] : 'php';
// This is a generic data object using the postgres driver to connect to cockroachdb.
return new PDO("pgsql:host=$host;port=$port;dbname=$name;sslmode=$sslmode",
return new PDO(
"pgsql:host=$host;port=$port;dbname=$name;sslmode=$sslmode",
$username,
null,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_PERSISTENT => isset($config['persistent']) ? $config['persistent'] : false,
]);
]
);
}, ['useFactory'=>true]);
/**
* Locks
......
......@@ -11,13 +11,15 @@ class Client
public function __construct($dbh = null)
{
$this->dbh = $dbh ?: new PDO('pgsql:host=cockroachdb;port=26257;dbname=minds;sslmode=disable',
$this->dbh = $dbh ?: new PDO(
'pgsql:host=cockroachdb;port=26257;dbname=minds;sslmode=disable',
'maxroach',
null,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => true,
]);
]
);
}
/**
......
......@@ -72,8 +72,10 @@ class EndFacebookSupport
foreach ($this->getUsers() as $user) {
if (!$user instanceof \Minds\Entities\User || !$user->guid || $user->disabled_emails || $user->enabled != "yes") {
$skipped++;
echo "\r [emails]: $queued queued | $skipped skipped | " . date('d-m-Y',
$user->time_created) . " | $user->guid ";
echo "\r [emails]: $queued queued | $skipped skipped | " . date(
'd-m-Y',
$user->time_created
) . " | $user->guid ";
continue;
}
$queued++;
......@@ -95,8 +97,10 @@ class EndFacebookSupport
if (!$this->dryRun) {
$this->mailer->queue($message);
}
echo "\r [emails]: $queued queued | $skipped skipped | " . date('d-m-Y',
$user->time_created) . " | $user->guid ";
echo "\r [emails]: $queued queued | $skipped skipped | " . date(
'd-m-Y',
$user->time_created
) . " | $user->guid ";
}
echo "[emails]: Completed ($queued queued | $skipped skipped) \n";
}
......
......@@ -59,8 +59,10 @@ class GlobalTips extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -70,8 +70,10 @@ class InactiveUsers extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -65,8 +65,10 @@ class Invoice
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1('invoice' . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1('invoice' . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -76,8 +76,10 @@ class MissedSinceLogin extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -73,8 +73,10 @@ class News extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -70,8 +70,10 @@ class Promotion extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -62,8 +62,10 @@ class GoneCold extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -62,8 +62,10 @@ class WelcomeComplete extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -62,8 +62,10 @@ class WelcomeIncomplete extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -60,8 +60,10 @@ class WhenBoost extends EmailCampaign
$subject = 'Your boost is complete';
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -49,8 +49,10 @@ class WhenNotifications extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign.$this->topic.time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -75,8 +75,10 @@ class WhenWire extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -118,8 +118,10 @@ class WirePayment
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->template . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->template . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -75,8 +75,10 @@ class WirePromotions extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($this->subject)
->setHtml($this->template);
......
......@@ -58,8 +58,10 @@ class WithActivity extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -72,8 +72,10 @@ class WithBlogs extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -50,8 +50,10 @@ class WithChannelTips extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -39,8 +39,10 @@ class WithImprovementTips extends EmailCampaign
$message = new Message();
$message->setTo($this->user)
->setMessageId(implode('-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]))
->setMessageId(implode(
'-',
[$this->user->guid, sha1($this->user->getEmail()), sha1($this->campaign . $this->topic . time())]
))
->setSubject($subject)
->setHtml($this->template);
......
......@@ -3,6 +3,12 @@ namespace Minds\Core\Email;
use Minds\Traits\MagicAttributes;
/**
* Class EmailSubscription
* @package Minds\Core\Email
*
* @method string getUserGuid()
*/
class EmailSubscription
{
use MagicAttributes;
......
......@@ -38,10 +38,14 @@ class Manager
$result = $this->repository->getList($options);
if (!$result || count($result['data'] === 0)) {
if (!$result || count($result['data']) === 0) {
return [];
}
/*$guids = [];
foreach($result['data'] as $subscription) {
$guids[] = $subscription->getUserGuid();
}*/
$guids = array_map(function ($item) {
return $item->getUserGuid();
}, $result['data']);
......
......@@ -79,8 +79,8 @@ class Manager
public function save(
$entity,
User $moderator,
int $time = null)
{
int $time = null
) {
if (!$time) {
$time = time();
}
......@@ -92,8 +92,8 @@ class Manager
private function saveEntity(
$entity,
User $moderator,
int $time = null)
{
int $time = null
) {
$entity->setModeratorGuid($moderator->getGUID());
$entity->setTimeModerated($time);
......
......@@ -34,7 +34,8 @@ class Entities
* @param ACL $acl
*/
public function __construct(
$entitiesBuilder = null, $acl = null
$entitiesBuilder = null,
$acl = null
) {
$this->entitiesBuilder = $entitiesBuilder ?: Di::_()->get('EntitiesBuilder');
$this->acl = $acl ?: ACL::_();
......
......@@ -42,7 +42,6 @@ class Notifications
$cql = null,
$notifications = null,
$notificationBatches = null
) {
$this->relDB = $relDb ?: Di::_()->get('Database\Cassandra\Relationships');
$this->indexDb = $indexDb ?: Di::_()->get('Database\Cassandra\Indexes');
......
......@@ -27,7 +27,10 @@ class CurlWrapper
curl_setopt($this->handle, CURLOPT_BUFFERSIZE, 128);
curl_setopt($this->handle, CURLOPT_NOPROGRESS, false);
curl_setopt($this->handle, CURLOPT_PROGRESSFUNCTION, function (
$downloadSize, $downloaded, $uploadSize, $uploaded
$downloadSize,
$downloaded,
$uploadSize,
$uploaded
) use ($limitKb) {
error_log($downloaded);
if ($downloaded) {
......
......@@ -140,7 +140,7 @@ class Resize
// Resize canvas to new image
$frame->setImagePage(0, 0, 0, 0);
// If selected with / height differ from selection width/height, then we need to resize
if ($params['selectionwidth'] !== $params['newwidth'] || $params['selectionheight'] !== $params['newheight']) {
$frame->thumbnailImage($params['newwidth'], $params['newheight']);
......
......@@ -34,21 +34,26 @@ class SEO
$type = ucfirst($slugs[0]);
switch ($slugs[1]) {
case 'top':
return $this->getInfo("Top $type",
return $this->getInfo(
"Top $type",
"$type from channels I'm subscribed to",
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs));
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs)
);
break;
case 'network':
return $this->getInfo("$type from your Network",
return $this->getInfo(
"$type from your Network",
"$type from channels you're subscribed to",
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs));
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs)
);
break;
case 'my':
return $this->getInfo(
"Your $type",
"List of your $type",
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs));
Core\Di\Di::_()->get('Config')->site_url . implode('/', $slugs)
);
break;
}
}
......
......@@ -237,8 +237,10 @@ class FFMpeg implements ServiceInterface
}
$video->filters()
->resize(new \FFMpeg\Coordinate\Dimension($opts['width'], $opts['height']),
$rotated ? ResizeFilter::RESIZEMODE_FIT : ResizeFilter::RESIZEMODE_SCALE_WIDTH)
->resize(
new \FFMpeg\Coordinate\Dimension($opts['width'], $opts['height']),
$rotated ? ResizeFilter::RESIZEMODE_FIT : ResizeFilter::RESIZEMODE_SCALE_WIDTH
)
->synchronize();
$formatMap = [
......
......@@ -116,7 +116,10 @@ class Ads
$dateRange = $payouts->getPayoutDateRange();
$list = $dateRange ? $this->getList(
$dateRange['start'], $dateRange['end'], $offset, $count
$dateRange['start'],
$dateRange['end'],
$offset,
$count
) : [];
return [
......
......@@ -101,14 +101,16 @@ class Repository
public function add(EarningsDeposit $deposit): bool
{
$prepared = new Prepared();
$prepared->query("INSERT INTO partner_earnings_ledger (user_guid, timestamp, item, amount_cents, amount_tokens) VALUES (?,?,?,?,?)",
$prepared->query(
"INSERT INTO partner_earnings_ledger (user_guid, timestamp, item, amount_cents, amount_tokens) VALUES (?,?,?,?,?)",
[
new Bigint($deposit->getUserGuid()),
new Timestamp($deposit->getTimestamp()),
$deposit->getItem(),
$deposit->getAmountCents() ? (int) $deposit->getAmountCents() : null,
$deposit->getAmountTokens() ? new Bigint($deposit->getAmountTokens()) : null,
]);
]
);
return (bool) $this->db->request($prepared);
}
......
......@@ -63,70 +63,80 @@ class Manager
->setTitle('Admin')
->setPath('admin/analytics')
->setVisibility(-1)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(1)
->setIcon('trending_up')
->setName('Boost')
->setTitle('Boost (Admin)')
->setPath('admin/boosts')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(2)
->setIcon('insert_chart')
->setName('Analytics')
->setTitle('Analytics')
->setPath('admin/analytics')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(3)
->setIcon('create')
->setName('Pages')
->setTitle('Pages')
->setPath('admin/pages')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(4)
->setIcon('flag')
->setName('Reports')
->setTitle('Reports')
->setPath('admin/reports')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(5)
->setIcon('attach_money')
->setName('Monetization review')
->setTitle('Monetization review')
->setPath('admin/monetization')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(6)
->setIcon('queue')
->setName('Program applications')
->setTitle('Program applications')
->setPath('admin/programs')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(7)
->setIcon('branding_watermark')
->setName('Payouts queue')
->setTitle('Payouts queue')
->setPath('admin/payouts')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(8)
->setIcon('star')
->setName('Featured')
->setTitle('Featured')
->setPath('admin/featured')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(9)
->setIcon('whatshot')
->setName('Hashtags')
->setTitle('Hashtags')
->setPath('admin/tagcloud')
)
->addSubItem((new Item())
->addSubItem(
(new Item())
->setPriority(10)
->setIcon('verified_user')
->setName('Verfiy')
......
......@@ -157,6 +157,7 @@ class Push implements Interfaces\NotificationExtensionInterface
if (!empty($entity->custom_data)) {
return $entity->custom_data[0]['src'];
}
// no break
default:
return null;
......
This diff is collapsed.
<?php
/**
* Braintree webhooks
*/
namespace Minds\Core\Payments\Braintree;
use Minds\Core;
use Minds\Core\Guid;
use Minds\Core\Payments;
use Minds\Entities;
use Minds\Helpers\Wallet as WalletHelper;
use Minds\Core\Di\Di;
use Minds\Core\Blockchain\Transactions\Transaction;
use Braintree_ClientToken;
use Braintree_Configuration;
use Braintree_MerchantAccount;
use Braintree_Transaction;
use Braintree_TransactionSearch;
use Braintree_Customer;
use Braintree_CustomerSearch;
use Braintree_PaymentMethod;
use Braintree_Subscription;
use Braintree_Test_MerchantAccount;
use Braintree_WebhookNotification;
use Minds\Core\Payments\Subscriptions\Subscription;
class Webhooks
{
protected $payload;
protected $signature;
protected $notification;
protected $aliases = [
Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED => 'subMerchantApproved',
Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED => 'subMerchantDeclined',
'subscription_charged_successfully' => 'subscriptionCharged',
'subscription_went_active' => 'subscriptionActive',
Braintree_WebhookNotification::SUBSCRIPTION_EXPIRED => 'subscriptionExpired',
Braintree_WebhookNotification::SUBSCRIPTION_WENT_PAST_DUE => 'subscriptionOverdue',
Braintree_WebhookNotification::SUBSCRIPTION_CANCELED => 'subscriptionCanceled',
'check' => 'check'
];
protected $hooks;
public function __construct($hooks = null, $braintree = null)
{
$this->hooks = $hooks ?: new Payments\Hooks();
$this->braintree = $braintree;
}
/**
* Set the request payload
* @param string $payload
* @return $this
*/
public function setPayload($payload)
{
$this->payload = $payload;
return $this;
}
/**
* Set the request signature
* @param string $signature
* @return $this
*/
public function setSignature($signature)
{
$this->signature = $signature;
return $this;
}
/**
* Run the notification hook
* @return $this
*/
public function run()
{
$this->buildNotification();
$this->routeAlias();
return $this;
}
protected function buildNotification()
{
$this->notification = Braintree_WebhookNotification::parse($this->signature, $this->payload);
}
protected function routeAlias()
{
if (method_exists($this, $this->aliases[$this->notification->kind])) {
$method = $this->aliases[$this->notification->kind];
$this->$method();
}
}
/**
* @return void
*/
protected function subMerchantApproved()
{
$message = "Congrats, you are now a Minds Merchant";
Core\Events\Dispatcher::trigger('notification', 'elgg/hook/activity', [
'to'=>[$notification->merchantAccount->id],
'from' => 100000000000000519,
'notification_view' => 'custom_message',
'params' => ['message'=>$message],
'message'=>$message
]);
}
/**
* @return void
*/
protected function subMerchantDeclined()
{
$reason = $notification->message;
$message = "Sorry, we could not approve your Merchant Account: $reason";
Core\Events\Dispatcher::trigger('notification', 'elgg/hook/activity', [
'to'=>[$notification->merchantAccount->id],
'from' => 100000000000000519,
'notification_view' => 'custom_message',
'params' => ['message'=>$message],
'message'=>$message
]);
}
/**
* @return void
*/
protected function subscriptionCharged()
{
$subscription = (new Subscription())
->setId($this->notification->subscription->id)
->setBalance($this->notification->subscription->balance)
->setPrice($this->notification->subscription->price);
$db = new Core\Data\Call('user_index_to_guid');
//find the customer
$user_guids = $db->getRow("subscription:" . $subscription->getId());
$user = Entities\Factory::build($user_guids[0]);
//WalletHelper::createTransaction($user->guid, ($subscription->getPrice() * 1000) * 1.1, null, "Purchase (Recurring)");
//$this->hooks->onCharged($subscription);
$transaction = new Transaction();
$transaction
->setUserGuid($user->guid)
->setWalletAddress('offchain')
->setTimestamp(time())
->setTx('cc:bt-' . Guid::build())
->setAmount(($subscription->getPrice()) * 1.1 * 10 ** 18)
->setContract('offchain:points')
->setCompleted(true);
Di::_()->get('Blockchain\Transactions\Repository')
->add($transaction);
}
/**
* @return void
*/
protected function subscriptionActive()
{
$subscription = (new Subscription())
->setId($this->notification->subscription->id)
->setBalance($this->notification->subscription->balance)
->setPrice($this->notification->subscription->price);
$this->hooks->onActive($subscription);
}
/**
* @return void
*/
protected function subscriptionExpired()
{
$subscription = (new Subscription())
->setId($this->notification->subscription->id);
$this->hooks->onExpired($subscription);
}
/**
* @return void
*/
protected function subscriprionOverdue()
{
$subscription = (new Subscription())
->setId($this->notification->subscription->id);
$this->hooks->onOverdue($subscription);
}
/**
* @return void
*/
protected function subscriptionCanceled()
{
$subscription = (new Subscription())
->setId($this->notification->subscription->id);
$this->hooks->onCanceled($subscription);
}
/**
* @return void
*/
protected function check()
{
error_log("[webook]:: check is OK!");
}
}
<?php
/**
* Payments Factory
*/
namespace Minds\Core\Payments;
use Minds\Core\Di\Di;
/**
* A factory providing handlers boosting items
*/
class Factory
{
/**
* Build the handler
* @param string $handler
* @param array $options (optional)
* @return BoostHandlerInterface
*/
public static function build($handler, $opts = [])
{
switch (ucfirst($handler)) {
case "Braintree":
return Di::_()->get('BraintreePayments')->setConfig($opts);
default:
throw new \Exception("Service not found");
}
......
......@@ -9,12 +9,6 @@ use Minds\Core;
use Minds\Core\Data;
use Minds\Core\Di\Provider;
use Braintree_ClientToken;
use Braintree_Configuration;
use Braintree_Transaction;
use Braintree_TransactionSearch;
use Braintree_MerchantAccount;
class PaymentsProvider extends Provider
{
public function register()
......@@ -27,33 +21,15 @@ class PaymentsProvider extends Provider
return new Repository();
}, [ 'useFactory' => true ]);
//
$this->di->bind('Payments\Points', function ($di) {
return new Points\Manager();
});
//
$this->di->bind('BraintreePayments', function ($di) {
$config = $di->get('Config');
$braintree = new Braintree\Braintree(new Braintree_Configuration(), $di->get('Config'));
/*$braintree->setConfig([
'environment' => $config->payments['braintree']['default']['environment'] ?: 'sandbox',
'merchant_id' => $config->payments['braintree']['default']['merchant_id'],
'master_merchant_id' => $config->payments['braintree']['default']['master_merchant_id'],
'public_key' => $config->payments['braintree']['default']['public_key'],
'private_key' => $config->payments['braintree']['default']['private_key']
]);*/
return $braintree;
}, ['useFactory'=>true]);
$this->di->bind('StripePayments', function ($di) {
$config = $di->get('Config');
return new Stripe\Stripe($di->get('Config'));
}, ['useFactory'=>true]);
// Stripe
$this->di->bind('Stripe\Connect\Manager', function ($di) {
return new Stripe\Connect\Manager();
}, ['useFactory'=>true]);
......
......@@ -65,13 +65,15 @@ class PaywallReview
public function add()
{
$query = new Core\Data\Cassandra\Prepared\Custom();
$query->query("INSERT INTO entities_by_time
$query->query(
"INSERT INTO entities_by_time
(key, column1, value)
VALUES ('paywall:review', ?, ?)",
[
[
(string) $this->entity_guid,
(string) $this->entity_guid
]);
]
);
try {
$result = $this->db->request($query);
} catch (\Exception $e) {
......@@ -84,7 +86,8 @@ class PaywallReview
public function remove()
{
$query = new Core\Data\Cassandra\Prepared\Custom();
$query->query("DELETE FROM entities_by_time
$query->query(
"DELETE FROM entities_by_time
WHERE key = 'paywall:review' AND column1 = ?",
[
(string) $this->entity_guid
......
......@@ -205,17 +205,19 @@ class Repository
public function add($plan)
{
$query = new Core\Data\Cassandra\Prepared\Custom();
$query->query("INSERT INTO plans
$query->query(
"INSERT INTO plans
(entity_guid, plan, user_guid, status, subscription_id, expires)
VALUES (?, ?, ?, ?, ?, ?)",
[
[
(string) $plan->getEntityGuid(),
(string) $plan->getName(),
(string) $plan->getUserGuid(),
(string) $plan->getStatus(),
(string) $plan->getSubscriptionId(),
(int) $plan->getExpires(),
]);
]
);
try {
$result = $this->db->request($query);
} catch (\Exception $e) {
......
......@@ -22,8 +22,8 @@ class Manager
public function __construct(
$lookup = null,
$customersManager = null,
$paymentMethodInstance = null)
{
$paymentMethodInstance = null
) {
$this->lookup = $lookup ?: Di::_()->get('Database\Cassandra\Lookup');
$this->customersManager = $customersManager ?? new CustomersManager;
$this->paymentMethodInstance = $paymentMethodInstance ?? new PaymentMethodInstance();
......
<?php
/**
* Braintree webhooks
*/
namespace Minds\Core\Payments\Stripe;
......
......@@ -185,7 +185,8 @@ class Repository
public function add($subscription)
{
$query = new Custom();
$query->query("INSERT INTO subscriptions (
$query->query(
"INSERT INTO subscriptions (
subscription_id,
plan_id,
payment_method,
......@@ -197,7 +198,7 @@ class Repository
last_billing,
next_billing
) VALUES (?,?,?,?,?,?,?,?,?,?)",
[
[
$subscription->getId(),
$subscription->getPlanId(),
$subscription->getPaymentMethod(),
......@@ -208,7 +209,8 @@ class Repository
$subscription->getStatus(),
new Timestamp($subscription->getLastBilling()),
new Timestamp($subscription->getNextBilling())
]);
]
);
$result = $this->cql->request($query);
......
......@@ -22,8 +22,8 @@ class Manager
public function __construct(
EntitiesBuilder $entitiesBuilder = null,
Call $db = null,
Save $save = null)
{
Save $save = null
) {
$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.
......
......@@ -228,15 +228,17 @@ class Installer
}
}
public function setupStorage(Provisioners\ProvisionerInterface $cassandraStorage = null,
$cleanData = false)
{
public function setupStorage(
Provisioners\ProvisionerInterface $cassandraStorage = null,
$cleanData = false
) {
$this->provisionCassandra($cassandraStorage, $cleanData);
}
public function provisionCassandra(Provisioners\ProvisionerInterface $cassandraStorage = null,
$cleanData = false)
{
public function provisionCassandra(
Provisioners\ProvisionerInterface $cassandraStorage = null,
$cleanData = false
) {
$cassandraStorage = $cassandraStorage ?: new Provisioners\CassandraProvisioner();
$cassandraStorage->provision($cleanData);
}
......
......@@ -56,17 +56,19 @@ class FeedDispatcher implements Interfaces\QueueRunner
$ninetyDays = (60 * 60 * 24 * 90);
foreach ($followers as $follower) {
$db->insert("$entity->type:network:$follower",
[ $entity->guid => $entity->guid ],
$ninetyDays, //ttl
$db->insert(
"$entity->type:network:$follower",
[ $entity->guid => $entity->guid ],
$ninetyDays, //ttl
true //async (silent)
);
);
if ($entity->subtype) {
$db->insert("$entity->type:$entity->subtype:network:$follower",
[ $entity->guid => $entity->guid ],
$ninetyDays, //ttl
$db->insert(
"$entity->type:$entity->subtype:network:$follower",
[ $entity->guid => $entity->guid ],
$ninetyDays, //ttl
true //async (silent)
);
);
}
}
......
......@@ -71,10 +71,12 @@ class Repository
foreach ($result as $row) {
if ($row['user_hashes']
&& in_array($opts['user']->getPhoneNumberHash(),
&& in_array(
$opts['user']->getPhoneNumberHash(),
array_map(function ($hash) {
return $hash;
}, $row['user_hashes']->values()), true
}, $row['user_hashes']->values()),
true
)
) {
continue; // Already interacted with
......
......@@ -232,7 +232,8 @@ class Repository
->setTimestamp($row['timestamp']->time())
//->setState((string) $row['state'])
->setUphold(isset($row['uphold']) ? (bool) $row['uphold'] : null)
->setStateChanges(isset($row['state_changes']) ?
->setStateChanges(
isset($row['state_changes']) ?
array_map(function ($timestamp) {
return $timestamp->time();
}, $this->mapToAssoc($row['state_changes']))
......@@ -253,7 +254,8 @@ class Repository
$this->buildDecisions($this->mapToAssoc($row['appeal_jury']))
: null
)
->setUserHashes(isset($row['user_hashes']) ?
->setUserHashes(
isset($row['user_hashes']) ?
$row['user_hashes']->values() : null
);
return $report;
......
......@@ -46,17 +46,21 @@ class Sums
$query = new Custom();
if ($this->user) {
$query->query("SELECT SUM(amount) as amount from contributions WHERE user_guid = ?
$query->query(
"SELECT SUM(amount) as amount from contributions WHERE user_guid = ?
AND timestamp = ?",
[
new Varint((int) $this->user->guid),
new Timestamp($this->timestamp / 1000)
]);
]
);
} else {
$query->query("SELECT SUM(amount) as amount from contributions_by_timestamp WHERE timestamp = ?",
$query->query(
"SELECT SUM(amount) as amount from contributions_by_timestamp WHERE timestamp = ?",
[
new Timestamp($this->timestamp / 1000)
]);
]
);
}
try {
......@@ -76,17 +80,21 @@ class Sums
$query = new Custom();
if ($this->user) {
$query->query("SELECT SUM(score) as score from contributions WHERE user_guid = ?
$query->query(
"SELECT SUM(score) as score from contributions WHERE user_guid = ?
AND timestamp = ?",
[
new Varint((int) $this->user->guid),
new Timestamp($this->timestamp / 1000)
]);
]
);
} else {
$query->query("SELECT SUM(score) as score from contributions_by_timestamp WHERE timestamp = ?",
$query->query(
"SELECT SUM(score) as score from contributions_by_timestamp WHERE timestamp = ?",
[
new Timestamp($this->timestamp / 1000)
]);
]
);
}
try {
......
......@@ -53,10 +53,12 @@ class Twilio implements SMSServiceInterface
try {
$result = $this->client->messages->create(
$number, [
$number,
[
'from' => $this->config['from'],
'body' => $message,
]);
]
);
} catch (\Exception $e) {
error_log("[guard] Twilio error: {$e->getMessage()}");
}
......
......@@ -94,8 +94,10 @@ class Block
$prepared = new Cassandra\Prepared\Custom();
$collection = \Cassandra\Type::collection(\Cassandra\Type::text())
->create(... $user_guids);
$prepared->query("SELECT * from entities_by_time WHERE key= ? AND column1 IN ? LIMIT ?",
[ "acl:blocked:$from", $collection, 1000 ]);
$prepared->query(
"SELECT * from entities_by_time WHERE key= ? AND column1 IN ? LIMIT ?",
[ "acl:blocked:$from", $collection, 1000 ]
);
$list = [];
$result = $this->cql->request($prepared);
......
......@@ -44,7 +44,7 @@ class Ban
return true;
}
echo "\n$user->guid now banned ({$this->accused->getScore()}) \n";
error_log("$user->guid now banned ({$this->accused->getScore()})");
$this->channelsBanManager
->setUser($user)
......@@ -52,7 +52,7 @@ class Ban
$this->recover->setAccused($this->accused)
->recover();
echo "\n$user->guid recovered";
error_log("$user->guid recovered");
if ($this->events) {
$event = new Core\Analytics\Metrics\Event();
......
......@@ -42,7 +42,7 @@ class Scanner
}
$this->manager->impose();
echo "\n$user->guid is now rate limited for {$opts['period']} seconds";
error_log("$user->guid is now rate limited for {$opts['period']} seconds");
}
}
}
......
......@@ -15,9 +15,9 @@ class SecurityProvider extends Provider
{
$this->di->bind('Security\ACL\Block', function ($di) {
return new ACL\Block(
Di::_()->get('Database\Cassandra\Indexes'),
Di::_()->get('Database\Cassandra\Cql'),
Core\Data\cache\factory::build()
Di::_()->get('Database\Cassandra\Indexes'),
Di::_()->get('Database\Cassandra\Cql'),
Core\Data\cache\factory::build()
);
}, ['useFactory'=>true]);
......
......@@ -34,11 +34,13 @@ class Repository
], $opts);
$query = new Prepared;
$query->query("SELECT * FROM spam_blocks
$query->query(
"SELECT * FROM spam_blocks
WHERE key = ?",
[
(string) $opts['key'],
]);
]
);
$query->setOpts([
'page_size' => $opts['limit'],
......@@ -73,12 +75,14 @@ class Repository
public function get($key, $value)
{
$query = new Prepared;
$query->query("SELECT * FROM spam_blocks
$query->query(
"SELECT * FROM spam_blocks
WHERE key = ? AND value = ?",
[
(string) $key,
(string) $value,
]);
]
);
$result = $this->client->request($query);
......@@ -100,12 +104,14 @@ class Repository
public function add(SpamBlock $model)
{
$query = new Prepared;
$query->query("INSERT INTO spam_blocks (key, value)
$query->query(
"INSERT INTO spam_blocks (key, value)
VALUES (?, ?)",
[
(string) $model->getKey(),
(string) $model->getValue(),
]);
]
);
return $this->client->request($query);
}
......@@ -129,12 +135,14 @@ class Repository
public function delete(SpamBlock $model)
{
$query = new Prepared;
$query->query("DELETE FROM spam_blocks
$query->query(
"DELETE FROM spam_blocks
WHERE key = ? AND value = ?",
[
(string) $model->getKey(),
(string) $model->getValue(),
]);
]
);
return $this->client->request($query);
}
......
......@@ -55,7 +55,8 @@ class GenericRule implements Interfaces\XSSRule
*/
public function clean()
{
$this->cleanString = preg_replace_callback('%
$this->cleanString = preg_replace_callback(
'%
(
<(?=[^a-zA-Z!/]) # a lone <
| # or
......@@ -66,7 +67,8 @@ class GenericRule implements Interfaces\XSSRule
> # just a >
)%x',
[$this, 'cleanSplit'],
$this->dirtyString);
$this->dirtyString
);
$this->cleanString = $this->cleanAttributes($this->cleanString);
......
......@@ -21,10 +21,12 @@ class Manager
public function getRedirectUrl()
{
$helper = $this->facebook->getFb()->getRedirectLoginHelper();
$url = $helper->getReRequestUrl(Core\Config::_()->site_url . 'api/v1/thirdpartynetworks/facebook/login-callback',
$url = $helper->getReRequestUrl(
Core\Config::_()->site_url . 'api/v1/thirdpartynetworks/facebook/login-callback',
[
'email'
]);
]
);
return $url;
}
......@@ -99,8 +101,17 @@ class Manager
$files = [];
foreach ($icon_sizes as $name => $size_info) {
$resized = get_resized_image_from_existing_file("/tmp/fb-" . md5($url), $size_info['w'], $size_info['h'],
$size_info['square'], 0, 0, 0, 0, $size_info['upscale']);
$resized = get_resized_image_from_existing_file(
"/tmp/fb-" . md5($url),
$size_info['w'],
$size_info['h'],
$size_info['square'],
0,
0,
0,
0,
$size_info['upscale']
);
if ($resized) {
//@todo Make these actual entities. See exts #348.
......
......@@ -23,8 +23,10 @@ class Storage
public function get($guid, $field, $target)
{
$prepared = new Cassandra\Prepared\Custom();
$prepared->query("SELECT * FROM translations WHERE guid= ? AND field= ? AND language= ? LIMIT 1",
[ (string) $guid, $field, $target ]);
$prepared->query(
"SELECT * FROM translations WHERE guid= ? AND field= ? AND language= ? LIMIT 1",
[ (string) $guid, $field, $target ]
);
$result = $this->db->request($prepared);
......@@ -47,8 +49,10 @@ class Storage
$content = (string) $content;
$prepared = new Cassandra\Prepared\Custom();
$prepared->query("INSERT INTO translations (guid, field, language, source_language, content) VALUES (?, ?, ?, ?, ?)",
[ (string) $guid, $field, $target, $sourceLanguage, $content ]);
$prepared->query(
"INSERT INTO translations (guid, field, language, source_language, content) VALUES (?, ?, ?, ?, ?)",
[ (string) $guid, $field, $target, $sourceLanguage, $content ]
);
$result = (array) $this->db->request($prepared);
......
......@@ -91,7 +91,7 @@ class Manager
//validate this entity is ok
if (!$this->validator->isValid($entity, $rating)) {
echo "\n[$rating] $key: $guid ($score) invalid";
error_log("[$rating] $key: $guid ($score) invalid");
continue;
}
......@@ -125,7 +125,7 @@ class Manager
$guids = [];
foreach ($scores[$key] as $guid => $score) {
$guids[] = $guid;
echo "\n[$rating] $key: $guid ($score)";
error_log("[$rating] $key: $guid ($score)");
}
$this->repository->add($key, $guids, $rating);
......
......@@ -6,9 +6,11 @@ abstract class UUIDGenerator
{
public static function generate()
{
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
......@@ -23,7 +25,9 @@ abstract class UUIDGenerator
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
}
}
......@@ -29,8 +29,11 @@ class Counter
$sum = $sums->getReceived();
$cache->set(static::getIndexName($user_guid, null, $method, $timestamp, false, false), $sum,
$timestamp ? static::CACHE_DURATION : false);
$cache->set(
static::getIndexName($user_guid, null, $method, $timestamp, false, false),
$sum,
$timestamp ? static::CACHE_DURATION : false
);
return $sum;
}
......@@ -44,15 +47,24 @@ class Counter
$sums->setFrom($timestamp)
->setSender($user_guid);
if (($cached = $cache->get(static::getIndexName($user_guid, null, $method, $timestamp, false,
true))) !== false) {
if (($cached = $cache->get(static::getIndexName(
$user_guid,
null,
$method,
$timestamp,
false,
true
))) !== false) {
return $cached;
}
try {
$sum = $sums->getSent();
$cache->set(static::getIndexName($user_guid, null, $method, $timestamp, false, true), $sum,
$timestamp ? static::CACHE_DURATION : false);
$cache->set(
static::getIndexName($user_guid, null, $method, $timestamp, false, true),
$sum,
$timestamp ? static::CACHE_DURATION : false
);
} catch (\Exception $e) {
$sum = 0;
}
......@@ -70,15 +82,24 @@ class Counter
->setSender($sender_guid)
->setReceiver($receiver_guid);
if (($cached = $cache->get(static::getIndexName($sender_guid, $receiver_guid, $method, $timestamp, false,
true))) !== false) {
if (($cached = $cache->get(static::getIndexName(
$sender_guid,
$receiver_guid,
$method,
$timestamp,
false,
true
))) !== false) {
return $cached;
}
$sum = $sums->getSent();
$cache->set(static::getIndexName($sender_guid, $receiver_guid, $method, $timestamp, false, true), $sum,
$timestamp ? static::CACHE_DURATION : false);
$cache->set(
static::getIndexName($sender_guid, $receiver_guid, $method, $timestamp, false, true),
$sum,
$timestamp ? static::CACHE_DURATION : false
);
return $sum;
}
......@@ -97,8 +118,11 @@ class Counter
try {
$sum = $sums->getEntity();
$cache->set(static::getIndexName($entity_guid, null, $method, $timestamp, true), $sum,
$timestamp ? static::CACHE_DURATION : false);
$cache->set(
static::getIndexName($entity_guid, null, $method, $timestamp, true),
$sum,
$timestamp ? static::CACHE_DURATION : false
);
} catch (\Exception $e) {
$sum = 0;
}
......
......@@ -28,6 +28,6 @@ class NotificationDelegate
'wire' => serialize($wire),
'entity' => serialize($wire->getEntity()),
]
);
);
}
}
......@@ -187,7 +187,8 @@ class Activity extends Entity
*/
public function getExportableValues()
{
return array_merge(parent::getExportableValues(),
return array_merge(
parent::getExportableValues(),
[
'title',
'blurb',
......@@ -221,7 +222,8 @@ class Activity extends Entity
'hide_impressions',
'pinned',
'time_sent',
]);
]
);
}
/**
......
......@@ -10,7 +10,7 @@ use Minds\Api;
use Minds\Core;
use Minds\Core\Data;
class Album extends Object
class Album extends MindsObject
{
protected function initializeAttributes()
{
......
......@@ -8,7 +8,7 @@ namespace Minds\Entities;
use Minds\Core\Data;
class Batch extends Object
class Batch extends MindsObject
{
public function __construct($guid = null)
{
......
......@@ -26,7 +26,7 @@ class DenormalizedEntity
/**
* Set this entity's database store
* @param object $db
* @param MindsObject $db
*/
public function setDb($db)
{
......
......@@ -153,8 +153,9 @@ class Image extends File
$w = 1024;
$s = false;
$u = true;
// no break
default:
continue;
continue 2;
}
/** @var Core\Media\Imagick\Autorotate $autorotate */
......
......@@ -8,7 +8,7 @@ use Minds\Core;
* Object Entity
* @todo Do not inherit from ElggObject
*/
class Object extends \ElggObject implements Flaggable
class MindsObject extends \ElggObject implements Flaggable
{
protected $dirtyIndexes;
......
......@@ -6,7 +6,7 @@ use Minds\Entities;
/**
* Carousel Entity
*/
class Carousel extends Entities\Object
class Carousel extends Entities\MindsObject
{
/**
* Initialize entity attributes
......
......@@ -6,7 +6,7 @@ use Minds\Entities;
/**
* Points Transaction Entity
*/
class Points_transaction extends Entities\Object
class Points_transaction extends Entities\MindsObject
{
/**
* Initialize attributes
......
......@@ -12,7 +12,7 @@ use Minds\Core\Di\Di;
use cinemr;
use Minds\Helpers;
class Video extends Object
class Video extends MindsObject
{
private $cinemr;
......
......@@ -45,7 +45,7 @@ Please report all security issues to [security@minds.com](mailto:security@minds.
[AGPLv3](https://www.minds.org/docs/license.html). Please see the license file of each repository.
## Credits
[PHP](https://php.net), [Cassandra](http://cassandra.apache.org/), [Angular2](http://angular.io), [Nginx](https://nginx.com), [Ubuntu](https://ubuntu.com), [OpenSSL](https://www.openssl.org/), [RabbitMQ](https://www.rabbitmq.com/), [Elasticsearch](https://www.elastic.co/), [Cordova](https://cordova.apache.org/), [Neo4j](https://neo4j.com/), [Elgg](http://elgg.org), [Node.js](https://nodejs.org/en/), [MongoDB](https://www.mongodb.com/), [Redis](http://redis.io/), [WebRTC](https://webrtc.org/), [Socket.io](http://socket.io/), [TinyMCE](https://www.tinymce.com/), [Ionic](http://ionicframework.com/), [Requirejs](http://requirejs.org/), [OAuth](http://oauth.net/2/), [Apigen](http://www.apigen.org/), [Braintree](https://www.braintreepayments.com/). If any are missing please feel free to add.
[PHP](https://php.net), [Cassandra](http://cassandra.apache.org/), [Angular2](http://angular.io), [Nginx](https://nginx.com), [Ubuntu](https://ubuntu.com), [OpenSSL](https://www.openssl.org/), [RabbitMQ](https://www.rabbitmq.com/), [Elasticsearch](https://www.elastic.co/), [Cordova](https://cordova.apache.org/), [Neo4j](https://neo4j.com/), [Elgg](http://elgg.org), [Node.js](https://nodejs.org/en/), [MongoDB](https://www.mongodb.com/), [Redis](http://redis.io/), [WebRTC](https://webrtc.org/), [Socket.io](http://socket.io/), [TinyMCE](https://www.tinymce.com/), [Ionic](http://ionicframework.com/), [Requirejs](http://requirejs.org/), [OAuth](http://oauth.net/2/), [Apigen](http://www.apigen.org/)). If any are missing please feel free to add.
___Copyright Minds 2012 - 2019___
......
......@@ -57,7 +57,8 @@ class SignupsMetricSpec extends ObjectBehavior
'value' => 256,
],
],
]);
]
);
$this->buildSummary();
......
......@@ -57,7 +57,8 @@ class ViewsMetricSpec extends ObjectBehavior
'value' => 256,
]
]
]);
]
);
$this->buildSummary();
......
......@@ -2,12 +2,10 @@
namespace Spec\Minds\Core\Analytics\Views;
use Minds\Common\Repository\Response;
use Minds\Core\Analytics\Views\Repository;
use Minds\Core\Analytics\Views\View;
use Minds\Core\Data\Cassandra\Client as CassandraClient;
use Minds\Core\Data\Cassandra\Prepared\Custom;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
......@@ -32,66 +30,24 @@ class RepositorySpec extends ObjectBehavior
// {
// }
public function it_should_add(
View $view
) {
public function it_should_add(View $view)
{
$now = strtotime('2019-05-29 12:00:00+0000');
$view->getTimestamp()
->shouldBeCalled()
->willReturn($now);
$view->getYear()
->shouldBeCalled()
->willReturn(2019);
$view->getMonth()
->shouldBeCalled()
->willReturn(5);
$view->getDay()
->shouldBeCalled()
->willReturn(29);
$view->getUuid()
->shouldBeCalled()
->willReturn('abc-123-456-def');
$view->getEntityUrn()
->shouldBeCalled()
->willReturn('urn:test:123123');
$view->getOwnerGuid()
->shouldBeCalled()
->wilLReturn('789');
$view->getPageToken()
->shouldBeCalled()
->willReturn('1234-qwe-qwe-1234');
$view->getPosition()
->shouldBeCalled()
->willReturn(5);
$view->getPlatform()
->shouldBeCalled()
->willReturn('php');
$view->getSource()
->shouldBeCalled()
->willReturn('phpspec');
$view->getMedium()
->shouldBeCalled()
->willReturn('test');
$view->getCampaign()
->shouldBeCalled()
->willReturn('urn:phpspec:234234');
$view->getDelta()
->shouldBeCalled()
->willReturn(100);
$view->getTimestamp()->shouldBeCalled()->willReturn($now);
$view->getYear()->shouldBeCalled()->willReturn(2019);
$view->getMonth()->shouldBeCalled()->willReturn(5);
$view->getDay()->shouldBeCalled()->willReturn(29);
$view->getUuid()->shouldBeCalled()->willReturn('8a7675d2-f1a7-11e9-8dea-b8aeed731cad');
$view->getEntityUrn()->shouldBeCalled()->willReturn('urn:test:123123');
$view->getOwnerGuid()->shouldBeCalled()->wilLReturn('789');
$view->getPageToken()->shouldBeCalled()->willReturn('95e82e24-f1a7-11e9-8dea-b8aeed731cad');
$view->getPosition()->shouldBeCalled()->willReturn(5);
$view->getPlatform()->shouldBeCalled()->willReturn('php');
$view->getSource()->shouldBeCalled()->willReturn('phpspec');
$view->getMedium()->shouldBeCalled()->willReturn('test');
$view->getCampaign()->shouldBeCalled()->willReturn('urn:phpspec:234234');
$view->getDelta()->shouldBeCalled()->willReturn(100);
$this->db->request(Argument::that(function (Custom $prepared) {
$statement = $prepared->build();
......@@ -100,85 +56,39 @@ class RepositorySpec extends ObjectBehavior
$statement['values'][0] === 2019 &&
$statement['values'][1]->toInt() === 5 &&
$statement['values'][2]->toInt() === 29 &&
$statement['values'][3]->uuid() === 'abc-123-456-def' &&
$statement['values'][3]->uuid() === '8a7675d2-f1a7-11e9-8dea-b8aeed731cad' &&
$statement['values'][4] === 'urn:test:123123' &&
$statement['values'][5] === '789' &&
$statement['values'][6] === '1234-qwe-qwe-1234' &&
$statement['values'][6] === '95e82e24-f1a7-11e9-8dea-b8aeed731cad' &&
$statement['values'][7] === 5 &&
$statement['values'][8] === 'php' &&
$statement['values'][9] === 'phpspec' &&
$statement['values'][10] === 'test' &&
$statement['values'][11] === 'urn:phpspec:234234' &&
$statement['values'][12] === 100;
}), true)
->shouldBeCalled()
->willReturn(true);
}), true)->shouldBeCalled()->willReturn(true);
$this
->add($view)
->shouldReturn(true);
$this->add($view)->shouldReturn(true);
}
public function it_should_add_with_a_timestamp(
View $view
) {
public function it_should_add_with_a_timestamp(View $view)
{
$now = strtotime('2019-05-29 12:00:00+0000');
$view->getTimestamp()
->shouldBeCalled()
->willReturn($now);
$view->getYear()
->shouldBeCalled()
->willReturn(null);
$view->getMonth()
->shouldBeCalled()
->willReturn(null);
$view->getDay()
->shouldBeCalled()
->willReturn(null);
$view->getUuid()
->shouldBeCalled()
->willReturn(null);
$view->getEntityUrn()
->shouldBeCalled()
->willReturn('urn:test:123123');
$view->getOwnerGuid()
->shouldBeCalled()
->willReturn(789);
$view->getPageToken()
->shouldBeCalled()
->willReturn('1234-qwe-qwe-1234');
$view->getPosition()
->shouldBeCalled()
->willReturn(5);
$view->getPlatform()
->shouldBeCalled()
->willReturn('php');
$view->getSource()
->shouldBeCalled()
->willReturn('phpspec');
$view->getMedium()
->shouldBeCalled()
->willReturn('test');
$view->getCampaign()
->shouldBeCalled()
->willReturn('urn:phpspec:234234');
$view->getDelta()
->shouldBeCalled()
->willReturn(100);
$view->getTimestamp()->shouldBeCalled()->willReturn($now);
$view->getYear()->shouldBeCalled()->willReturn(null);
$view->getMonth()->shouldBeCalled()->willReturn(null);
$view->getDay()->shouldBeCalled()->willReturn(null);
$view->getUuid()->shouldBeCalled()->willReturn(null);
$view->getEntityUrn()->shouldBeCalled()->willReturn('urn:test:123123');
$view->getOwnerGuid()->shouldBeCalled()->willReturn(789);
$view->getPageToken()->shouldBeCalled()->willReturn('95e82e24-f1a7-11e9-8dea-b8aeed731cad');
$view->getPosition()->shouldBeCalled()->willReturn(5);
$view->getPlatform()->shouldBeCalled()->willReturn('php');
$view->getSource()->shouldBeCalled()->willReturn('phpspec');
$view->getMedium()->shouldBeCalled()->willReturn('test');
$view->getCampaign()->shouldBeCalled()->willReturn('urn:phpspec:234234');
$view->getDelta()->shouldBeCalled()->willReturn(100);
$this->db->request(Argument::that(function (Custom $prepared) use ($now) {
$statement = $prepared->build();
......@@ -187,22 +97,21 @@ class RepositorySpec extends ObjectBehavior
$statement['values'][0] === 2019 &&
$statement['values'][1]->toInt() === 5 &&
$statement['values'][2]->toInt() === 29 &&
$statement['values'][3]->time() === $now * 1000 &&
//TODO: Timeuuid isreturning different value between actual vs mock
//$statement['values'][3]->time() == $now &&
$statement['values'][4] === 'urn:test:123123' &&
$statement['values'][5] === '789' &&
$statement['values'][6] === '1234-qwe-qwe-1234' &&
$statement['values'][6] === '95e82e24-f1a7-11e9-8dea-b8aeed731cad' &&
$statement['values'][7] === 5 &&
$statement['values'][8] === 'php' &&
$statement['values'][9] === 'phpspec' &&
$statement['values'][10] === 'test' &&
$statement['values'][11] === 'urn:phpspec:234234' &&
$statement['values'][12] === 100;
}), true)
->shouldBeCalled()
->willReturn(true);
}), true)->shouldBeCalled()->willReturn(true);
//$this->db->request(Argument::type(Custom::class), true)->shouldBeCalled();
$this
->add($view)
->shouldReturn(true);
$this->add($view)->shouldReturn(true);
}
}
......@@ -83,8 +83,11 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('456');
$this->event('0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040', ['address' => '0xasd'],
$transaction);
$this->event(
'0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040',
['address' => '0xasd'],
$transaction
);
}
public function it_should_execute_a_boost_sent_event_but_not_find_the_boost(Transaction $transaction)
......@@ -104,12 +107,14 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn(null);
$this->shouldThrow(new \Exception("No boost with hash 0x123123asdasd"))->during('event',
$this->shouldThrow(new \Exception("No boost with hash 0x123123asdasd"))->during(
'event',
[
'0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040',
['address' => '0xasd'],
$transaction
]);
]
);
}
public function it_should_execute_a_boost_sent_event_but_boost_has_been_processed_already(
......@@ -135,12 +140,14 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('created');
$this->shouldThrow(new \Exception("Boost with hash 0x123123asdasd already processed. State: created"))->during('event',
$this->shouldThrow(new \Exception("Boost with hash 0x123123asdasd already processed. State: created"))->during(
'event',
[
'0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040',
['address' => '0xasd'],
$transaction
]);
]
);
}
public function it_shoud_execute_a_boost_fail_event(Transaction $transaction, Network $boost)
......@@ -196,8 +203,10 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('wire');
$this->shouldThrow(new \Exception("Failed but not a boost"))->during('event',
['blockchain:fail', ['address' => '0xasd'], $transaction]);
$this->shouldThrow(new \Exception("Failed but not a boost"))->during(
'event',
['blockchain:fail', ['address' => '0xasd'], $transaction]
);
}
public function it_should_execute_a_boost_fail_event_but_boost_isnt_found(Transaction $transaction)
......@@ -221,8 +230,10 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('0x123123asdasd');
$this->shouldThrow(new \Exception("No boost with hash 0x123123asdasd"))->during('event',
['blockchain:fail', ['address' => '0xasd'], $transaction]);
$this->shouldThrow(new \Exception("No boost with hash 0x123123asdasd"))->during(
'event',
['blockchain:fail', ['address' => '0xasd'], $transaction]
);
}
public function it_should_execute_a_boost_fail_event_but_boost_already_processed(Transaction $transaction, Network $boost)
......@@ -250,8 +261,10 @@ class BoostEventSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('created');
$this->shouldThrow(new \Exception("Boost with hash 0x123123asdasd already processed. State: created"))->during('event',
['blockchain:fail', ['address' => '0xasd'], $transaction]);
$this->shouldThrow(new \Exception("Boost with hash 0x123123asdasd already processed. State: created"))->during(
'event',
['blockchain:fail', ['address' => '0xasd'], $transaction]
);
}
public function it_should_record_as_failed(
......@@ -300,7 +313,9 @@ class BoostEventSpec extends ObjectBehavior
'0x123123'
]
];
$this->shouldThrow(new \Exception('Event does not match address'))->during('event',
['0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040', $log, $transaction]);
$this->shouldThrow(new \Exception('Event does not match address'))->during(
'event',
['0x68170a430a4e2c3743702c7f839f5230244aca61ed306ec622a5f393f9559040', $log, $transaction]
);
}
}
......@@ -56,8 +56,10 @@ class TokenSaleEventSpec extends ObjectBehavior
'0x123123'
]
];
$this->shouldThrow(new \Exception('Event does not match address'))->during('event',
['0xf4b351c7293f3c20fc9912c61adbe9823a6de3162bde18c98eb6feeae232f861', $log, $transaction]);
$this->shouldThrow(new \Exception('Event does not match address'))->during(
'event',
['0xf4b351c7293f3c20fc9912c61adbe9823a6de3162bde18c98eb6feeae232f861', $log, $transaction]
);
}
public function it_should_execute_a_token_purchase_event(Transaction $transaction, Purchase\Purchase $purchase)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.