This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This version attempts to resolve major outages in using seat-groups >1.6.0 if not used with seat-notifications installed. * Refactored GroupSync job to use events for missing refreshtoken, successful attaches/detached role updates and failed syncs * Events have two listeners: one for writing a log entry and one to dispatch a notification * `MissingRefreshTokenNotification` for discord contains a link to the configuration page of that user to quicker resolve false positive messages. log events are queued into the default queue whereas notifications are prioritized. Thank you @lawin for pointing out this bug.
- Loading branch information
1 parent
0fd982b
commit 57871fe
Showing
14 changed files
with
532 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felix | ||
* Date: 08.01.2019 | ||
* Time: 20:20. | ||
*/ | ||
|
||
namespace Herpaderpaldent\Seat\SeatGroups\Events; | ||
|
||
use Illuminate\Queue\SerializesModels; | ||
use Seat\Eveapi\Models\Character\CharacterInfo; | ||
use Seat\Web\Models\Group; | ||
|
||
class GroupSyncFailed | ||
{ | ||
use SerializesModels; | ||
|
||
public $group; | ||
|
||
public $main_character; | ||
|
||
public $sync; | ||
|
||
public function __construct(Group $group, CharacterInfo $main_character) | ||
{ | ||
$this->group = $group; | ||
$this->main_character = $main_character; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felix | ||
* Date: 08.01.2019 | ||
* Time: 20:20. | ||
*/ | ||
|
||
namespace Herpaderpaldent\Seat\SeatGroups\Events; | ||
|
||
use Illuminate\Queue\SerializesModels; | ||
use Seat\Eveapi\Models\Character\CharacterInfo; | ||
use Seat\Web\Models\Group; | ||
|
||
class GroupSynced | ||
{ | ||
use SerializesModels; | ||
|
||
public $group; | ||
|
||
public $main_character; | ||
|
||
public $sync; | ||
|
||
public function __construct(Group $group, CharacterInfo $main_character, array $sync) | ||
{ | ||
$this->group = $group; | ||
$this->main_character = $main_character; | ||
$this->sync = $sync; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felix | ||
* Date: 08.01.2019 | ||
* Time: 22:40. | ||
*/ | ||
|
||
namespace Herpaderpaldent\Seat\SeatGroups\Events; | ||
|
||
use Illuminate\Queue\SerializesModels; | ||
use Seat\Eveapi\Models\Character\CharacterInfo; | ||
use Seat\Web\Models\User; | ||
|
||
class MissingRefreshToken | ||
{ | ||
use SerializesModels; | ||
|
||
public $user; | ||
|
||
public $main_character; | ||
|
||
public function __construct(User $user, CharacterInfo $main_character) | ||
{ | ||
$this->user = $user; | ||
$this->main_character = $main_character; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felix | ||
* Date: 08.01.2019 | ||
* Time: 22:23. | ||
*/ | ||
|
||
namespace Herpaderpaldent\Seat\SeatGroups\Listeners; | ||
|
||
use Herpaderpaldent\Seat\SeatGroups\Events\GroupSyncFailed; | ||
use Herpaderpaldent\Seat\SeatGroups\Models\SeatgroupLog; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
|
||
class CreateSyncFailedLogsEntry implements ShouldQueue | ||
{ | ||
public function __construct() | ||
{ | ||
|
||
} | ||
|
||
public function handle(GroupSyncFailed $event) | ||
{ | ||
|
||
$message = sprintf('An error occurred while syncing user group of %s (%s). Please check the logs.', | ||
$event->main_character->name, | ||
$event->group->users->map(function ($user) {return $user->name; })->implode(', ') | ||
); | ||
|
||
SeatgroupLog::create([ | ||
'event' => 'error', | ||
'message' => $message, | ||
]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felix | ||
* Date: 08.01.2019 | ||
* Time: 20:28. | ||
*/ | ||
|
||
namespace Herpaderpaldent\Seat\SeatGroups\Listeners; | ||
|
||
use Herpaderpaldent\Seat\SeatGroups\Events\GroupSynced; | ||
use Herpaderpaldent\Seat\SeatGroups\Models\SeatgroupLog; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Seat\Web\Models\Acl\Role; | ||
|
||
class CreateSyncedSeatLogsEntry implements ShouldQueue | ||
{ | ||
use InteractsWithQueue; | ||
|
||
public function __construct() | ||
{ | ||
|
||
} | ||
|
||
public function handle(GroupSynced $event) | ||
{ | ||
if (empty($event->sync['attached']) && empty($event->sync['detached'])) | ||
$this->delete(); | ||
|
||
if (! empty($event->sync['attached'])) { | ||
|
||
SeatgroupLog::create([ | ||
'event' => 'attached', | ||
'message' => sprintf('The user group of %s (%s) has successfully been attached to the following roles: %s.', | ||
$event->main_character->name, | ||
$event->group->users->map(function ($user) { | ||
|
||
return $user->name; | ||
})->implode(', '), | ||
Role::whereIn('id', $event->sync['attached'])->pluck('title')->implode(', ') | ||
), | ||
]); | ||
} | ||
|
||
if (! empty($event->sync['detached'])) { | ||
|
||
SeatgroupLog::create([ | ||
'event' => 'detached', | ||
'message' => sprintf('The user group of %s (%s) has been detached from the following roles: %s.', | ||
$event->main_character->name, | ||
$event->group->users->map(function ($user) { | ||
|
||
return $user->name; | ||
})->implode(', '), | ||
Role::whereIn('id', $event->sync['detached'])->pluck('title')->implode(', ') | ||
), | ||
]); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Handle a job failure. | ||
* | ||
* @param \Herpaderpaldent\Seat\SeatGroups\Events\GroupSynced $event | ||
* @param \Exception $exception | ||
* | ||
* @return void | ||
*/ | ||
public function failed(GroupSynced $event, $exception) | ||
{ | ||
report($exception); | ||
} | ||
} |
Oops, something went wrong.