I tried like the below, but it seems the post has no ID yet. Also regarding $actor
, if it's the user posting I'm not sure they are able to "hide" their own post.
class CheckBan {
protected $bus;
public function __construct (Dispatcher $bus) {
$this->bus = $bus;
}
public function handle(Saving $event) {
if ($event->post instanceof CommentPost) {
$text = $event->post->getParsedContentAttribute();
if (stripos($text, "temu coupon") !== false) {
$this->bus->dispatch(
new EditPost($event->post->id, $event->actor, [
'attributes' => ['isHidden' => true],
])
);
}
}
}
}
Instead of this, for now I just exit;
. That causes the user posting to stay at composing their post. That's not great, as it allows them to edit and submit until they get past my keyword filter. I'd like to suspend the user then exit;
(or hide the post, if you can help with that).
To suspend the user, is it something like:
$this->bus->dispatch(
new EditUser($event->actor->id, ACTOR, [
'attributes' => ['suspendedUntil' => Carbon::now()->addYears(99)],
])
);
What do I use for ACTOR
? I guess the user can't suspend themselves. Should I look up an actor for an admin?