Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: send event when deleting all sessions #3014

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
feat: fixing realtime bugs
  • Loading branch information
christyjacob4 committed Mar 28, 2022
commit d7fc85ee99776ad98628601a0fdf2e511609be47
22 changes: 10 additions & 12 deletions app/realtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,17 @@ function () use ($register, $db, $redis) {

if ($realtime->hasSubscriber($projectId, 'user:' . $userId)) {
$connection = array_key_first(reset($realtime->subscriptions[$projectId]['user:' . $userId]));
} else {
return;

[$database, $returnDatabase] = getDatabase($register, "_{$projectId}");

$user = $database->getDocument('users', $userId);

$roles = Auth::getRoles($user);

$realtime->subscribe($projectId, $connection, $roles, $realtime->connections[$connection]['channels']);

call_user_func($returnDatabase);
}

[$database, $returnDatabase] = getDatabase($register, "_{$projectId}");

$user = $database->getDocument('users', $userId);

$roles = Auth::getRoles($user);

$realtime->subscribe($projectId, $connection, $roles, $realtime->connections[$connection]['channels']);

call_user_func($returnDatabase);
}

$receivers = $realtime->getSubscribers($event);
Expand Down
2 changes: 2 additions & 0 deletions src/Appwrite/Messaging/Adapter/Realtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function getSubscribers(array $event)
* Iterate through each channel.
*/
foreach ($event['data']['channels'] as $channel) {

/**
* Check if channel has subscriber. Also taking care of the role in the event and the wildcard role.
*/
Expand Down Expand Up @@ -282,6 +283,7 @@ public static function fromPayload(string $event, Document $payload, Document $p
$channels[] = 'memberships';
$channels[] = 'memberships.' . $payload->getId();
$roles = ['team:' . $payload->getAttribute('teamId')];
var_dump($roles, $channels);

break;
case strpos($event, 'teams.') === 0:
Expand Down