Skip to content

Commit

Permalink
fixing async
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed May 24, 2021
1 parent 99a3d1e commit 9962537
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 5 additions & 16 deletions lib/Command/MembersAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,29 @@
use daita\MySmallPhpTools\Model\Request;
use Exception;
use OC\Core\Command\Base;
use OCA\Circles\Db\CircleRequest;
use OCA\Circles\Exceptions\FederatedItemException;
use OCA\Circles\Exceptions\GSStatusException;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\MemberService;
use OCP\IL10N;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;


/**
* Class MembersCreate
* Class MembersAdd
*
* @package OCA\Circles\Command
*/
class MembersAdd extends Base {


/** @var IL10N */
private $l10n;

/** @var FederatedUserService */
private $federatedUserService;

/** @var CircleRequest */
private $circleRequest;

/** @var MemberService */
private $memberService;

Expand All @@ -79,23 +71,20 @@ class MembersAdd extends Base {


/**
* MembersCreate constructor.
* MembersAdd constructor.
*
* @param IL10N $l10n
* @param CircleRequest $circleRequest
* @param FederatedUserService $federatedUserService
* @param MemberService $memberService
* @param ConfigService $configService
*/
public function __construct(
IL10N $l10n, CircleRequest $circleRequest, FederatedUserService $federatedUserService,
MemberService $memberService, ConfigService $configService
FederatedUserService $federatedUserService,
MemberService $memberService,
ConfigService $configService
) {
parent::__construct();

$this->l10n = $l10n;
$this->federatedUserService = $federatedUserService;
$this->circleRequest = $circleRequest;

$this->memberService = $memberService;
$this->configService = $configService;
Expand Down
15 changes: 12 additions & 3 deletions lib/Controller/EventWrapperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
namespace OCA\Circles\Controller;


use daita\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Async;
use daita\MySmallPhpTools\Traits\Nextcloud\nc22\TNC22Controller;
use daita\MySmallPhpTools\Traits\TAsync;
use daita\MySmallPhpTools\Traits\TStringTools;
use Exception;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Db\EventWrapperRequest;
use OCA\Circles\Model\Federated\EventWrapper;
use OCA\Circles\Model\Federated\FederatedEvent;
Expand All @@ -56,7 +57,7 @@ class EventWrapperController extends Controller {


use TStringTools;
use TAsync;
use TNC22Async;
use TNC22Controller;


Expand Down Expand Up @@ -102,6 +103,9 @@ public function __construct(
$this->remoteUpstreamService = $remoteUpstreamService;
$this->remoteDownstreamService = $remoteDownstreamService;
$this->configService = $configService;

$this->setup('app', Application::APP_ID);
$this->setupInt(self::$SETUP_TIME_LIMIT, 900);
}


Expand All @@ -120,7 +124,7 @@ public function __construct(
*/
public function asyncBroadcast(string $token): DataResponse {
$wrappers = $this->remoteUpstreamService->getEventsByToken($token);
if (empty($wrappers)) {
if (empty($wrappers) && $token !== 'test-dummy-token') {
return new DataResponse(null, Http::STATUS_OK);
}

Expand All @@ -133,6 +137,11 @@ public function asyncBroadcast(string $token): DataResponse {

$this->federatedEventService->manageResults($token);

// circles:check can check async is fine
if ($token === 'test-dummy-token') {
sleep(5);
}

// exit() or useless log will be generated
exit();
}
Expand Down
1 change: 1 addition & 0 deletions lib/FederatedItems/SingleMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class SingleMemberAdd implements
* @param IUserManager $userManager
* @param MemberRequest $memberRequest
* @param FederatedUserService $federatedUserService
* @param RemoteStreamService $remoteStreamService
* @param CircleService $circleService
* @param MembershipService $membershipService
* @param EventService $eventService
Expand Down

0 comments on commit 9962537

Please sign in to comment.