Commit 209a5da9 authored by Brian Hatchet's avatar Brian Hatchet
Browse files

Merged and cleanup

parent 36b9df4c
Loading
Loading
Loading
Loading
+77 −0
Original line number Original line Diff line number Diff line
<?php

namespace Minds\Controllers\Cli;

use Minds\Cli;
use Minds\Core\Events\Dispatcher;
use Minds\Interfaces;

class Notification extends Cli\Controller implements Interfaces\CliControllerInterface
{
    public function help($command = null)
    {
        switch ($command) {
            case 'send':
                $this->out('Send a notification');
                $this->out('--namespace=<type> Notification namespace');
                $this->out('--to=<user guid> User to send notification to');
                $this->out('--from=<entity guid> Entity notification is from (defaults to system user)');
                $this->out('--view=<view> Notification view');
                $this->out('--params=<params> JSON payload data');
            // no break
            default:
                $this->out('Syntax usage: cli notification <cmd>');
                $this->displayCommandHelp();
        }
    }

    public function exec()
    {
        $this->help();
    }

    public function send()
    {
        $namespace = $this->getOpt('namespace');
        $to = $this->getOpt('to');
        $from = $this->getOpt('from') ?? \Minds\Core\Notification\Notification::SYSTEM_ENTITY;
        $view = $this->getOpt('view');
        $params = $this->getOpt('params') ?? '{}';

        if (is_null($namespace)) {
            $this->out('namespace must be set');
            return;
        }

        if (is_null($to)) {
            $this->out('to must be set');
            return;
        }

        if (is_null($view)) {
            $this->out('view must be set');
            return;
        }

        $paramsDecoded = json_decode($params, true);
        if (is_null($paramsDecoded)) {
            $this->out('Params is not valid JSON');
            return;
        }

        $eventParams = [
            'to' => [$to],
            'from' => $from,
            'notification_view' => $view,
            'params' => $paramsDecoded
        ];

        $sent = Dispatcher::trigger('notification', $namespace, $eventParams);

        if ($sent) {
            $this->out('Notification sent');
        } else {
            $this->out('Error sending notification - is from guid valid?');
        }
    }
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@ class reports implements Interfaces\Api, Interfaces\ApiAdminPam
        /** @var Core\Reports\Repository $repository */
        /** @var Core\Reports\Repository $repository */
        $repository = Di::_()->get('Reports\Repository');
        $repository = Di::_()->get('Reports\Repository');


        $reports = $repository->getAll([
        $reports = $repository->getList([
            'state' => $state,
            'state' => $state,
            'limit' => $limit,
            'limit' => $limit,
            'offset' => $offset
            'offset' => $offset
+3 −0
Original line number Original line Diff line number Diff line
@@ -58,6 +58,9 @@ class container implements Interfaces\Api
            case 'blogs':
            case 'blogs':
                $type = 'object:blog';
                $type = 'object:blog';
                break;
                break;
            case 'all':
                $type = 'all';
                break;
        }
        }


        $hardLimit = 5000;
        $hardLimit = 5000;
+7 −0
Original line number Original line Diff line number Diff line
@@ -20,7 +20,14 @@ class connect implements Interfaces\Api


        $connectManager = new Stripe\Connect\Manager();
        $connectManager = new Stripe\Connect\Manager();


        try {
            $account = $connectManager->getByUser($user);
            $account = $connectManager->getByUser($user);
        } catch (\Exception $e) {
            return Factory::response([
                'status' => 'error',
                'message' => 'There was an error returning the usd account',
            ]);
        }


        return Factory::response([
        return Factory::response([
            'account' => $account->export(),
            'account' => $account->export(),
+41 −0
Original line number Original line Diff line number Diff line
<?php
/**
 *
 */
namespace Minds\Controllers\api\v2\payments\stripe\connect;

use Minds\Api\Factory;
use Minds\Common\Cookie;
use Minds\Core\Di\Di;
use Minds\Core\Config;
use Minds\Core\Session;
use Minds\Interfaces;
use Minds\Core\Payments\Stripe;

class photoid implements Interfaces\Api
{
    public function get($pages)
    {
        return Factory::response([]);
    }

    public function post($pages)
    {
        $user = Session::getLoggedInUser();
        $connectManager = new Stripe\Connect\Manager();
        $account = $connectManager->getByUser($user);
        $fp = fopen($_FILES['file']['tmp_name'], 'r');
        $connectManager->addPhotoId($account, $fp);
        return Factory::response([ 'account_id' => $account->getId() ]);
    }

    public function put($pages)
    {
        return Factory::response([]);
    }

    public function delete($pages)
    {
        return Factory::response([]);
    }
}
Loading