-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextend.php
27 lines (19 loc) · 817 Bytes
/
extend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
namespace MatteoCiaroni\PublicSuspensions;
use Flarum\Extend;
use Flarum\Api\Serializer\UserSerializer;
use Carbon\Carbon;
return [
(new Extend\Frontend("forum"))
->js(__DIR__."/js/dist/forum.js"),
(new Extend\Frontend("admin"))
->js(__DIR__."/js/dist/admin.js"),
new Extend\Locales(__DIR__."/locale"),
// add "suspended" attributes to user API
(new Extend\ApiSerializer(UserSerializer::class))
->attribute("suspended", function ($serializer, $user, $attributes) {
$actorCanViewSuspensions = $serializer->getActor()->hasPermission("matteociaroni-public-suspensions.read_suspensions");
$isUserSuspended = $user->suspended_until && $user->suspended_until->gt(Carbon::now());
return $actorCanViewSuspensions ? $isUserSuspended : null;
})
];