-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
258e52e
commit 9eba26f
Showing
15 changed files
with
326 additions
and
26 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
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class DiscussionWasDeletedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class DiscussionWasHiddenHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class DiscussionWasRestoredHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class DiscussionWasStartedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class PostWasDeletedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Hidden as PostHidden; | ||
class PostWasHiddenHistory | ||
{ | ||
private $sourceDesc = "隐藏帖子"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostHidden $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class PostWasLikedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Posted; | ||
|
||
class PostWasPostedHistory | ||
{ | ||
private $sourceDesc = "发帖奖励"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(Posted $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class PostWasRestoredHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class PostWasUnlikedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Listeners; | ||
|
||
use Flarum\Notification\NotificationSyncer; | ||
use Flarum\Post\Event\Restored as PostRestored; | ||
|
||
class UserWillBeSavedHistory | ||
{ | ||
private $sourceDesc = "帖子恢复"; | ||
|
||
public function __construct(NotificationSyncer $notifications) | ||
{ | ||
$this->notifications = $notifications; | ||
} | ||
|
||
public function handle(PostRestored $event) { | ||
|
||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
namespace Mattoid\MoneyHistory\Middleware; | ||
|
||
use Flarum\Http\RequestUtil; | ||
use Flarum\Settings\SettingsRepositoryInterface; | ||
use Illuminate\Support\Arr; | ||
use Mattoid\MoneyHistory\model\UserOperateLog; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
|
||
class HistoryMiddleware implements MiddlewareInterface | ||
{ | ||
public function __construct(SettingsRepositoryInterface $settings) | ||
{ | ||
$this->settings = $settings; | ||
} | ||
|
||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | ||
{ | ||
$typesAllowed = []; | ||
$actor = RequestUtil::getActor($request); | ||
$userId = Arr::get($actor, 'id'); | ||
|
||
if ($this->settings->get('mattoid-money-history.request-type-get')) { | ||
$typesAllowed[] = "GET"; | ||
} | ||
if ($this->settings->get('mattoid-money-history.request-type-post')) { | ||
$typesAllowed[] = "POST"; | ||
} | ||
if ($this->settings->get('mattoid-money-history.request-type-put')) { | ||
$typesAllowed[] = "PUT"; | ||
$typesAllowed[] = "PATCH"; | ||
} | ||
if ($this->settings->get('mattoid-money-history.request-type-delete')) { | ||
$typesAllowed[] = "DELETE"; | ||
} | ||
|
||
$response = $handler->handle($request); | ||
|
||
if (!in_array($request->getMethod(), $typesAllowed)) { | ||
return $response; | ||
} | ||
|
||
$operateLog = new UserOperateLog(); | ||
$operateLog->user_id = $userId; | ||
$operateLog->method = $request->getMethod(); | ||
$operateLog->uri = $request->getUri(); | ||
$operateLog->request = json_encode($request->getParsedBody()); | ||
$operateLog->response = $response->getBody(); | ||
$operateLog->save(); | ||
|
||
return $response; | ||
} | ||
} |
Oops, something went wrong.