-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add configurable throttling to video (#536)
- Loading branch information
paranarimasu
authored
Mar 1, 2023
1 parent
134a82e
commit c046440
Showing
6 changed files
with
208 additions
and
3 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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Video; | ||
|
||
use App\Constants\Config\ServiceConstants; | ||
use App\Contracts\Events\DiscordMessageEvent; | ||
use App\Enums\Discord\EmbedColor; | ||
use App\Models\Wiki\Video; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Config; | ||
use NotificationChannels\Discord\DiscordMessage; | ||
|
||
/** | ||
* Class VideoThrottled. | ||
*/ | ||
class VideoThrottled implements DiscordMessageEvent | ||
{ | ||
use Dispatchable; | ||
use SerializesModels; | ||
|
||
/** | ||
* Create new event instance. | ||
* | ||
* @param Video $video | ||
* @param string $user | ||
*/ | ||
public function __construct(protected Video $video, protected string $user) | ||
{ | ||
} | ||
|
||
/** | ||
* Get Discord message payload. | ||
* | ||
* @return DiscordMessage | ||
*/ | ||
public function getDiscordMessage(): DiscordMessage | ||
{ | ||
return DiscordMessage::create('', [ | ||
'description' => "Video '**{$this->video->getName()}**' throttled for user '**$this->user**'", | ||
'color' => EmbedColor::YELLOW, | ||
]); | ||
} | ||
|
||
/** | ||
* Get Discord channel the message will be sent to. | ||
* | ||
* @return string | ||
*/ | ||
public function getDiscordChannel(): string | ||
{ | ||
return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED); | ||
} | ||
} |
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
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