-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pm_triggers] WIP extension to send PMs on certain events
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shimmie2; | ||
|
||
class PMTriggerInfo extends ExtensionInfo | ||
{ | ||
public const KEY = "pm_triggers"; | ||
|
||
public string $key = self::KEY; | ||
public string $name = "PM triggers"; | ||
public string $url = self::SHIMMIE_URL; | ||
public array $authors = self::SHISH_AUTHOR; | ||
public string $license = self::LICENSE_GPLV2; | ||
public string $description = "Send PMs in response to certain events (eg post deletion)"; | ||
public bool $beta = true; | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shimmie2; | ||
|
||
class PMTrigger extends Extension | ||
{ | ||
public function onImageDeletion(ImageDeletionEvent $event) | ||
{ | ||
$this->send( | ||
$event->image->owner_id, | ||
"[System] A post you uploaded has been deleted", | ||
"Post le gone~ (#{$event->image->id}, {$event->image->get_tag_list()})" | ||
); | ||
} | ||
|
||
private function send($to_id, $subject, $body) | ||
{ | ||
global $user; | ||
send_event(new SendPMEvent(new PM( | ||
$user->id, | ||
get_real_ip(), | ||
$to_id, | ||
$subject, | ||
$body | ||
))); | ||
} | ||
} |