1
0
mirror of https://github.com/flarum/core.git synced 2025-08-24 00:53:27 +02:00

Compare commits

..

22 Commits

Author SHA1 Message Date
StyleCI Bot
e49dd8c8b7 Apply fixes from StyleCI 2023-08-14 12:18:42 +00:00
Sami Mazouz
0db8007002 test: adapt 2023-08-14 13:16:14 +01:00
Sami Mazouz
835eba9178 chore: some fixes 2023-08-14 13:11:26 +01:00
Sami Mazouz
2a0f8ff7ed chore: use ExceptionHandler contract 2023-08-13 17:43:14 +01:00
Sami Mazouz
e1ab77f66a chore: some fixes 2023-08-13 15:50:09 +01:00
Sami Mazouz
6a812910dc fix: broken test suite 2023-08-13 15:50:04 +01:00
Sami Mazouz
f126c688d3 chore: some fixes 2023-08-13 13:43:17 +01:00
Sami Mazouz
6fb1640b3c chore: some fixes 2023-08-13 13:43:08 +01:00
Sami Mazouz
834bd732da chore: bind request to container then boot app 2023-08-13 13:41:33 +01:00
Sami Mazouz
9c3460a619 chore: adapt UrlGenerator 2023-08-11 15:48:04 +01:00
Sami Mazouz
3b3efc7cbb chore: adapt test infra 2023-08-11 15:04:30 +01:00
Sami Mazouz
cca5725fe4 chore: adapt extenders 2023-08-11 14:20:26 +01:00
Sami Mazouz
0ce33c3ec0 chore: adapt whoops formatter 2023-08-11 14:20:18 +01:00
Sami Mazouz
495b24a5aa chore: convert other middleware 2023-08-11 14:19:59 +01:00
Sami Mazouz
7d4549ea34 chore: replace request handling with illuminate http & router 2023-08-11 14:19:44 +01:00
Sami Mazouz
a60e3d174f chore: replace SeverRequestInterface with laravel Request in controllers 2023-08-11 14:17:54 +01:00
Sami Mazouz
0a89c3bd53 chore: recover container prop 2023-08-11 10:17:36 +01:00
StyleCI Bot
d056e339a4 Apply fixes from StyleCI 2023-08-11 08:34:47 +00:00
Sami Mazouz
3e49aeb32c chore: unimplement terminat(e/ing) 2023-08-11 09:34:21 +01:00
Sami Mazouz
47a0298958 chore: service provider no longer has to change app type 2023-08-11 09:28:56 +01:00
Sami Mazouz
f0eebc53ec chore: improve concern implementation readability 2023-08-11 09:28:33 +01:00
Sami Mazouz
5120e357bb chore: merge the app with the container & implement the ApplicationContract
Illuminate components always expect the app to be the container, but also expect the app to be implementing the laravel app contract. This means that very often between minor illuminate updates we get a call to a method on the app that doesn't exist in the Flarum app. This fixes the issue once and for all.
2023-08-03 14:28:18 +01:00
678 changed files with 6055 additions and 7995 deletions

View File

@@ -43,7 +43,7 @@ on:
description: Versions of databases to test with. Should be array of strings encoded as JSON array
type: string
required: false
default: '["mysql:5.7", "mysql:8.0.30", "mysql:8.1.0", "mariadb"]'
default: '["mysql:5.7", "mysql:8.0.30", "mariadb"]'
php_ini_values:
description: PHP ini values
@@ -76,8 +76,6 @@ jobs:
db: MySQL 8.0
- service: mariadb
db: MariaDB
- service: 'mysql:8.1.0'
db: MySQL 8.1
# Include Database prefix tests with only one PHP version.
- php: ${{ fromJSON(inputs.php_versions)[0] }}
@@ -95,11 +93,6 @@ jobs:
db: MariaDB
prefix: flarum_
prefixStr: (prefix)
- php: ${{ fromJSON(inputs.php_versions)[0] }}
service: 'mysql:8.1.0'
db: MySQL 8.1
prefix: flarum_
prefixStr: (prefix)
# To reduce number of actions, we exclude some PHP versions from running with some DB versions.
exclude:

View File

@@ -109,7 +109,6 @@
"ext-json": "*",
"components/font-awesome": "^5.15.0",
"composer/composer": "^2.0",
"dflydev/fig-cookies": "^3.0",
"doctrine/dbal": "^3.6.2",
"dragonmantank/cron-expression": "^3.3",
"franzl/whoops-middleware": "2.0",
@@ -124,8 +123,10 @@
"illuminate/events": "^10.0",
"illuminate/filesystem": "^10.0",
"illuminate/hashing": "^10.0",
"illuminate/http": "^10.0",
"illuminate/mail": "^10.0",
"illuminate/queue": "^10.0",
"illuminate/routing": "^10.0",
"illuminate/session": "^10.0",
"illuminate/support": "^10.0",
"illuminate/validation": "^10.0",
@@ -143,7 +144,6 @@
"middlewares/request-handler": "^2.0.2",
"monolog/monolog": "^3.3",
"nesbot/carbon": "^2.66",
"nikic/fast-route": "^1.3",
"psr/http-message": "^1.1",
"psr/http-server-handler": "^1.0.2",
"psr/http-server-middleware": "^1.0.2",
@@ -160,6 +160,7 @@
"symfony/mime": "^6.3",
"symfony/polyfill-intl-messageformatter": "^1.27",
"symfony/postmark-mailer": "^6.3",
"symfony/psr-http-message-bridge": "^2.3",
"symfony/translation": "^6.3",
"symfony/yaml": "^6.3",
"wikimedia/less.php": "^4.1"

View File

@@ -36,7 +36,7 @@ class AkismetProvider extends AbstractServiceProvider
return new Akismet(
$settings->get('flarum-akismet.api_key'),
$url->to('forum')->base(),
$url->base('forum'),
$app::VERSION,
$extensions->getExtension('flarum-akismet')->getVersion() ?? 'unknown',
$config->inDebugMode()

View File

@@ -38,7 +38,7 @@ class ListDiscussionsTest extends TestCase
$this->request('GET', '/api/discussions', compact('authenticatedAs'))
);
$body = json_decode($response->getBody()->getContents(), true);
$body = json_decode($response->getContent(), true);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEqualsCanonicalizing([1, 4, 5, 7], Arr::pluck($body['data'], 'id'));
@@ -54,7 +54,7 @@ class ListDiscussionsTest extends TestCase
$this->request('GET', '/api/discussions', compact('authenticatedAs'))
);
$body = json_decode($response->getBody()->getContents(), true);
$body = json_decode($response->getContent(), true);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], Arr::pluck($body['data'], 'id'));

View File

@@ -12,6 +12,7 @@ namespace Flarum\Approval\Tests\integration\api;
use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
class ListPostsTest extends TestCase
@@ -35,16 +36,17 @@ class ListPostsTest extends TestCase
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
{
$response = $this->send(
$this
->request('GET', '/api/posts', compact('authenticatedAs'))
->withQueryParams([
tap(
$this->request('GET', '/api/posts', compact('authenticatedAs')),
fn (Request $request) => $request->query->add([
'filter' => [
'discussion' => 7
]
])
)
);
$body = json_decode($response->getBody()->getContents(), true);
$body = json_decode($response->getContent(), true);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEqualsCanonicalizing([7, 8, 10], Arr::pluck($body['data'], 'id'));
@@ -57,16 +59,17 @@ class ListPostsTest extends TestCase
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
{
$response = $this->send(
$this
->request('GET', '/api/posts', compact('authenticatedAs'))
->withQueryParams([
tap(
$this->request('GET', '/api/posts', compact('authenticatedAs')),
fn (Request $request) => $request->query->add([
'filter' => [
'discussion' => 7
]
])
)
);
$body = json_decode($response->getBody()->getContents(), true);
$body = json_decode($response->getContent(), true);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEqualsCanonicalizing([7, 8, 9, 10, 11], Arr::pluck($body['data'], 'id'));

View File

@@ -9,7 +9,7 @@
use Flarum\Extend;
use Flarum\Frontend\Document;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Http\Request;
return [
(new Extend\Frontend('forum'))

View File

@@ -50,7 +50,7 @@
padding: 15px 15px;
.scrolled & {
.box-shadow(0 2px 6px var(--shadow-color));
.box-shadow(0 2px 6px @shadow-color);
}
}
@@ -69,7 +69,7 @@
margin: 0;
&, a {
color: var(--muted-color);
color: @muted-color;
}
}
}

View File

@@ -12,7 +12,7 @@ img.emoji {
margin: 5px 0 !important;
> li > button {
color: var(--text-color);
color: @text-color;
font-weight: bold;
padding-top: 6px;
padding-bottom: 6px;
@@ -25,7 +25,7 @@ img.emoji {
}
.Dropdown-header {
color: var(--muted-more-color);
color: @muted-more-color;
text-transform: none;
font-weight: normal;
padding-bottom: 5px;

View File

@@ -1,11 +1,7 @@
import Component from 'flarum/common/Component';
import type { ComponentAttrs } from 'flarum/common/Component';
import type Mithril from 'mithril';
import type FlagListState from '../states/FlagListState';
export interface IFlagListAttrs extends ComponentAttrs {
state: FlagListState;
}
export default class FlagList<CustomAttrs extends IFlagListAttrs = IFlagListAttrs> extends Component<CustomAttrs, FlagListState> {
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
export default class FlagList extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
constructor();
oninit(vnode: any): void;
state: any;
view(): JSX.Element;
}
import Component from "flarum/common/Component";

View File

@@ -1,12 +1,7 @@
/// <reference types="mithril" />
import HeaderDropdown from 'flarum/forum/components/HeaderDropdown';
import type { IHeaderDropdownAttrs } from 'flarum/forum/components/HeaderDropdown';
export interface IFlagsDropdownAttrs extends IHeaderDropdownAttrs {
}
export default class FlagsDropdown<CustomAttrs extends IFlagsDropdownAttrs = IFlagsDropdownAttrs> extends HeaderDropdown<CustomAttrs> {
static initAttrs(attrs: IFlagsDropdownAttrs): void;
getContent(): JSX.Element;
goToRoute(): void;
getUnreadCount(): number;
getNewCount(): number;
export default class FlagsDropdown extends NotificationsDropdown<import("flarum/common/components/Dropdown").IDropdownAttrs> {
static initAttrs(attrs: any): void;
constructor();
getUnreadCount(): any;
getNewCount(): unknown;
}
import NotificationsDropdown from "flarum/forum/components/NotificationsDropdown";

View File

@@ -1,15 +1,16 @@
import type ForumApplication from 'flarum/forum/ForumApplication';
import type Flag from '../models/Flag';
import type Post from 'flarum/common/models/Post';
export default class FlagListState {
app: ForumApplication;
constructor(app: any);
app: any;
/**
* Whether or not the flags are loading.
*
* @type {Boolean}
*/
loading: boolean;
cache: Flag[] | null;
index: Post | false | null;
constructor(app: ForumApplication);
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load(): void;
cache: any;
}

2
extensions/flags/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { extend, override } from 'flarum/common/extend';
import { extend } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import Post from 'flarum/forum/components/Post';
import Button from 'flarum/common/components/Button';
@@ -75,7 +75,7 @@ export default function () {
return items;
};
override(Post.prototype, 'header', function (vdom) {
extend(Post.prototype, 'content', function (vdom) {
const post = this.attrs.post;
const flags = post.flags();
@@ -83,7 +83,7 @@ export default function () {
if (post.isHidden()) this.revealContent = true;
return (
vdom.unshift(
<div className="Post-flagged">
<div className="Post-flagged-flags">
{flags.map((flag) => (

View File

@@ -0,0 +1,65 @@
import app from 'flarum/forum/app';
import Component from 'flarum/common/Component';
import Link from 'flarum/common/components/Link';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import avatar from 'flarum/common/helpers/avatar';
import username from 'flarum/common/helpers/username';
import icon from 'flarum/common/helpers/icon';
import humanTime from 'flarum/common/helpers/humanTime';
export default class FlagList extends Component {
oninit(vnode) {
super.oninit(vnode);
this.state = this.attrs.state;
}
view() {
const flags = this.state.cache || [];
return (
<div className="NotificationList FlagList">
<div className="NotificationList-header">
<h4 className="App-titleControl App-titleControl--text">{app.translator.trans('flarum-flags.forum.flagged_posts.title')}</h4>
</div>
<div className="NotificationList-content">
<ul className="NotificationGroup-content">
{flags.length ? (
flags.map((flag) => {
const post = flag.post();
return (
<li>
<Link
href={app.route.post(post)}
className="Notification Flag"
onclick={(e) => {
app.flags.index = post;
e.redraw = false;
}}
>
{avatar(post.user())}
{icon('fas fa-flag', { className: 'Notification-icon' })}
<span className="Notification-content">
{app.translator.trans('flarum-flags.forum.flagged_posts.item_text', {
username: username(post.user()),
em: <em />,
discussion: post.discussion().title(),
})}
</span>
{humanTime(flag.createdAt())}
<div className="Notification-excerpt">{post.contentPlain()}</div>
</Link>
</li>
);
})
) : !this.state.loading ? (
<div className="NotificationList-empty">{app.translator.trans('flarum-flags.forum.flagged_posts.empty_text')}</div>
) : (
<LoadingIndicator className="LoadingIndicator--block" />
)}
</ul>
</div>
</div>
);
}
}

View File

@@ -1,64 +0,0 @@
import app from 'flarum/forum/app';
import Component from 'flarum/common/Component';
import type { ComponentAttrs } from 'flarum/common/Component';
import Avatar from 'flarum/common/components/Avatar';
import username from 'flarum/common/helpers/username';
import HeaderList from 'flarum/forum/components/HeaderList';
import HeaderListItem from 'flarum/forum/components/HeaderListItem';
import type Mithril from 'mithril';
import type Post from 'flarum/common/models/Post';
import type FlagListState from '../states/FlagListState';
export interface IFlagListAttrs extends ComponentAttrs {
state: FlagListState;
}
export default class FlagList<CustomAttrs extends IFlagListAttrs = IFlagListAttrs> extends Component<CustomAttrs, FlagListState> {
oninit(vnode: Mithril.Vnode<CustomAttrs, this>) {
super.oninit(vnode);
this.state = this.attrs.state;
}
view() {
const flags = this.state.cache || [];
return (
<HeaderList
className="FlagList"
title={app.translator.trans('flarum-flags.forum.flagged_posts.title')}
hasItems={flags.length}
loading={this.state.loading}
emptyText={app.translator.trans('flarum-flags.forum.flagged_posts.empty_text')}
>
<ul className="HeaderListGroup-content">
{!this.state.loading &&
flags.map((flag) => {
const post = flag.post() as Post;
return (
<li>
<HeaderListItem
className="Flag"
avatar={<Avatar user={post.user() || null} />}
icon="fas fa-flag"
content={app.translator.trans('flarum-flags.forum.flagged_posts.item_text', {
username: username(post.user()),
em: <em />,
discussion: post.discussion().title(),
})}
excerpt={post.contentPlain()}
datetime={flag.createdAt()}
href={app.route.post(post)}
onclick={(e: MouseEvent) => {
app.flags.index = post;
e.redraw = false;
}}
/>
</li>
);
})}
</ul>
</HeaderList>
);
}
}

View File

@@ -1,6 +1,5 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Form from 'flarum/common/components/Form';
import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
@@ -29,31 +28,31 @@ export default class FlagPostModal extends Modal {
if (this.success) {
return (
<div className="Modal-body">
<Form className="Form--centered">
<div className="Form Form--centered">
<p className="helpText">{app.translator.trans('flarum-flags.forum.flag_post.confirmation_message')}</p>
<div className="Form-group Form-controls">
<div className="Form-group">
<Button className="Button Button--primary Button--block" onclick={this.hide.bind(this)}>
{app.translator.trans('flarum-flags.forum.flag_post.dismiss_button')}
</Button>
</div>
</Form>
</div>
</div>
);
}
return (
<div className="Modal-body">
<Form className="Form--centered">
<div className="Form Form--centered">
<div className="Form-group">
<div>{this.flagReasons().toArray()}</div>
</div>
<div className="Form-group Form-controls">
<div className="Form-group">
<Button className="Button Button--primary Button--block" type="submit" loading={this.loading} disabled={!this.reason()}>
{app.translator.trans('flarum-flags.forum.flag_post.submit_button')}
</Button>
</div>
</Form>
</div>
</div>
);
}

View File

@@ -0,0 +1,33 @@
import app from 'flarum/forum/app';
import NotificationsDropdown from 'flarum/forum/components/NotificationsDropdown';
import FlagList from './FlagList';
export default class FlagsDropdown extends NotificationsDropdown {
static initAttrs(attrs) {
attrs.label = attrs.label || app.translator.trans('flarum-flags.forum.flagged_posts.tooltip');
attrs.icon = attrs.icon || 'fas fa-flag';
super.initAttrs(attrs);
}
getMenu() {
return (
<div className={'Dropdown-menu ' + this.attrs.menuClassName} onclick={this.menuClick.bind(this)}>
{this.showing && <FlagList state={this.attrs.state} />}
</div>
);
}
goToRoute() {
m.route.set(app.route('flags'));
}
getUnreadCount() {
return app.flags.cache ? app.flags.cache.length : app.forum.attribute('flagCount');
}
getNewCount() {
return app.session.user.attribute('newFlagCount');
}
}

View File

@@ -1,34 +0,0 @@
import app from 'flarum/forum/app';
import HeaderDropdown from 'flarum/forum/components/HeaderDropdown';
import type { IHeaderDropdownAttrs } from 'flarum/forum/components/HeaderDropdown';
import classList from 'flarum/common/utils/classList';
import FlagList from './FlagList';
export interface IFlagsDropdownAttrs extends IHeaderDropdownAttrs {}
export default class FlagsDropdown<CustomAttrs extends IFlagsDropdownAttrs = IFlagsDropdownAttrs> extends HeaderDropdown<CustomAttrs> {
static initAttrs(attrs: IFlagsDropdownAttrs) {
attrs.className = classList('FlagsDropdown', attrs.className);
attrs.label = attrs.label || app.translator.trans('flarum-flags.forum.flagged_posts.tooltip');
attrs.icon = attrs.icon || 'fas fa-flag';
super.initAttrs(attrs);
}
getContent() {
return <FlagList state={this.attrs.state} />;
}
goToRoute() {
m.route.set(app.route('flags'));
}
getUnreadCount() {
return app.flags.cache ? app.flags.cache.length : app.forum.attribute<number>('flagCount');
}
getNewCount() {
return app.session.user!.attribute<number>('newFlagCount');
}
}

View File

@@ -0,0 +1,37 @@
export default class FlagListState {
constructor(app) {
this.app = app;
/**
* Whether or not the flags are loading.
*
* @type {Boolean}
*/
this.loading = false;
}
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load() {
if (this.cache && !this.app.session.user.attribute('newFlagCount')) {
return;
}
this.loading = true;
m.redraw();
this.app.store
.find('flags')
.then((flags) => {
this.app.session.user.pushAttributes({ newFlagCount: 0 });
this.cache = flags.sort((a, b) => b.createdAt() - a.createdAt());
})
.catch(() => {})
.then(() => {
this.loading = false;
m.redraw();
});
}
}

View File

@@ -1,39 +0,0 @@
import type ForumApplication from 'flarum/forum/ForumApplication';
import type Flag from '../models/Flag';
import type Post from 'flarum/common/models/Post';
export default class FlagListState {
public app: ForumApplication;
public loading = false;
public cache: Flag[] | null = null;
public index: Post | false | null = null;
constructor(app: ForumApplication) {
this.app = app;
}
/**
* Load flags into the application's cache if they haven't already
* been loaded.
*/
load() {
if (this.cache && !this.app.session.user!.attribute<number>('newFlagCount')) {
return;
}
this.loading = true;
m.redraw();
this.app.store
.find<Flag[]>('flags')
.then((flags) => {
this.app.session.user!.pushAttributes({ newFlagCount: 0 });
this.cache = flags.sort((a, b) => b.createdAt()!.getTime() - a.createdAt()!.getTime());
})
.catch(() => {})
.then(() => {
this.loading = false;
m.redraw();
});
}
}

View File

@@ -1,9 +1,6 @@
.Post--flagged {
--border-width: 2px;
padding-top: 0 !important;
padding-left: var(--post-padding);
margin-left: calc(~"0px - var(--post-padding)");
border: var(--border-width) solid var(--primary-color);
border: 2px solid @primary-color;
}
.Post-header .item-flagged {
@@ -11,22 +8,29 @@
margin: 0;
}
.Post-flagged {
background: var(--primary-color);
margin: calc(~"0px - var(--border-width)") calc(~"0px - var(--border-width) - var(--post-padding)") var(--post-padding);
background: @primary-color;
margin-top: -2px;
margin-bottom: 20px;
margin-left: -22px;
margin-right: -22px;
padding: 10px;
border-radius: var(--border-radius) var(--border-radius) 0 0;
border-radius: @border-radius @border-radius 0 0;
overflow: hidden;
.light-contents(@color: @body-bg; @control-color: @body-bg);
display: flex;
align-items: center;
justify-content: space-between;
@media @tablet-up {
margin-left: -22px - 85px;
}
&, a {
color: var(--body-bg) !important;
color: @body-bg !important;
}
}
.Post-flagged-flags {
@media @tablet-up {
float: left;
}
font-size: 14px;
margin: 7px 10px;
text-align: left;
@@ -38,10 +42,19 @@
font-weight: normal;
}
.Post-flagged-actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 5px;
@media @tablet-up {
float: right;
}
}
.Post-flagged-actions .Button {
margin-left: 5px;
}
.FlagsDropdown .Dropdown-toggle {
.Button-label,
.Button-caret {
display: none;
}
}
.FlagPostModal {
@@ -53,16 +66,7 @@
strong {
display: block;
color: var(--text-color);
color: @text-color;
}
}
}
.Flag .HeaderListItem-title {
justify-content: space-between;
flex-wrap: nowrap;
}
.Flag .HeaderListItem-time {
flex-shrink: 0;
}

View File

@@ -15,8 +15,7 @@ use Flarum\Flags\Command\CreateFlag;
use Flarum\Flags\Flag;
use Flarum\Http\RequestUtil;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
use Tobscure\JsonApi\Document;
class CreateFlagController extends AbstractCreateController
@@ -34,10 +33,10 @@ class CreateFlagController extends AbstractCreateController
) {
}
protected function data(ServerRequestInterface $request, Document $document): Flag
protected function data(Request $request, Document $document): Flag
{
return $this->bus->dispatch(
new CreateFlag(RequestUtil::getActor($request), Arr::get($request->getParsedBody(), 'data', []))
new CreateFlag(RequestUtil::getActor($request), $request->json('data', []))
);
}
}

View File

@@ -13,8 +13,7 @@ use Flarum\Api\Controller\AbstractDeleteController;
use Flarum\Flags\Command\DeleteFlags;
use Flarum\Http\RequestUtil;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
class DeleteFlagsController extends AbstractDeleteController
{
@@ -23,10 +22,10 @@ class DeleteFlagsController extends AbstractDeleteController
) {
}
protected function delete(ServerRequestInterface $request): void
protected function delete(Request $request): void
{
$this->bus->dispatch(
new DeleteFlags(Arr::get($request->getQueryParams(), 'id'), RequestUtil::getActor($request), $request->getParsedBody())
new DeleteFlags($request->route('id'), RequestUtil::getActor($request), $request->json()->all())
);
}
}

View File

@@ -14,7 +14,7 @@ use Flarum\Api\Controller\AbstractListController;
use Flarum\Flags\Api\Serializer\FlagSerializer;
use Flarum\Flags\Flag;
use Flarum\Http\RequestUtil;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
use Tobscure\JsonApi\Document;
class ListFlagsController extends AbstractListController
@@ -28,7 +28,7 @@ class ListFlagsController extends AbstractListController
'post.discussion'
];
protected function data(ServerRequestInterface $request, Document $document): iterable
protected function data(Request $request, Document $document): iterable
{
$actor = RequestUtil::getActor($request);
$include = $this->extractInclude($request);

View File

@@ -24,7 +24,7 @@ class FlagSerializer extends AbstractSerializer
{
if (! ($model instanceof Flag)) {
throw new InvalidArgumentException(
$this::class.' can only serialize instances of '.Flag::class
get_class($this).' can only serialize instances of '.Flag::class
);
}

View File

@@ -13,11 +13,11 @@ use Flarum\Api\Controller;
use Flarum\Flags\Api\Controller\CreateFlagController;
use Flarum\Http\RequestUtil;
use Illuminate\Database\Eloquent\Collection;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
class PrepareFlagsApiData
{
public function __invoke(Controller\AbstractSerializeController $controller, mixed $data, ServerRequestInterface $request): void
public function __invoke(Controller\AbstractSerializeController $controller, mixed $data, Request $request): void
{
// For any API action that allows the 'flags' relationship to be
// included, we need to preload this relationship onto the data (Post

View File

@@ -75,7 +75,7 @@ class ListTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);
@@ -94,7 +94,7 @@ class ListTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
@@ -113,7 +113,7 @@ class ListTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);

View File

@@ -108,7 +108,7 @@ class ListWithTagsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing(['1', '4', '5', '6', '7', '8', '9'], $ids);
@@ -127,7 +127,7 @@ class ListWithTagsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
@@ -146,7 +146,7 @@ class ListWithTagsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$ids = Arr::pluck($data, 'id');
// 7 is included, even though mods can't view discussions.

2
extensions/likes/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,7 @@ import CommentPost from 'flarum/forum/components/CommentPost';
import Link from 'flarum/common/components/Link';
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
import username from 'flarum/common/helpers/username';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import Button from 'flarum/common/components/Button';
import PostLikesModal from './components/PostLikesModal';
@@ -58,7 +58,7 @@ export default function () {
items.add(
'liked',
<div className="Post-likedBy">
<Icon name={'far fa-thumbs-up'} />
{icon('far fa-thumbs-up')}
{app.translator.trans(`flarum-likes.forum.post.liked_by${likes[0] === app.session.user ? '_self' : ''}_text`, {
count: names.length,
users: punctuateSeries(names),

View File

@@ -1,7 +1,7 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Link from 'flarum/common/components/Link';
import Avatar from 'flarum/common/components/Avatar';
import avatar from 'flarum/common/helpers/avatar';
import username from 'flarum/common/helpers/username';
import type { IInternalModalAttrs } from 'flarum/common/components/Modal';
import type Post from 'flarum/common/models/Post';
@@ -9,7 +9,6 @@ import type Mithril from 'mithril';
import PostLikesModalState from '../states/PostLikesModalState';
import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import Form from 'flarum/common/components/Form';
export interface IPostLikesModalAttrs extends IInternalModalAttrs {
post: Post;
@@ -48,7 +47,7 @@ export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = I
page.items.map((user) => (
<li>
<Link href={app.route.user(user)}>
<Avatar user={user} /> {username(user)}
{avatar(user)} {username(user)}
</Link>
</li>
))
@@ -58,13 +57,13 @@ export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = I
</div>
{this.state.hasNext() ? (
<div className="Modal-footer">
<Form className="Form--centered">
<div className="Form Form--centered">
<div className="Form-group">
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
{app.translator.trans('flarum-likes.forum.post_likes.load_more_button')}
</Button>
</div>
</Form>
</div>
</div>
) : null}
</>

View File

@@ -4,7 +4,7 @@
margin: 0;
a {
color: var(--text-color);
color: @text-color;
font-size: 15px;
font-weight: bold;
display: block;

View File

@@ -16,13 +16,13 @@ use Flarum\Post\Post;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Expression;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
class LoadLikesRelationship
{
public static int $maxLikes = 4;
public static function mutateRelation(BelongsToMany $query, ServerRequestInterface $request): void
public static function mutateRelation(BelongsToMany $query, Request $request): void
{
$actor = RequestUtil::getActor($request);

View File

@@ -143,7 +143,7 @@ class LikePostTest extends TestCase
$this->request('GET', '/')
);
$token = $initial->getHeaderLine('X-CSRF-Token');
$token = $initial->headers->get('X-CSRF-Token');
}
$request = $this->request('PATCH', "/api/posts/$postId", [
@@ -159,7 +159,7 @@ class LikePostTest extends TestCase
]);
if (! isset($authenticatedAs)) {
$request = $request->withHeader('X-CSRF-Token', $token);
$request->headers->set('X-CSRF-Token', $token);
}
return $this->send($request);

View File

@@ -14,6 +14,7 @@ use Flarum\Group\Group;
use Flarum\Likes\Api\LoadLikesRelationship;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
class ListPostsTest extends TestCase
@@ -75,15 +76,17 @@ class ListPostsTest extends TestCase
public function liked_filter_works()
{
$response = $this->send(
$this->request('GET', '/api/users')
->withQueryParams([
tap(
$this->request('GET', '/api/users'),
fn (Request $request) => $request->query->add([
'filter' => ['liked' => 101],
])
)
);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
@@ -98,15 +101,17 @@ class ListPostsTest extends TestCase
public function liked_filter_works_negated()
{
$response = $this->send(
$this->request('GET', '/api/users')
->withQueryParams([
'filter' => ['-liked' => 101],
])
tap(
$this->request('GET', '/api/users'),
fn (Request $request) => $request->query->add([
'filter' => ['-liked' => 101],
])
)
);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
@@ -118,14 +123,17 @@ class ListPostsTest extends TestCase
{
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts/101', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => 'likes',
])
tap(
$this->request('GET', '/api/posts/101', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'include' => 'likes',
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
@@ -144,15 +152,18 @@ class ListPostsTest extends TestCase
{
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
])->withQueryParams([
'filter' => ['discussion' => 100],
'include' => 'likes',
])
tap(
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'filter' => ['discussion' => 100],
'include' => 'likes',
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
@@ -174,14 +185,17 @@ class ListPostsTest extends TestCase
{
// Show discussion endpoint
$response = $this->send(
$this->request('GET', '/api/discussions/100', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => $include,
])
tap(
$this->request('GET', '/api/discussions/100', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'include' => $include,
])
)
);
$included = json_decode($response->getBody()->getContents(), true)['included'];
$included = json_decode($response->getContent(), true)['included'];
$likes = collect($included)
->where('type', 'posts')

2
extensions/lock/js/dist/forum.js generated vendored
View File

@@ -1,2 +1,2 @@
(()=>{var o={n:t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t),o.d(t,{extend:()=>P});const e=flarum.reg.get("core","common/extend"),n=flarum.reg.get("core","forum/app");var r=o.n(n);const s=flarum.reg.get("core","forum/components/Notification");var c=o.n(s);class a extends(c()){icon(){return"fas fa-lock"}href(){const o=this.attrs.notification;return r().route.discussion(o.subject(),o.content().postNumber)}content(){return r().translator.trans("flarum-lock.forum.notifications.discussion_locked_text",{user:this.attrs.notification.fromUser()})}excerpt(){return null}}flarum.reg.add("flarum-lock","forum/components/DiscussionLockedNotification",a);const i=flarum.reg.get("core","common/models/Discussion");var u=o.n(i);const l=flarum.reg.get("core","common/components/Badge");var d=o.n(l);const f=flarum.reg.get("core","forum/utils/DiscussionControls");var k=o.n(f);const g=flarum.reg.get("core","forum/components/DiscussionPage");var p=o.n(g);const b=flarum.reg.get("core","common/components/Button");var _=o.n(b);const v=flarum.reg.get("core","common/extenders");var y=o.n(v);const x=flarum.reg.get("core","forum/components/EventPost");var L=o.n(x);class h extends(L()){icon(){return this.attrs.post.content().locked?"fas fa-lock":"fas fa-unlock"}descriptionKey(){return this.attrs.post.content().locked?"flarum-lock.forum.post_stream.discussion_locked_text":"flarum-lock.forum.post_stream.discussion_unlocked_text"}}flarum.reg.add("flarum-lock","forum/components/DiscussionLockedPost",h);const P=[(new(y().PostTypes)).add("discussionLocked",h),new(y().Model)(u()).attribute("isLocked").attribute("canLock")];r().initializers.add("flarum-lock",(()=>{r().notificationComponents.discussionLocked=a,(0,e.extend)(u().prototype,"badges",(function(o){this.isLocked()&&o.add("locked",m(d(),{type:"locked",label:r().translator.trans("flarum-lock.forum.badge.locked_tooltip"),icon:"fas fa-lock"}))})),(0,e.extend)(k(),"moderationControls",(function(o,t){t.canLock()&&o.add("lock",m(_(),{icon:"fas fa-lock",onclick:this.lockAction.bind(t)},r().translator.trans("flarum-lock.forum.discussion_controls.".concat(t.isLocked()?"unlock":"lock","_button"))))})),k().lockAction=function(){this.save({isLocked:!this.isLocked()}).then((()=>{r().current.matches(p())&&r().current.get("stream").update(),m.redraw()}))},(0,e.extend)("flarum/forum/components/NotificationGrid","notificationTypes",(function(o){o.add("discussionLocked",{name:"discussionLocked",icon:"fas fa-lock",label:r().translator.trans("flarum-lock.forum.settings.notify_discussion_locked_label")})}))}))})(),module.exports=t})();
(()=>{var o={n:t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t),o.d(t,{extend:()=>P});const e=flarum.reg.get("core","common/extend"),n=flarum.reg.get("core","forum/app");var r=o.n(n);const s=flarum.reg.get("core","forum/components/Notification");var c=o.n(s);class a extends(c()){icon(){return"fas fa-lock"}href(){const o=this.attrs.notification;return r().route.discussion(o.subject(),o.content().postNumber)}content(){return r().translator.trans("flarum-lock.forum.notifications.discussion_locked_text",{user:this.attrs.notification.fromUser()})}}flarum.reg.add("flarum-lock","forum/components/DiscussionLockedNotification",a);const i=flarum.reg.get("core","common/models/Discussion");var u=o.n(i);const l=flarum.reg.get("core","common/components/Badge");var d=o.n(l);const f=flarum.reg.get("core","forum/utils/DiscussionControls");var k=o.n(f);const g=flarum.reg.get("core","forum/components/DiscussionPage");var p=o.n(g);const b=flarum.reg.get("core","common/components/Button");var _=o.n(b);const v=flarum.reg.get("core","common/extenders");var y=o.n(v);const L=flarum.reg.get("core","forum/components/EventPost");var h=o.n(L);class x extends(h()){icon(){return this.attrs.post.content().locked?"fas fa-lock":"fas fa-unlock"}descriptionKey(){return this.attrs.post.content().locked?"flarum-lock.forum.post_stream.discussion_locked_text":"flarum-lock.forum.post_stream.discussion_unlocked_text"}}flarum.reg.add("flarum-lock","forum/components/DiscussionLockedPost",x);const P=[(new(y().PostTypes)).add("discussionLocked",x),new(y().Model)(u()).attribute("isLocked").attribute("canLock")];r().initializers.add("flarum-lock",(()=>{r().notificationComponents.discussionLocked=a,(0,e.extend)(u().prototype,"badges",(function(o){this.isLocked()&&o.add("locked",m(d(),{type:"locked",label:r().translator.trans("flarum-lock.forum.badge.locked_tooltip"),icon:"fas fa-lock"}))})),(0,e.extend)(k(),"moderationControls",(function(o,t){t.canLock()&&o.add("lock",m(_(),{icon:"fas fa-lock",onclick:this.lockAction.bind(t)},r().translator.trans("flarum-lock.forum.discussion_controls.".concat(t.isLocked()?"unlock":"lock","_button"))))})),k().lockAction=function(){this.save({isLocked:!this.isLocked()}).then((()=>{r().current.matches(p())&&r().current.get("stream").update(),m.redraw()}))},(0,e.extend)("flarum/forum/components/NotificationGrid","notificationTypes",(function(o){o.add("discussionLocked",{name:"discussionLocked",icon:"fas fa-lock",label:r().translator.trans("flarum-lock.forum.settings.notify_discussion_locked_label")})}))}))})(),module.exports=t})();
//# sourceMappingURL=forum.js.map

File diff suppressed because one or more lines are too long

View File

@@ -15,8 +15,4 @@ export default class DiscussionLockedNotification extends Notification {
content() {
return app.translator.trans('flarum-lock.forum.notifications.discussion_locked_text', { user: this.attrs.notification.fromUser() });
}
excerpt() {
return null;
}
}

View File

@@ -1,3 +1,3 @@
/*! For license information please see admin.js.LICENSE.txt */
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.reg.get("core","admin/app");var r=t.n(o);const i=flarum.reg.get("core","common/app");var n=t.n(i);const a=flarum.reg.get("core","common/extend"),l=flarum.reg.get("core","common/utils/BasicEditorDriver");var c=t.n(l);const s=flarum.reg.get("core","common/utils/styleSelectedText");var d=t.n(s);const f=flarum.reg.get("core","common/Component");var u=t.n(f);class p extends(u()){view(t){return m("div",{className:"MarkdownToolbar"},t.children)}}flarum.reg.add("flarum-markdown","common/components/MarkdownToolbar",p);const k=flarum.reg.get("core","common/components/Icon");var h=t.n(k);const g=flarum.reg.get("core","common/components/Tooltip");var x=t.n(g);class b extends(u()){oncreate(t){super.oncreate(t)}view(){const t=m("button",{className:"Button Button--icon Button--link",type:"button","data-hotkey":this.attrs.hotkey,onkeydown:this.keydown.bind(this),onclick:this.attrs.onclick},m(h(),{name:this.attrs.icon}));return this.attrs.title?m(x(),{text:this.attrs.title},t):t}keydown(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.element.click())}}flarum.reg.add("flarum-markdown","common/components/MarkdownButton",b);const y=flarum.reg.get("core","common/utils/ItemList");var v=t.n(y);const w=navigator.userAgent.match(/Macintosh/)?"⌘":"ctrl",_={header:{prefix:"### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},image:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},unordered_list:{prefix:"- ",multiline:!0,surroundWithNewlines:!0},ordered_list:{prefix:"1. ",multiline:!0,orderedList:!0},spoiler:{prefix:">!",suffix:"!<",blockPrefix:">! ",multiline:!0,trimFirst:!0}},T=(t,e)=>{d()(e.el,_[t])};function S(t,e,o){return function(r){r.key===e&&(r.metaKey&&"⌘"===w||r.ctrlKey&&"ctrl"===w)&&(r.preventDefault(),T(t,o))}}function M(t){const e="function"==typeof t?t():new(v());function o(t,e){return n().translator.trans("flarum-markdown.lib.composer.".concat(t,"_tooltip"))+(e?" <".concat(w,"-").concat(e,">"):"")}const r=t=>()=>T(t,this.attrs.composer.editor);return e.add("header",m(b,{title:o("header"),icon:"fas fa-heading",onclick:r("header")}),1e3),e.add("bold",m(b,{title:o("bold","b"),icon:"fas fa-bold",onclick:r("bold")}),900),e.add("italic",m(b,{title:o("italic","i"),icon:"fas fa-italic",onclick:r("italic")}),800),e.add("strikethrough",m(b,{title:o("strikethrough"),icon:"fas fa-strikethrough",onclick:r("strikethrough")}),700),e.add("quote",m(b,{title:o("quote"),icon:"fas fa-quote-left",onclick:r("quote")}),600),e.add("spoiler",m(b,{title:o("spoiler"),icon:"fas fa-exclamation-triangle",onclick:r("spoiler")}),500),e.add("code",m(b,{title:o("code"),icon:"fas fa-code",onclick:r("code")}),400),e.add("link",m(b,{title:o("link"),icon:"fas fa-link",onclick:r("link")}),300),e.add("image",m(b,{title:o("image"),icon:"fas fa-image",onclick:r("image")}),200),e.add("unordered_list",m(b,{title:o("unordered_list"),icon:"fas fa-list-ul",onclick:r("unordered_list")}),100),e.add("ordered_list",m(b,{title:o("ordered_list"),icon:"fas fa-list-ol",onclick:r("ordered_list")}),0),e}r().initializers.add("flarum-markdown",(function(t){(0,a.extend)(c().prototype,"keyHandlers",(function(t){t.add("bold",S("bold","b",this)),t.add("italic",S("italic","i",this))})),(0,a.override)("flarum/common/components/TextEditor","markdownToolbarItems",M),(0,a.extend)("flarum/common/components/TextEditor","toolbarItems",(function(t){t.add("markdown",m(p,{for:this.textareaId,setShortcutHandler:t=>shortcutHandler=t},this.markdownToolbarItems().toArray()),100)}))}))})(),module.exports=e})();
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.reg.get("core","admin/app");var r=t.n(o);const i=flarum.reg.get("core","common/app");var n=t.n(i);const a=flarum.reg.get("core","common/extend"),l=flarum.reg.get("core","common/utils/BasicEditorDriver");var c=t.n(l);const s=flarum.reg.get("core","common/utils/styleSelectedText");var d=t.n(s);const f=flarum.reg.get("core","common/Component");var u=t.n(f);class p extends(u()){view(t){return m("div",{className:"MarkdownToolbar"},t.children)}}flarum.reg.add("flarum-markdown","common/components/MarkdownToolbar",p);const k=flarum.reg.get("core","common/helpers/icon");var h=t.n(k);const g=flarum.reg.get("core","common/components/Tooltip");var x=t.n(g);class b extends(u()){oncreate(t){super.oncreate(t)}view(){const t=m("button",{className:"Button Button--icon Button--link",type:"button","data-hotkey":this.attrs.hotkey,onkeydown:this.keydown.bind(this),onclick:this.attrs.onclick},h()(this.attrs.icon));return this.attrs.title?m(x(),{text:this.attrs.title},t):t}keydown(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.element.click())}}flarum.reg.add("flarum-markdown","common/components/MarkdownButton",b);const y=flarum.reg.get("core","common/utils/ItemList");var v=t.n(y);const w=navigator.userAgent.match(/Macintosh/)?"⌘":"ctrl",_={header:{prefix:"### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},image:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},unordered_list:{prefix:"- ",multiline:!0,surroundWithNewlines:!0},ordered_list:{prefix:"1. ",multiline:!0,orderedList:!0},spoiler:{prefix:">!",suffix:"!<",blockPrefix:">! ",multiline:!0,trimFirst:!0}},T=(t,e)=>{d()(e.el,_[t])};function S(t,e,o){return function(r){r.key===e&&(r.metaKey&&"⌘"===w||r.ctrlKey&&"ctrl"===w)&&(r.preventDefault(),T(t,o))}}function M(t){const e="function"==typeof t?t():new(v());function o(t,e){return n().translator.trans("flarum-markdown.lib.composer.".concat(t,"_tooltip"))+(e?" <".concat(w,"-").concat(e,">"):"")}const r=t=>()=>T(t,this.attrs.composer.editor);return e.add("header",m(b,{title:o("header"),icon:"fas fa-heading",onclick:r("header")}),1e3),e.add("bold",m(b,{title:o("bold","b"),icon:"fas fa-bold",onclick:r("bold")}),900),e.add("italic",m(b,{title:o("italic","i"),icon:"fas fa-italic",onclick:r("italic")}),800),e.add("strikethrough",m(b,{title:o("strikethrough"),icon:"fas fa-strikethrough",onclick:r("strikethrough")}),700),e.add("quote",m(b,{title:o("quote"),icon:"fas fa-quote-left",onclick:r("quote")}),600),e.add("spoiler",m(b,{title:o("spoiler"),icon:"fas fa-exclamation-triangle",onclick:r("spoiler")}),500),e.add("code",m(b,{title:o("code"),icon:"fas fa-code",onclick:r("code")}),400),e.add("link",m(b,{title:o("link"),icon:"fas fa-link",onclick:r("link")}),300),e.add("image",m(b,{title:o("image"),icon:"fas fa-image",onclick:r("image")}),200),e.add("unordered_list",m(b,{title:o("unordered_list"),icon:"fas fa-list-ul",onclick:r("unordered_list")}),100),e.add("ordered_list",m(b,{title:o("ordered_list"),icon:"fas fa-list-ol",onclick:r("ordered_list")}),0),e}r().initializers.add("flarum-markdown",(function(t){(0,a.extend)(c().prototype,"keyHandlers",(function(t){t.add("bold",S("bold","b",this)),t.add("italic",S("italic","i",this))})),(0,a.override)("flarum/common/components/TextEditor","markdownToolbarItems",M),(0,a.extend)("flarum/common/components/TextEditor","toolbarItems",(function(t){t.add("markdown",m(p,{for:this.textareaId,setShortcutHandler:t=>shortcutHandler=t},this.markdownToolbarItems().toArray()),100)}))}))})(),module.exports=e})();
//# sourceMappingURL=admin.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,3 @@
/*! For license information please see forum.js.LICENSE.txt */
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.reg.get("core","forum/app");var r=t.n(o);const i=flarum.reg.get("core","common/app");var n=t.n(i);const a=flarum.reg.get("core","common/extend"),l=flarum.reg.get("core","common/utils/BasicEditorDriver");var c=t.n(l);const s=flarum.reg.get("core","common/utils/styleSelectedText");var d=t.n(s);const f=flarum.reg.get("core","common/Component");var u=t.n(f);class p extends(u()){view(t){return m("div",{className:"MarkdownToolbar"},t.children)}}flarum.reg.add("flarum-markdown","common/components/MarkdownToolbar",p);const k=flarum.reg.get("core","common/components/Icon");var h=t.n(k);const g=flarum.reg.get("core","common/components/Tooltip");var x=t.n(g);class b extends(u()){oncreate(t){super.oncreate(t)}view(){const t=m("button",{className:"Button Button--icon Button--link",type:"button","data-hotkey":this.attrs.hotkey,onkeydown:this.keydown.bind(this),onclick:this.attrs.onclick},m(h(),{name:this.attrs.icon}));return this.attrs.title?m(x(),{text:this.attrs.title},t):t}keydown(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.element.click())}}flarum.reg.add("flarum-markdown","common/components/MarkdownButton",b);const y=flarum.reg.get("core","common/utils/ItemList");var v=t.n(y);const w=navigator.userAgent.match(/Macintosh/)?"⌘":"ctrl",_={header:{prefix:"### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},image:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},unordered_list:{prefix:"- ",multiline:!0,surroundWithNewlines:!0},ordered_list:{prefix:"1. ",multiline:!0,orderedList:!0},spoiler:{prefix:">!",suffix:"!<",blockPrefix:">! ",multiline:!0,trimFirst:!0}},T=(t,e)=>{d()(e.el,_[t])};function S(t,e,o){return function(r){r.key===e&&(r.metaKey&&"⌘"===w||r.ctrlKey&&"ctrl"===w)&&(r.preventDefault(),T(t,o))}}function M(t){const e="function"==typeof t?t():new(v());function o(t,e){return n().translator.trans("flarum-markdown.lib.composer.".concat(t,"_tooltip"))+(e?" <".concat(w,"-").concat(e,">"):"")}const r=t=>()=>T(t,this.attrs.composer.editor);return e.add("header",m(b,{title:o("header"),icon:"fas fa-heading",onclick:r("header")}),1e3),e.add("bold",m(b,{title:o("bold","b"),icon:"fas fa-bold",onclick:r("bold")}),900),e.add("italic",m(b,{title:o("italic","i"),icon:"fas fa-italic",onclick:r("italic")}),800),e.add("strikethrough",m(b,{title:o("strikethrough"),icon:"fas fa-strikethrough",onclick:r("strikethrough")}),700),e.add("quote",m(b,{title:o("quote"),icon:"fas fa-quote-left",onclick:r("quote")}),600),e.add("spoiler",m(b,{title:o("spoiler"),icon:"fas fa-exclamation-triangle",onclick:r("spoiler")}),500),e.add("code",m(b,{title:o("code"),icon:"fas fa-code",onclick:r("code")}),400),e.add("link",m(b,{title:o("link"),icon:"fas fa-link",onclick:r("link")}),300),e.add("image",m(b,{title:o("image"),icon:"fas fa-image",onclick:r("image")}),200),e.add("unordered_list",m(b,{title:o("unordered_list"),icon:"fas fa-list-ul",onclick:r("unordered_list")}),100),e.add("ordered_list",m(b,{title:o("ordered_list"),icon:"fas fa-list-ol",onclick:r("ordered_list")}),0),e}r().initializers.add("flarum-markdown",(function(t){(0,a.extend)(c().prototype,"keyHandlers",(function(t){t.add("bold",S("bold","b",this)),t.add("italic",S("italic","i",this))})),(0,a.override)("flarum/common/components/TextEditor","markdownToolbarItems",M),(0,a.extend)("flarum/common/components/TextEditor","toolbarItems",(function(t){t.add("markdown",m(p,{for:this.textareaId,setShortcutHandler:t=>shortcutHandler=t},this.markdownToolbarItems().toArray()),100)}))}))})(),module.exports=e})();
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.reg.get("core","forum/app");var r=t.n(o);const i=flarum.reg.get("core","common/app");var n=t.n(i);const a=flarum.reg.get("core","common/extend"),l=flarum.reg.get("core","common/utils/BasicEditorDriver");var c=t.n(l);const s=flarum.reg.get("core","common/utils/styleSelectedText");var d=t.n(s);const f=flarum.reg.get("core","common/Component");var u=t.n(f);class p extends(u()){view(t){return m("div",{className:"MarkdownToolbar"},t.children)}}flarum.reg.add("flarum-markdown","common/components/MarkdownToolbar",p);const k=flarum.reg.get("core","common/helpers/icon");var h=t.n(k);const g=flarum.reg.get("core","common/components/Tooltip");var x=t.n(g);class b extends(u()){oncreate(t){super.oncreate(t)}view(){const t=m("button",{className:"Button Button--icon Button--link",type:"button","data-hotkey":this.attrs.hotkey,onkeydown:this.keydown.bind(this),onclick:this.attrs.onclick},h()(this.attrs.icon));return this.attrs.title?m(x(),{text:this.attrs.title},t):t}keydown(t){" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.element.click())}}flarum.reg.add("flarum-markdown","common/components/MarkdownButton",b);const y=flarum.reg.get("core","common/utils/ItemList");var v=t.n(y);const w=navigator.userAgent.match(/Macintosh/)?"⌘":"ctrl",_={header:{prefix:"### "},bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},strikethrough:{prefix:"~~",suffix:"~~",trimFirst:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},image:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"},unordered_list:{prefix:"- ",multiline:!0,surroundWithNewlines:!0},ordered_list:{prefix:"1. ",multiline:!0,orderedList:!0},spoiler:{prefix:">!",suffix:"!<",blockPrefix:">! ",multiline:!0,trimFirst:!0}},T=(t,e)=>{d()(e.el,_[t])};function S(t,e,o){return function(r){r.key===e&&(r.metaKey&&"⌘"===w||r.ctrlKey&&"ctrl"===w)&&(r.preventDefault(),T(t,o))}}function M(t){const e="function"==typeof t?t():new(v());function o(t,e){return n().translator.trans("flarum-markdown.lib.composer.".concat(t,"_tooltip"))+(e?" <".concat(w,"-").concat(e,">"):"")}const r=t=>()=>T(t,this.attrs.composer.editor);return e.add("header",m(b,{title:o("header"),icon:"fas fa-heading",onclick:r("header")}),1e3),e.add("bold",m(b,{title:o("bold","b"),icon:"fas fa-bold",onclick:r("bold")}),900),e.add("italic",m(b,{title:o("italic","i"),icon:"fas fa-italic",onclick:r("italic")}),800),e.add("strikethrough",m(b,{title:o("strikethrough"),icon:"fas fa-strikethrough",onclick:r("strikethrough")}),700),e.add("quote",m(b,{title:o("quote"),icon:"fas fa-quote-left",onclick:r("quote")}),600),e.add("spoiler",m(b,{title:o("spoiler"),icon:"fas fa-exclamation-triangle",onclick:r("spoiler")}),500),e.add("code",m(b,{title:o("code"),icon:"fas fa-code",onclick:r("code")}),400),e.add("link",m(b,{title:o("link"),icon:"fas fa-link",onclick:r("link")}),300),e.add("image",m(b,{title:o("image"),icon:"fas fa-image",onclick:r("image")}),200),e.add("unordered_list",m(b,{title:o("unordered_list"),icon:"fas fa-list-ul",onclick:r("unordered_list")}),100),e.add("ordered_list",m(b,{title:o("ordered_list"),icon:"fas fa-list-ol",onclick:r("ordered_list")}),0),e}r().initializers.add("flarum-markdown",(function(t){(0,a.extend)(c().prototype,"keyHandlers",(function(t){t.add("bold",S("bold","b",this)),t.add("italic",S("italic","i",this))})),(0,a.override)("flarum/common/components/TextEditor","markdownToolbarItems",M),(0,a.extend)("flarum/common/components/TextEditor","toolbarItems",(function(t){t.add("markdown",m(p,{for:this.textareaId,setShortcutHandler:t=>shortcutHandler=t},this.markdownToolbarItems().toArray()),100)}))}))})(),module.exports=e})();
//# sourceMappingURL=forum.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
import Component from 'flarum/common/Component';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import Tooltip from 'flarum/common/components/Tooltip';
export default class MarkdownButton extends Component {
@@ -16,7 +16,7 @@ export default class MarkdownButton extends Component {
onkeydown={this.keydown.bind(this)}
onclick={this.attrs.onclick}
>
<Icon name={this.attrs.icon} />
{icon(this.attrs.icon)}
</button>
);

View File

@@ -27,6 +27,7 @@ use Flarum\Post\Event\Revised;
use Flarum\Post\Filter\PostFilterer;
use Flarum\Post\Post;
use Flarum\Tags\Api\Serializer\TagSerializer;
use Flarum\Tags\Tag;
use Flarum\User\User;
return [
@@ -125,7 +126,7 @@ return [
// Tag mentions
(new Extend\Conditional())
->whenExtensionEnabled('flarum-tags', fn () => [
->whenExtensionEnabled('flarum-tags', [
(new Extend\Formatter)
->render(Formatter\FormatTagMentions::class)
->unparse(Formatter\UnparseTagMentions::class),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@ import Link from 'flarum/common/components/Link';
import PostPreview from 'flarum/forum/components/PostPreview';
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
import username from 'flarum/common/helpers/username';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import Button from 'flarum/common/components/Button';
import MentionedByModal from './components/MentionedByModal';
@@ -54,9 +54,7 @@ export default function addMentionedByList() {
}}
>
<span className="PostPreview-content">
<span className="PostPreview-badge Avatar">
<Icon name={'fas fa-reply-all'} />
</span>
<span className="PostPreview-badge Avatar">{icon('fas fa-reply-all')}</span>
<span>
{app.translator.trans('flarum-mentions.forum.post.mentioned_by_more_text', { count: post.mentionedByCount() - replies.length })}
</span>
@@ -147,7 +145,7 @@ export default function addMentionedByList() {
'replies',
<div className="Post-mentionedBy">
<span className="Post-mentionedBy-summary">
<Icon name={'fas fa-reply'} />
{icon('fas fa-reply')}
{app.translator.trans(`flarum-mentions.forum.post.mentioned_by${repliers[0].user() === app.session.user ? '_self' : ''}_text`, {
count: names.length,
users: punctuateSeries(names),

View File

@@ -5,7 +5,7 @@ import CommentPost from 'flarum/forum/components/CommentPost';
import reply from './utils/reply';
export default function addPostReplyAction() {
export default function () {
extend(CommentPost.prototype, 'actionItems', function (items) {
const post = this.attrs.post;

View File

@@ -6,7 +6,6 @@ import type Post from 'flarum/common/models/Post';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import Button from 'flarum/common/components/Button';
import MentionedByModalState from '../state/MentionedByModalState';
import Form from 'flarum/common/components/Form';
export interface IMentionedByModalAttrs extends IInternalModalAttrs {
post: Post;
@@ -59,13 +58,13 @@ export default class MentionedByModal<CustomAttrs extends IMentionedByModalAttrs
</div>
{this.state.hasNext() && (
<div className="Modal-footer">
<Form className="Form--centered">
<div className="Form Form--centered">
<div className="Form-group">
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
{app.translator.trans('flarum-mentions.forum.mentioned_by.load_more_button')}
</Button>
</div>
</Form>
</div>
</div>
)}
</>

View File

@@ -1,6 +1,6 @@
import app from 'flarum/forum/app';
import Fragment from 'flarum/common/Fragment';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import reply from '../utils/reply';
@@ -19,7 +19,7 @@ export default class PostQuoteButton extends Fragment {
reply(this.post, this.content);
}}
>
<Icon name="fas fa-quote-left" className="Button-icon" />
{icon('fas fa-quote-left', { className: 'Button-icon' })}
{app.translator.trans('flarum-mentions.forum.post.quote_button')}
</button>
);

View File

@@ -3,7 +3,7 @@ import MentionableModel from './MentionableModel';
import type Post from 'flarum/common/models/Post';
import type Mithril from 'mithril';
import usernameHelper from 'flarum/common/helpers/username';
import Avatar from 'flarum/common/components/Avatar';
import avatar from 'flarum/common/helpers/avatar';
import highlight from 'flarum/common/helpers/highlight';
import { truncate } from 'flarum/common/utils/string';
import getCleanDisplayName from '../utils/getCleanDisplayName';
@@ -63,7 +63,7 @@ export default class PostMention extends MentionableModel<Post, AtMentionFormat>
return (
<>
<Avatar user={user} />
{avatar(user)}
{username}
{[
app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: model.number() }),

View File

@@ -2,7 +2,7 @@ import app from 'flarum/forum/app';
import type Mithril from 'mithril';
import type User from 'flarum/common/models/User';
import usernameHelper from 'flarum/common/helpers/username';
import Avatar from 'flarum/common/components/Avatar';
import avatar from 'flarum/common/helpers/avatar';
import highlight from 'flarum/common/helpers/highlight';
import MentionableModel from './MentionableModel';
import getCleanDisplayName, { shouldUseOldFormat } from '../utils/getCleanDisplayName';
@@ -46,7 +46,7 @@ export default class UserMention extends MentionableModel<User, AtMentionFormat>
return (
<>
<Avatar user={model} />
{avatar(model)}
{username}
</>
);

View File

@@ -1,7 +1,7 @@
.PostMention, .UserMention, .GroupMention {
background: var(--control-bg);
color: var(--control-color);
border-radius: var(--border-radius);
border-radius: @border-radius;
font-weight: 600;
blockquote & {
@@ -30,7 +30,10 @@
margin-left: 0;
}
.icon {
// @TODO: 2.0 use an icon in the XSLT template.
&:before {
.fas();
content: @fa-var-reply;
margin-right: 5px;
}
}
@@ -78,7 +81,7 @@
.MentionsDropdown, .PostMention-preview, .Post-mentionedBy-preview {
// @TODO: Rename to .MentionsDropdownItem, along with child classes. 2.0
.PostPreview {
color: var(--muted-color);
color: @muted-color;
.Avatar {
.Avatar--size(24px);
@@ -90,7 +93,7 @@
}
}
.username {
color: var(--text-color);
color: @text-color;
font-weight: bold;
}
}

View File

@@ -70,43 +70,40 @@ flarum-mentions:
# These translations are used in emails sent when a post is replied to
post_mentioned:
subject: "{replier_display_name} replied to your post in {title}"
plain:
body: |
{replier_display_name} replied to your post (#{post_number}) in {title}.
body: |
Hey {recipient_display_name}!
{url}
{replier_display_name} replied to your post (#{post_number}) in {title}.
---
{url}
{content}
html:
body: "{replier_display_name} replied to your post (#{post_number}) in [{title}]({url})."
---
{content}
# These translations are used in emails sent when a user is mentioned
user_mentioned:
subject: "{mentioner_display_name} mentioned you in {title}"
plain:
body: |
{mentioner_display_name} mentioned you in a post in {title}.
body: |
Hey {recipient_display_name}!
{url}
{mentioner_display_name} mentioned you in a post in {title}.
---
{url}
{content}
html:
body: "{mentioner_display_name} mentioned you in a post in [{title}]({url})."
---
{content}
# These translations are used in emails sent when a group is mentioned
group_mentioned:
subject: "{mentioner_display_name} mentioned a group you're a member of in {title}"
plain:
body: |
{mentioner_display_name} mentioned a group you're a member of in {title}.
body: |
Hey {recipient_display_name}!
{url}
{mentioner_display_name} mentioned a group you're a member of in {title}.
---
{url}
{content}
html:
body: "{mentioner_display_name} mentioned a group you're a member of in [{title}]({url})."
---
{content}

View File

@@ -15,7 +15,7 @@ use Flarum\Http\RequestUtil;
use Flarum\Post\Post;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
/**
* Apply visibility permissions to API data's mentionedBy relationship.
@@ -25,7 +25,7 @@ class LoadMentionedByRelationship
{
public static int $maxMentionedBy = 4;
public static function mutateRelation(BelongsToMany $query, ServerRequestInterface $request): void
public static function mutateRelation(BelongsToMany $query, Request $request): void
{
$actor = RequestUtil::getActor($request);
@@ -42,7 +42,7 @@ class LoadMentionedByRelationship
/**
* Called using the @see ApiController::prepareDataForSerialization extender.
*/
public static function countRelation(AbstractSerializeController $controller, mixed $data, ServerRequestInterface $request): array
public static function countRelation(AbstractSerializeController $controller, mixed $data, Request $request): array
{
$actor = RequestUtil::getActor($request);
$loadable = null;

View File

@@ -50,7 +50,7 @@ class ConfigureMentions
private function configureUserMentions(Configurator $config): void
{
$config->rendering->parameters['PROFILE_URL'] = $this->url->to('forum')->route('user', ['username' => '']);
$config->rendering->parameters['PROFILE_URL'] = $this->url->route('forum.user', ['username' => '']);
$tagName = 'USERMENTION';
@@ -108,7 +108,7 @@ class ConfigureMentions
private function configurePostMentions(Configurator $config): void
{
$config->rendering->parameters['DISCUSSION_URL'] = $this->url->to('forum')->route('discussion', ['id' => '']);
$config->rendering->parameters['DISCUSSION_URL'] = $this->url->route('forum.discussion', ['id' => '']);
$tagName = 'POSTMENTION';
@@ -122,10 +122,10 @@ class ConfigureMentions
$tag->template = '
<xsl:choose>
<xsl:when test="@deleted != 1">
<a href="{$DISCUSSION_URL}{@discussionid}/{@number}" class="PostMention" data-id="{@id}"><i class="icon fas fa-reply"></i><xsl:value-of select="@displayname"/></a>
<a href="{$DISCUSSION_URL}{@discussionid}/{@number}" class="PostMention" data-id="{@id}"><xsl:value-of select="@displayname"/></a>
</xsl:when>
<xsl:otherwise>
<span class="PostMention PostMention--deleted" data-id="{@id}"><i class="icon fas fa-reply"></i><xsl:value-of select="@displayname"/></span>
<span class="PostMention PostMention--deleted" data-id="{@id}"><xsl:value-of select="@displayname"/></span>
</xsl:otherwise>
</xsl:choose>';
@@ -246,7 +246,7 @@ class ConfigureMentions
private function configureTagMentions(Configurator $config): void
{
$config->rendering->parameters['TAG_URL'] = $this->url->to('forum')->route('tag', ['slug' => '']);
$config->rendering->parameters['TAG_URL'] = $this->url->route('forum.tag', ['slug' => '']);
$tagName = 'TAGMENTION';

View File

@@ -12,7 +12,7 @@ namespace Flarum\Mentions\Formatter;
use Flarum\Discussion\Discussion;
use Flarum\Http\SlugManager;
use Flarum\Locale\TranslatorInterface;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Http\Request;
use s9e\TextFormatter\Renderer;
use s9e\TextFormatter\Utils;

View File

@@ -11,7 +11,7 @@ namespace Flarum\Mentions\Formatter;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Psr\Http\Message\ServerRequestInterface as Request;
use Illuminate\Http\Request;
use s9e\TextFormatter\Renderer;
use s9e\TextFormatter\Utils;

View File

@@ -47,7 +47,7 @@ class UnparsePostMentions
$attributes['displayname'] = $this->translator->trans('core.lib.username.deleted_text');
}
if (str_contains($attributes['displayname'], '"#')) {
if (strpos($attributes['displayname'], '"#') !== false) {
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
}
@@ -62,7 +62,7 @@ class UnparsePostMentions
{
$tagName = 'POSTMENTION';
if (! str_contains($xml, $tagName)) {
if (strpos($xml, $tagName) === false) {
return $xml;
}

View File

@@ -49,7 +49,7 @@ class UnparseTagMentions
{
$tagName = 'TAGMENTION';
if (! str_contains($xml, $tagName)) {
if (strpos($xml, $tagName) === false) {
return $xml;
}

View File

@@ -40,7 +40,7 @@ class UnparseUserMentions
$attributes['displayname'] = $user?->display_name ?? $this->translator->trans('core.lib.username.deleted_text');
if (str_contains($attributes['displayname'], '"#')) {
if (strpos($attributes['displayname'], '"#') !== false) {
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
}
@@ -55,7 +55,7 @@ class UnparseUserMentions
{
$tagName = 'USERMENTION';
if (! str_contains($xml, $tagName)) {
if (strpos($xml, $tagName) === false) {
return $xml;
}

View File

@@ -38,11 +38,9 @@ class GroupMentionedBlueprint implements BlueprintInterface, MailableInterface
return null;
}
public function getEmailViews(): array
public function getEmailView(): string|array
{
return [
'text' => 'flarum-mentions::emails.plain.groupMentioned',
'html' => 'flarum-mentions::emails.html.groupMentioned', ];
return ['text' => 'flarum-mentions::emails.groupMentioned'];
}
public function getEmailSubject(TranslatorInterface $translator): string

View File

@@ -39,12 +39,9 @@ class PostMentionedBlueprint implements BlueprintInterface, MailableInterface
return ['replyNumber' => (int) $this->reply->number];
}
public function getEmailViews(): array
public function getEmailView(): string|array
{
return [
'text' => 'flarum-mentions::emails.plain.postMentioned',
'html' => 'flarum-mentions::emails.html.postMentioned',
];
return ['text' => 'flarum-mentions::emails.postMentioned'];
}
public function getEmailSubject(TranslatorInterface $translator): string

View File

@@ -38,12 +38,9 @@ class UserMentionedBlueprint implements BlueprintInterface, MailableInterface
return null;
}
public function getEmailViews(): array
public function getEmailView(): string|array
{
return [
'text' => 'flarum-mentions::emails.plain.userMentioned',
'html' => 'flarum-mentions::emails.html.userMentioned'
];
return ['text' => 'flarum-mentions::emails.userMentioned'];
}
public function getEmailSubject(TranslatorInterface $translator): string

View File

@@ -70,7 +70,7 @@ class GroupMentionsTest extends TestCase
$this->request('GET', '/api/posts/4')
);
$contents = $response->getBody()->getContents();
$contents = $response->getContent();
$this->assertEquals(200, $response->getStatusCode(), $contents);
@@ -104,7 +104,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@"InvalidGroup"#g99', $response['data']['attributes']['content']);
$this->assertStringNotContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
@@ -126,7 +126,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString("@$deleted_text", $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
@@ -148,7 +148,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@Fresh Name', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
@@ -179,7 +179,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('fas fa-bolt', $response['data']['attributes']['contentHtml']);
@@ -211,7 +211,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@Admins', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
@@ -245,7 +245,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('@Members', $response['data']['attributes']['contentHtml']);
$this->assertStringNotContainsString('@Guests', $response['data']['attributes']['contentHtml']);
@@ -301,7 +301,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('@Mods', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
@@ -332,7 +332,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
@@ -363,7 +363,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('@Ninjas', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"Ninjas"#g10', $response['data']['attributes']['content']);
@@ -391,7 +391,7 @@ class GroupMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
$this->assertEquals('New content with @"Mods"#g4 mention', $response['data']['attributes']['content']);

View File

@@ -13,6 +13,7 @@ use Carbon\Carbon;
use Flarum\Mentions\Api\LoadMentionedByRelationship;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
class ListPostsTest extends TestCase
@@ -55,13 +56,15 @@ class ListPostsTest extends TestCase
public function mentioned_filter_works()
{
$response = $this->send(
$this->request('GET', '/api/posts')
->withQueryParams([
tap(
$this->request('GET', '/api/posts'),
fn (Request $request) => $request->query->add([
'filter' => ['mentioned' => 1],
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
@@ -74,13 +77,15 @@ class ListPostsTest extends TestCase
public function mentioned_filter_works_negated()
{
$response = $this->send(
$this->request('GET', '/api/posts')
->withQueryParams([
'filter' => ['-mentioned' => 1],
])
tap(
$this->request('GET', '/api/posts'),
fn (Request $request) => $request->query->add([
'filter' => ['-mentioned' => 1],
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
@@ -93,14 +98,16 @@ class ListPostsTest extends TestCase
public function mentioned_filter_works_with_sort()
{
$response = $this->send(
$this->request('GET', '/api/posts')
->withQueryParams([
tap(
$this->request('GET', '/api/posts'),
fn (Request $request) => $request->query->add([
'filter' => ['mentioned' => 1],
'sort' => '-createdAt'
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
@@ -153,14 +160,17 @@ class ListPostsTest extends TestCase
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts/101', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => 'mentionedBy',
])
tap(
$this->request('GET', '/api/posts/101', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'include' => 'mentionedBy',
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
@@ -179,15 +189,18 @@ class ListPostsTest extends TestCase
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
])->withQueryParams([
'filter' => ['discussion' => 100],
'include' => 'mentionedBy',
])
tap(
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'filter' => ['discussion' => 100],
'include' => 'mentionedBy',
])
)
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
@@ -209,14 +222,17 @@ class ListPostsTest extends TestCase
// Show discussion endpoint
$response = $this->send(
$this->request('GET', '/api/discussions/100', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => $include,
])
tap(
$this->request('GET', '/api/discussions/100', [
'authenticatedAs' => 2,
]),
fn (Request $request) => $request->query->add([
'include' => $include,
])
)
);
$included = json_decode($response->getBody()->getContents(), true)['included'];
$included = json_decode($response->getContent(), true)['included'];
$mentionedBy = collect($included)
->where('type', 'posts')
@@ -250,7 +266,7 @@ class ListPostsTest extends TestCase
])
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$data = json_decode($response->getContent(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());

View File

@@ -93,7 +93,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@potato#4', $response['data']['attributes']['content']);
@@ -124,7 +124,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
@@ -155,7 +155,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('potato', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"potato"#p50', $response['data']['attributes']['content']);
@@ -186,7 +186,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
@@ -217,7 +217,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"franzofflarum"#p215', $response['data']['attributes']['content']);
@@ -248,7 +248,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('TOBY$', $response['data']['attributes']['contentHtml']);
$this->assertStringNotContainsString('FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
@@ -271,7 +271,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('TOBY$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('PostMention', $response['data']['attributes']['contentHtml']);
@@ -291,7 +291,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@"TOBY$"#p5', $response['data']['attributes']['content']);
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
@@ -312,7 +312,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString($deleted_text, $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"'.$deleted_text.'"#p7', $response['data']['attributes']['content']);
@@ -337,7 +337,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString($deleted_text, $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"'.$deleted_text.'"#p2010', $response['data']['attributes']['content']);
@@ -362,7 +362,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString($deleted_text, $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"'.$deleted_text.'"#p2020', $response['data']['attributes']['content']);
@@ -395,7 +395,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"POTATO$"#p6 User"#p9', $response['data']['attributes']['content']);
@@ -416,7 +416,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"Bad _ User"#p9', $response['data']['attributes']['content']);
@@ -447,7 +447,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
@@ -475,7 +475,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
@@ -503,7 +503,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
@@ -531,7 +531,7 @@ class PostMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('[deleted]', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"[deleted]"#p11', $response['data']['attributes']['content']);

View File

@@ -81,7 +81,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
$this->assertStringNotContainsString('TagMention--deleted', $response['data']['attributes']['contentHtml']);
@@ -109,7 +109,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Tatakai', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -138,7 +138,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertEquals('#franzofflarum', $response['data']['attributes']['content']);
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -168,7 +168,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertEquals('#test', $response['data']['attributes']['content']);
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -196,7 +196,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertEquals('#dev', $response['data']['attributes']['content']);
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -224,7 +224,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertEquals('#dev', $response['data']['attributes']['content']);
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -252,7 +252,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Test', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('Flarum', $response['data']['attributes']['contentHtml']);
@@ -273,7 +273,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Test', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
@@ -305,7 +305,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('#test', $response['data']['attributes']['content']);
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
@@ -325,7 +325,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString($deleted_text, $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
@@ -348,7 +348,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Support', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
@@ -375,7 +375,7 @@ class TagMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Laravel "#t6 Tag', $response['data']['attributes']['contentHtml']);
$this->assertEquals('#laravel', $response['data']['attributes']['content']);

View File

@@ -85,7 +85,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@potato', $response['data']['attributes']['content']);
@@ -118,7 +118,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"POTATO$"#3', $response['data']['attributes']['content']);
@@ -149,7 +149,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
@@ -180,7 +180,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
@@ -211,7 +211,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('@FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"franzofflarum"#82', $response['data']['attributes']['content']);
@@ -242,7 +242,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@TOBY$', $response['data']['attributes']['contentHtml']);
$this->assertStringNotContainsString('@FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
@@ -265,7 +265,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@TOBY$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
@@ -295,7 +295,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
@@ -325,7 +325,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
@@ -346,7 +346,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString("@$deleted_text", $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"'.$deleted_text.'"#2021', $response['data']['attributes']['content']);
@@ -380,7 +380,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringNotContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertNotEquals('@"Bad "#p6 User"#5', $response['data']['attributes']['content']);
@@ -401,7 +401,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertStringContainsString('@"Bad _ User"#5', $response['data']['attributes']['content']);
@@ -432,7 +432,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(201, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
@@ -460,7 +460,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
@@ -488,7 +488,7 @@ class UserMentionsTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
$response = json_decode($response->getBody(), true);
$response = json_decode($response->getContent(), true);
$this->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);

View File

@@ -0,0 +1,7 @@
{!! $translator->trans('flarum-mentions.email.group_mentioned.body', [
'{recipient_display_name}' => $user->display_name,
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->route('forum.discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}

View File

@@ -1,13 +0,0 @@
@extends('flarum.forum::email.html.notification.base')
@section('notificationContent')
{!! $formatter->convert($translator->trans('flarum-mentions.email.group_mentioned.html.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
])) !!}
@endsection
@section('contentPreview')
{!! $blueprint->post->formatContent() !!}
@endsection

View File

@@ -1,14 +0,0 @@
@extends('flarum.forum::email.html.notification.base')
@section('notificationContent')
{!! $formatter->convert($translator->trans('flarum-mentions.email.post_mentioned.html.body', [
'{replier_display_name}' => $blueprint->reply->user->display_name,
'{post_number}' => $blueprint->post->number,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number])
])) !!}
@endsection
@section('contentPreview')
{!! $blueprint->reply->formatContent() !!}
@endsection

View File

@@ -1,13 +0,0 @@
@extends('flarum.forum::email.html.notification.base')
@section('notificationContent')
{!! $formatter->convert($translator->trans('flarum-mentions.email.user_mentioned.html.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number])
])) !!}
@endsection
@section('contentPreview')
{!! $blueprint->post->formatContent() !!}
@endsection

View File

@@ -1,10 +0,0 @@
@extends('flarum.forum::email.plain.notification.base')
@section('content')
{!! $translator->trans('flarum-mentions.email.group_mentioned.plain.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}
@endsection

View File

@@ -1,11 +0,0 @@
@extends('flarum.forum::email.plain.notification.base')
@section('content')
{!! $translator->trans('flarum-mentions.email.post_mentioned.plain.body', [
'{replier_display_name}' => $blueprint->reply->user->display_name,
'{post_number}' => $blueprint->post->number,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number]),
'{content}' => $blueprint->reply->content
]) !!}
@endsection

View File

@@ -1,10 +0,0 @@
@extends('flarum.forum::email.plain.notification.base')
@section('content')
{!! $translator->trans('flarum-mentions.email.user_mentioned.plain.body', [
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->to('forum')->route('discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}
@endsection

View File

@@ -0,0 +1,8 @@
{!! $translator->trans('flarum-mentions.email.post_mentioned.body', [
'{recipient_display_name}' => $user->display_name,
'{replier_display_name}' => $blueprint->reply->user->display_name,
'{post_number}' => $blueprint->post->number,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->route('forum.discussion', ['id' => $blueprint->reply->discussion_id, 'near' => $blueprint->reply->number]),
'{content}' => $blueprint->reply->content
]) !!}

View File

@@ -0,0 +1,7 @@
{!! $translator->trans('flarum-mentions.email.user_mentioned.body', [
'{recipient_display_name}' => $user->display_name,
'{mentioner_display_name}' => $blueprint->post->user->display_name,
'{title}' => $blueprint->post->discussion->title,
'{url}' => $url->route('forum.discussion', ['id' => $blueprint->post->discussion_id, 'near' => $blueprint->post->number]),
'{content}' => $blueprint->post->content
]) !!}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,6 @@ import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
import Form from '@flarum/core/src/common/components/Form';
export default class NicknameModal extends Modal {
oninit(vnode) {
@@ -21,16 +20,16 @@ export default class NicknameModal extends Modal {
content() {
return (
<div className="Modal-body">
<Form className="Form--centered">
<div className="Form Form--centered">
<div className="Form-group">
<input type="text" autocomplete="off" name="nickname" className="FormControl" bidi={this.nickname} disabled={this.loading} />
</div>
<div className="Form-group Form-controls">
<div className="Form-group">
<Button className="Button Button--primary Button--block" type="submit" loading={this.loading}>
{app.translator.trans('flarum-nicknames.forum.change_nickname.submit_button')}
</Button>
</div>
</Form>
</div>
</div>
);
}

View File

@@ -22,7 +22,7 @@ class RegisterTest extends TestCase
{
$this->extension('flarum-nicknames');
$this->extend(
(new Extend\Csrf)->exemptRoute('register')
(new Extend\Csrf)->exemptRoute('forum.register')
);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@ import type Mithril from 'mithril';
import app from 'flarum/admin/app';
import Component, { ComponentAttrs } from 'flarum/common/Component';
import classList from 'flarum/common/utils/classList';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import Tooltip from 'flarum/common/components/Tooltip';
import Button from 'flarum/common/components/Button';
import { Extension } from 'flarum/admin/AdminApplication';
@@ -35,7 +35,7 @@ export default class ExtensionItem<Attrs extends ExtensionItemAttrs = ExtensionI
})}
>
<div className="PackageManager-extension-icon ExtensionIcon" style={extension.icon}>
{extension.icon ? <Icon name={extension.icon.name} /> : ''}
{extension.icon ? icon(extension.icon.name) : ''}
</div>
<div className="PackageManager-extension-info">
<div className="PackageManager-extension-name">{extension.extra['flarum-extension'].title}</div>

View File

@@ -5,7 +5,7 @@ import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import Button from 'flarum/common/components/Button';
import Tooltip from 'flarum/common/components/Tooltip';
import { Extension } from 'flarum/admin/AdminApplication';
import Icon from 'flarum/common/components/Icon';
import icon from 'flarum/common/helpers/icon';
import ItemList from 'flarum/common/utils/ItemList';
import extractText from 'flarum/common/utils/extractText';
@@ -75,7 +75,7 @@ export default class QueueSection extends Component<{}> {
return extension ? (
<div className="PackageManager-queueTable-package">
<div className="PackageManager-queueTable-package-icon ExtensionIcon" style={extension.icon}>
{!!extension.icon && <Icon name={extension.icon.name} />}
{!!extension.icon && icon(extension.icon.name)}
</div>
<div className="PackageManager-queueTable-package-details">
<span className="PackageManager-queueTable-package-title">{extension.extra['flarum-extension'].title}</span>
@@ -199,17 +199,17 @@ export default class QueueSection extends Component<{}> {
}
operationIcon(operation: TaskOperations): Mithril.Children {
const iconName = {
update_check: 'fas fa-sync-alt',
update_major: 'fas fa-play',
update_minor: 'fas fa-play',
update_global: 'fas fa-play',
extension_install: 'fas fa-download',
extension_remove: 'fas fa-times',
extension_update: 'fas fa-arrow-alt-circle-up',
why_not: 'fas fa-exclamation-circle',
}[operation];
return <Icon name={iconName} />;
return icon(
{
update_check: 'fas fa-sync-alt',
update_major: 'fas fa-play',
update_minor: 'fas fa-play',
update_global: 'fas fa-play',
extension_install: 'fas fa-download',
extension_remove: 'fas fa-times',
extension_update: 'fas fa-arrow-alt-circle-up',
why_not: 'fas fa-exclamation-circle',
}[operation]
);
}
}

View File

@@ -9,22 +9,22 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\CheckForUpdates;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class CheckForUpdatesController implements RequestHandlerInterface
class CheckForUpdatesController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);

View File

@@ -9,23 +9,23 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\GlobalUpdate;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class GlobalUpdateController implements RequestHandlerInterface
class GlobalUpdateController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);

View File

@@ -14,7 +14,7 @@ use Flarum\Http\RequestUtil;
use Flarum\Http\UrlGenerator;
use Flarum\PackageManager\Api\Serializer\TaskSerializer;
use Flarum\PackageManager\Task\TaskRepository;
use Psr\Http\Message\ServerRequestInterface;
use Illuminate\Http\Request;
use Tobscure\JsonApi\Document;
class ListTasksController extends AbstractListController
@@ -27,7 +27,7 @@ class ListTasksController extends AbstractListController
) {
}
protected function data(ServerRequestInterface $request, Document $document): iterable
protected function data(Request $request, Document $document): iterable
{
$actor = RequestUtil::getActor($request);
@@ -48,8 +48,8 @@ class ListTasksController extends AbstractListController
$document->addMeta('total', (string) $total);
$document->addPaginationLinks(
$this->url->to('api')->route('package-manager.tasks.index'),
$request->getQueryParams(),
$this->url->route('api.package-manager.tasks.index'),
$request->query(),
$offset,
$limit,
$total

View File

@@ -9,27 +9,26 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\MajorUpdate;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class MajorUpdateController implements RequestHandlerInterface
class MajorUpdateController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);
$dryRun = (bool) (int) Arr::get($request->getParsedBody(), 'data.dryRun', 0);
$dryRun = (bool) (int) $request->json('data.dryRun', 0);
$response = $this->bus->dispatch(
new MajorUpdate($actor, $dryRun)

View File

@@ -9,23 +9,23 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\MinorUpdate;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class MinorUpdateController implements RequestHandlerInterface
class MinorUpdateController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);

View File

@@ -9,30 +9,28 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\RemoveExtension;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class RemoveExtensionController implements RequestHandlerInterface
class RemoveExtensionController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request, int $id): ResponseInterface
{
$actor = RequestUtil::getActor($request);
$extensionId = Arr::get($request->getQueryParams(), 'id');
$response = $this->bus->dispatch(
new RemoveExtension($actor, $extensionId)
new RemoveExtension($actor, $id)
);
return $response->queueJobs

View File

@@ -9,26 +9,25 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\RequireExtension;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class RequireExtensionController implements RequestHandlerInterface
class RequireExtensionController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);
$package = Arr::get($request->getParsedBody(), 'data.package');
$package = $request->json('data.package');
$response = $this->bus->dispatch(
new RequireExtension($actor, $package)

View File

@@ -9,30 +9,28 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\UpdateExtension;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class UpdateExtensionController implements RequestHandlerInterface
class UpdateExtensionController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request, int $id): ResponseInterface
{
$actor = RequestUtil::getActor($request);
$extensionId = Arr::get($request->getQueryParams(), 'id');
$response = $this->bus->dispatch(
new UpdateExtension($actor, $extensionId)
new UpdateExtension($actor, $id)
);
return $response->queueJobs

View File

@@ -9,27 +9,26 @@
namespace Flarum\PackageManager\Api\Controller;
use Flarum\Http\Controller\AbstractController;
use Flarum\Http\RequestUtil;
use Flarum\PackageManager\Command\WhyNot;
use Flarum\PackageManager\Job\Dispatcher;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
class WhyNotController implements RequestHandlerInterface
class WhyNotController extends AbstractController
{
public function __construct(
protected Dispatcher $bus
) {
}
public function handle(ServerRequestInterface $request): ResponseInterface
public function __invoke(Request $request): ResponseInterface
{
$actor = RequestUtil::getActor($request);
$package = Arr::get($request->getParsedBody(), 'data.package', '');
$version = Arr::get($request->getParsedBody(), 'data.version', '*');
$package = $request->json('data.package', '');
$version = $request->json('data.version', '*');
$whyNot = $this->bus->sync()->dispatch(
new WhyNot($actor, $package, $version)

View File

@@ -24,7 +24,7 @@ class TaskSerializer extends AbstractSerializer
{
if (! ($model instanceof Task)) {
throw new InvalidArgumentException(
$this::class.' can only serialize instances of '.Task::class
get_class($this).' can only serialize instances of '.Task::class
);
}

View File

@@ -45,7 +45,7 @@ class RequireExtensionHandler
$packageName = $command->package;
// Auto append :* if not requiring a specific version.
if (! str_contains($packageName, ':')) {
if (strpos($packageName, ':') === false) {
$packageName .= ':*';
}

View File

@@ -92,7 +92,7 @@ class TestCase extends \Flarum\Testing\integration\TestCase
protected function errorDetails(ResponseInterface $response): array
{
$json = json_decode((string) $response->getBody(), true);
$json = json_decode((string) $response->getContent(), true);
return $json['errors'] ? ($json['errors'][0] ?? []) : [];
}

Some files were not shown because too many files have changed in this diff Show More