mirror of
https://github.com/flarum/core.git
synced 2025-08-24 09:03:05 +02:00
Compare commits
22 Commits
sm/itemlis
...
sm/laravel
Author | SHA1 | Date | |
---|---|---|---|
|
e49dd8c8b7 | ||
|
0db8007002 | ||
|
835eba9178 | ||
|
2a0f8ff7ed | ||
|
e1ab77f66a | ||
|
6a812910dc | ||
|
f126c688d3 | ||
|
6fb1640b3c | ||
|
834bd732da | ||
|
9c3460a619 | ||
|
3b3efc7cbb | ||
|
cca5725fe4 | ||
|
0ce33c3ec0 | ||
|
495b24a5aa | ||
|
7d4549ea34 | ||
|
a60e3d174f | ||
|
0a89c3bd53 | ||
|
d056e339a4 | ||
|
3e49aeb32c | ||
|
47a0298958 | ||
|
f0eebc53ec | ||
|
5120e357bb |
9
.github/workflows/REUSABLE_backend.yml
vendored
9
.github/workflows/REUSABLE_backend.yml
vendored
@@ -43,7 +43,7 @@ on:
|
|||||||
description: Versions of databases to test with. Should be array of strings encoded as JSON array
|
description: Versions of databases to test with. Should be array of strings encoded as JSON array
|
||||||
type: string
|
type: string
|
||||||
required: false
|
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:
|
php_ini_values:
|
||||||
description: PHP ini values
|
description: PHP ini values
|
||||||
@@ -76,8 +76,6 @@ jobs:
|
|||||||
db: MySQL 8.0
|
db: MySQL 8.0
|
||||||
- service: mariadb
|
- service: mariadb
|
||||||
db: MariaDB
|
db: MariaDB
|
||||||
- service: 'mysql:8.1.0'
|
|
||||||
db: MySQL 8.1
|
|
||||||
|
|
||||||
# Include Database prefix tests with only one PHP version.
|
# Include Database prefix tests with only one PHP version.
|
||||||
- php: ${{ fromJSON(inputs.php_versions)[0] }}
|
- php: ${{ fromJSON(inputs.php_versions)[0] }}
|
||||||
@@ -95,11 +93,6 @@ jobs:
|
|||||||
db: MariaDB
|
db: MariaDB
|
||||||
prefix: flarum_
|
prefix: flarum_
|
||||||
prefixStr: (prefix)
|
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.
|
# To reduce number of actions, we exclude some PHP versions from running with some DB versions.
|
||||||
exclude:
|
exclude:
|
||||||
|
@@ -109,7 +109,6 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"components/font-awesome": "^5.15.0",
|
"components/font-awesome": "^5.15.0",
|
||||||
"composer/composer": "^2.0",
|
"composer/composer": "^2.0",
|
||||||
"dflydev/fig-cookies": "^3.0",
|
|
||||||
"doctrine/dbal": "^3.6.2",
|
"doctrine/dbal": "^3.6.2",
|
||||||
"dragonmantank/cron-expression": "^3.3",
|
"dragonmantank/cron-expression": "^3.3",
|
||||||
"franzl/whoops-middleware": "2.0",
|
"franzl/whoops-middleware": "2.0",
|
||||||
@@ -124,8 +123,10 @@
|
|||||||
"illuminate/events": "^10.0",
|
"illuminate/events": "^10.0",
|
||||||
"illuminate/filesystem": "^10.0",
|
"illuminate/filesystem": "^10.0",
|
||||||
"illuminate/hashing": "^10.0",
|
"illuminate/hashing": "^10.0",
|
||||||
|
"illuminate/http": "^10.0",
|
||||||
"illuminate/mail": "^10.0",
|
"illuminate/mail": "^10.0",
|
||||||
"illuminate/queue": "^10.0",
|
"illuminate/queue": "^10.0",
|
||||||
|
"illuminate/routing": "^10.0",
|
||||||
"illuminate/session": "^10.0",
|
"illuminate/session": "^10.0",
|
||||||
"illuminate/support": "^10.0",
|
"illuminate/support": "^10.0",
|
||||||
"illuminate/validation": "^10.0",
|
"illuminate/validation": "^10.0",
|
||||||
@@ -143,7 +144,6 @@
|
|||||||
"middlewares/request-handler": "^2.0.2",
|
"middlewares/request-handler": "^2.0.2",
|
||||||
"monolog/monolog": "^3.3",
|
"monolog/monolog": "^3.3",
|
||||||
"nesbot/carbon": "^2.66",
|
"nesbot/carbon": "^2.66",
|
||||||
"nikic/fast-route": "^1.3",
|
|
||||||
"psr/http-message": "^1.1",
|
"psr/http-message": "^1.1",
|
||||||
"psr/http-server-handler": "^1.0.2",
|
"psr/http-server-handler": "^1.0.2",
|
||||||
"psr/http-server-middleware": "^1.0.2",
|
"psr/http-server-middleware": "^1.0.2",
|
||||||
@@ -160,6 +160,7 @@
|
|||||||
"symfony/mime": "^6.3",
|
"symfony/mime": "^6.3",
|
||||||
"symfony/polyfill-intl-messageformatter": "^1.27",
|
"symfony/polyfill-intl-messageformatter": "^1.27",
|
||||||
"symfony/postmark-mailer": "^6.3",
|
"symfony/postmark-mailer": "^6.3",
|
||||||
|
"symfony/psr-http-message-bridge": "^2.3",
|
||||||
"symfony/translation": "^6.3",
|
"symfony/translation": "^6.3",
|
||||||
"symfony/yaml": "^6.3",
|
"symfony/yaml": "^6.3",
|
||||||
"wikimedia/less.php": "^4.1"
|
"wikimedia/less.php": "^4.1"
|
||||||
|
@@ -36,7 +36,7 @@ class AkismetProvider extends AbstractServiceProvider
|
|||||||
|
|
||||||
return new Akismet(
|
return new Akismet(
|
||||||
$settings->get('flarum-akismet.api_key'),
|
$settings->get('flarum-akismet.api_key'),
|
||||||
$url->to('forum')->base(),
|
$url->base('forum'),
|
||||||
$app::VERSION,
|
$app::VERSION,
|
||||||
$extensions->getExtension('flarum-akismet')->getVersion() ?? 'unknown',
|
$extensions->getExtension('flarum-akismet')->getVersion() ?? 'unknown',
|
||||||
$config->inDebugMode()
|
$config->inDebugMode()
|
||||||
|
@@ -38,7 +38,7 @@ class ListDiscussionsTest extends TestCase
|
|||||||
$this->request('GET', '/api/discussions', compact('authenticatedAs'))
|
$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->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertEqualsCanonicalizing([1, 4, 5, 7], Arr::pluck($body['data'], 'id'));
|
$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'))
|
$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->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], Arr::pluck($body['data'], 'id'));
|
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], Arr::pluck($body['data'], 'id'));
|
||||||
|
@@ -12,6 +12,7 @@ namespace Flarum\Approval\Tests\integration\api;
|
|||||||
use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
|
use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
|
||||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||||
use Flarum\Testing\integration\TestCase;
|
use Flarum\Testing\integration\TestCase;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class ListPostsTest extends TestCase
|
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)
|
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this
|
tap(
|
||||||
->request('GET', '/api/posts', compact('authenticatedAs'))
|
$this->request('GET', '/api/posts', compact('authenticatedAs')),
|
||||||
->withQueryParams([
|
fn (Request $request) => $request->query->add([
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'discussion' => 7
|
'discussion' => 7
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$body = json_decode($response->getBody()->getContents(), true);
|
$body = json_decode($response->getContent(), true);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertEqualsCanonicalizing([7, 8, 10], Arr::pluck($body['data'], 'id'));
|
$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)
|
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this
|
tap(
|
||||||
->request('GET', '/api/posts', compact('authenticatedAs'))
|
$this->request('GET', '/api/posts', compact('authenticatedAs')),
|
||||||
->withQueryParams([
|
fn (Request $request) => $request->query->add([
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'discussion' => 7
|
'discussion' => 7
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$body = json_decode($response->getBody()->getContents(), true);
|
$body = json_decode($response->getContent(), true);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertEqualsCanonicalizing([7, 8, 9, 10, 11], Arr::pluck($body['data'], 'id'));
|
$this->assertEqualsCanonicalizing([7, 8, 9, 10, 11], Arr::pluck($body['data'], 'id'));
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
use Flarum\Extend;
|
use Flarum\Extend;
|
||||||
use Flarum\Frontend\Document;
|
use Flarum\Frontend\Document;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new Extend\Frontend('forum'))
|
(new Extend\Frontend('forum'))
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
|
|
||||||
.scrolled & {
|
.scrolled & {
|
||||||
.box-shadow(0 2px 6px var(--shadow-color));
|
.box-shadow(0 2px 6px @shadow-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
&, a {
|
&, a {
|
||||||
color: var(--muted-color);
|
color: @muted-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ img.emoji {
|
|||||||
margin: 5px 0 !important;
|
margin: 5px 0 !important;
|
||||||
|
|
||||||
> li > button {
|
> li > button {
|
||||||
color: var(--text-color);
|
color: @text-color;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
padding-bottom: 6px;
|
padding-bottom: 6px;
|
||||||
@@ -25,7 +25,7 @@ img.emoji {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.Dropdown-header {
|
.Dropdown-header {
|
||||||
color: var(--muted-more-color);
|
color: @muted-more-color;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
14
extensions/flags/js/dist-typings/forum/components/FlagList.d.ts
generated
vendored
14
extensions/flags/js/dist-typings/forum/components/FlagList.d.ts
generated
vendored
@@ -1,11 +1,7 @@
|
|||||||
import Component from 'flarum/common/Component';
|
export default class FlagList extends Component<import("flarum/common/Component").ComponentAttrs, undefined> {
|
||||||
import type { ComponentAttrs } from 'flarum/common/Component';
|
constructor();
|
||||||
import type Mithril from 'mithril';
|
oninit(vnode: any): void;
|
||||||
import type FlagListState from '../states/FlagListState';
|
state: any;
|
||||||
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;
|
|
||||||
view(): JSX.Element;
|
view(): JSX.Element;
|
||||||
}
|
}
|
||||||
|
import Component from "flarum/common/Component";
|
||||||
|
17
extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts
generated
vendored
17
extensions/flags/js/dist-typings/forum/components/FlagsDropdown.d.ts
generated
vendored
@@ -1,12 +1,7 @@
|
|||||||
/// <reference types="mithril" />
|
export default class FlagsDropdown extends NotificationsDropdown<import("flarum/common/components/Dropdown").IDropdownAttrs> {
|
||||||
import HeaderDropdown from 'flarum/forum/components/HeaderDropdown';
|
static initAttrs(attrs: any): void;
|
||||||
import type { IHeaderDropdownAttrs } from 'flarum/forum/components/HeaderDropdown';
|
constructor();
|
||||||
export interface IFlagsDropdownAttrs extends IHeaderDropdownAttrs {
|
getUnreadCount(): any;
|
||||||
}
|
getNewCount(): unknown;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
import NotificationsDropdown from "flarum/forum/components/NotificationsDropdown";
|
||||||
|
15
extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts
generated
vendored
15
extensions/flags/js/dist-typings/forum/states/FlagListState.d.ts
generated
vendored
@@ -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 {
|
export default class FlagListState {
|
||||||
app: ForumApplication;
|
constructor(app: any);
|
||||||
|
app: any;
|
||||||
|
/**
|
||||||
|
* Whether or not the flags are loading.
|
||||||
|
*
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
loading: 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
|
* Load flags into the application's cache if they haven't already
|
||||||
* been loaded.
|
* been loaded.
|
||||||
*/
|
*/
|
||||||
load(): void;
|
load(): void;
|
||||||
|
cache: any;
|
||||||
}
|
}
|
||||||
|
2
extensions/flags/js/dist/forum.js
generated
vendored
2
extensions/flags/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/flags/js/dist/forum.js.map
generated
vendored
2
extensions/flags/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
import { extend, override } from 'flarum/common/extend';
|
import { extend } from 'flarum/common/extend';
|
||||||
import app from 'flarum/forum/app';
|
import app from 'flarum/forum/app';
|
||||||
import Post from 'flarum/forum/components/Post';
|
import Post from 'flarum/forum/components/Post';
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
@@ -75,7 +75,7 @@ export default function () {
|
|||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
|
||||||
override(Post.prototype, 'header', function (vdom) {
|
extend(Post.prototype, 'content', function (vdom) {
|
||||||
const post = this.attrs.post;
|
const post = this.attrs.post;
|
||||||
const flags = post.flags();
|
const flags = post.flags();
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ export default function () {
|
|||||||
|
|
||||||
if (post.isHidden()) this.revealContent = true;
|
if (post.isHidden()) this.revealContent = true;
|
||||||
|
|
||||||
return (
|
vdom.unshift(
|
||||||
<div className="Post-flagged">
|
<div className="Post-flagged">
|
||||||
<div className="Post-flagged-flags">
|
<div className="Post-flagged-flags">
|
||||||
{flags.map((flag) => (
|
{flags.map((flag) => (
|
||||||
|
65
extensions/flags/js/src/forum/components/FlagList.js
Normal file
65
extensions/flags/js/src/forum/components/FlagList.js
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,5 @@
|
|||||||
import app from 'flarum/forum/app';
|
import app from 'flarum/forum/app';
|
||||||
import Modal from 'flarum/common/components/Modal';
|
import Modal from 'flarum/common/components/Modal';
|
||||||
import Form from 'flarum/common/components/Form';
|
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
|
|
||||||
import Stream from 'flarum/common/utils/Stream';
|
import Stream from 'flarum/common/utils/Stream';
|
||||||
@@ -29,31 +28,31 @@ export default class FlagPostModal extends Modal {
|
|||||||
if (this.success) {
|
if (this.success) {
|
||||||
return (
|
return (
|
||||||
<div className="Modal-body">
|
<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>
|
<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)}>
|
<Button className="Button Button--primary Button--block" onclick={this.hide.bind(this)}>
|
||||||
{app.translator.trans('flarum-flags.forum.flag_post.dismiss_button')}
|
{app.translator.trans('flarum-flags.forum.flag_post.dismiss_button')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="Modal-body">
|
<div className="Modal-body">
|
||||||
<Form className="Form--centered">
|
<div className="Form Form--centered">
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<div>{this.flagReasons().toArray()}</div>
|
<div>{this.flagReasons().toArray()}</div>
|
||||||
</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()}>
|
<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')}
|
{app.translator.trans('flarum-flags.forum.flag_post.submit_button')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
33
extensions/flags/js/src/forum/components/FlagsDropdown.js
Normal file
33
extensions/flags/js/src/forum/components/FlagsDropdown.js
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
@@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
37
extensions/flags/js/src/forum/states/FlagListState.js
Normal file
37
extensions/flags/js/src/forum/states/FlagListState.js
Normal 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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,9 +1,6 @@
|
|||||||
.Post--flagged {
|
.Post--flagged {
|
||||||
--border-width: 2px;
|
|
||||||
padding-top: 0 !important;
|
padding-top: 0 !important;
|
||||||
padding-left: var(--post-padding);
|
border: 2px solid @primary-color;
|
||||||
margin-left: calc(~"0px - var(--post-padding)");
|
|
||||||
border: var(--border-width) solid var(--primary-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.Post-header .item-flagged {
|
.Post-header .item-flagged {
|
||||||
@@ -11,22 +8,29 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.Post-flagged {
|
.Post-flagged {
|
||||||
background: var(--primary-color);
|
background: @primary-color;
|
||||||
margin: calc(~"0px - var(--border-width)") calc(~"0px - var(--border-width) - var(--post-padding)") var(--post-padding);
|
margin-top: -2px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
margin-left: -22px;
|
||||||
|
margin-right: -22px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
border-radius: @border-radius @border-radius 0 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.light-contents(@color: @body-bg; @control-color: @body-bg);
|
.light-contents(@color: @body-bg; @control-color: @body-bg);
|
||||||
|
|
||||||
display: flex;
|
@media @tablet-up {
|
||||||
align-items: center;
|
margin-left: -22px - 85px;
|
||||||
justify-content: space-between;
|
}
|
||||||
|
|
||||||
&, a {
|
&, a {
|
||||||
color: var(--body-bg) !important;
|
color: @body-bg !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.Post-flagged-flags {
|
.Post-flagged-flags {
|
||||||
|
@media @tablet-up {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin: 7px 10px;
|
margin: 7px 10px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -38,10 +42,19 @@
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
.Post-flagged-actions {
|
.Post-flagged-actions {
|
||||||
display: flex;
|
@media @tablet-up {
|
||||||
align-items: center;
|
float: right;
|
||||||
flex-wrap: wrap;
|
}
|
||||||
gap: 5px;
|
}
|
||||||
|
.Post-flagged-actions .Button {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FlagsDropdown .Dropdown-toggle {
|
||||||
|
.Button-label,
|
||||||
|
.Button-caret {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.FlagPostModal {
|
.FlagPostModal {
|
||||||
@@ -53,16 +66,7 @@
|
|||||||
|
|
||||||
strong {
|
strong {
|
||||||
display: block;
|
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;
|
|
||||||
}
|
|
||||||
|
@@ -15,8 +15,7 @@ use Flarum\Flags\Command\CreateFlag;
|
|||||||
use Flarum\Flags\Flag;
|
use Flarum\Flags\Flag;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
class CreateFlagController extends AbstractCreateController
|
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(
|
return $this->bus->dispatch(
|
||||||
new CreateFlag(RequestUtil::getActor($request), Arr::get($request->getParsedBody(), 'data', []))
|
new CreateFlag(RequestUtil::getActor($request), $request->json('data', []))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,7 @@ use Flarum\Api\Controller\AbstractDeleteController;
|
|||||||
use Flarum\Flags\Command\DeleteFlags;
|
use Flarum\Flags\Command\DeleteFlags;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
|
|
||||||
class DeleteFlagsController extends AbstractDeleteController
|
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(
|
$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())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ use Flarum\Api\Controller\AbstractListController;
|
|||||||
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
use Flarum\Flags\Api\Serializer\FlagSerializer;
|
||||||
use Flarum\Flags\Flag;
|
use Flarum\Flags\Flag;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Illuminate\Http\Request;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
class ListFlagsController extends AbstractListController
|
class ListFlagsController extends AbstractListController
|
||||||
@@ -28,7 +28,7 @@ class ListFlagsController extends AbstractListController
|
|||||||
'post.discussion'
|
'post.discussion'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function data(ServerRequestInterface $request, Document $document): iterable
|
protected function data(Request $request, Document $document): iterable
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
$include = $this->extractInclude($request);
|
$include = $this->extractInclude($request);
|
||||||
|
@@ -24,7 +24,7 @@ class FlagSerializer extends AbstractSerializer
|
|||||||
{
|
{
|
||||||
if (! ($model instanceof Flag)) {
|
if (! ($model instanceof Flag)) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
$this::class.' can only serialize instances of '.Flag::class
|
get_class($this).' can only serialize instances of '.Flag::class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,11 +13,11 @@ use Flarum\Api\Controller;
|
|||||||
use Flarum\Flags\Api\Controller\CreateFlagController;
|
use Flarum\Flags\Api\Controller\CreateFlagController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class PrepareFlagsApiData
|
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
|
// For any API action that allows the 'flags' relationship to be
|
||||||
// included, we need to preload this relationship onto the data (Post
|
// included, we need to preload this relationship onto the data (Post
|
||||||
|
@@ -75,7 +75,7 @@ class ListTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);
|
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);
|
||||||
@@ -94,7 +94,7 @@ class ListTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
|
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
|
||||||
@@ -113,7 +113,7 @@ class ListTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);
|
$this->assertEqualsCanonicalizing(['1', '4', '5'], $ids);
|
||||||
|
@@ -108,7 +108,7 @@ class ListWithTagsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['1', '4', '5', '6', '7', '8', '9'], $ids);
|
$this->assertEqualsCanonicalizing(['1', '4', '5', '6', '7', '8', '9'], $ids);
|
||||||
@@ -127,7 +127,7 @@ class ListWithTagsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
|
$this->assertEqualsCanonicalizing(['2', '4'], $ids);
|
||||||
@@ -146,7 +146,7 @@ class ListWithTagsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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');
|
$ids = Arr::pluck($data, 'id');
|
||||||
// 7 is included, even though mods can't view discussions.
|
// 7 is included, even though mods can't view discussions.
|
||||||
|
2
extensions/likes/js/dist/forum.js
generated
vendored
2
extensions/likes/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/likes/js/dist/forum.js.map
generated
vendored
2
extensions/likes/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@ import CommentPost from 'flarum/forum/components/CommentPost';
|
|||||||
import Link from 'flarum/common/components/Link';
|
import Link from 'flarum/common/components/Link';
|
||||||
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
|
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
|
||||||
import username from 'flarum/common/helpers/username';
|
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 Button from 'flarum/common/components/Button';
|
||||||
|
|
||||||
import PostLikesModal from './components/PostLikesModal';
|
import PostLikesModal from './components/PostLikesModal';
|
||||||
@@ -58,7 +58,7 @@ export default function () {
|
|||||||
items.add(
|
items.add(
|
||||||
'liked',
|
'liked',
|
||||||
<div className="Post-likedBy">
|
<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`, {
|
{app.translator.trans(`flarum-likes.forum.post.liked_by${likes[0] === app.session.user ? '_self' : ''}_text`, {
|
||||||
count: names.length,
|
count: names.length,
|
||||||
users: punctuateSeries(names),
|
users: punctuateSeries(names),
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import app from 'flarum/forum/app';
|
import app from 'flarum/forum/app';
|
||||||
import Modal from 'flarum/common/components/Modal';
|
import Modal from 'flarum/common/components/Modal';
|
||||||
import Link from 'flarum/common/components/Link';
|
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 username from 'flarum/common/helpers/username';
|
||||||
import type { IInternalModalAttrs } from 'flarum/common/components/Modal';
|
import type { IInternalModalAttrs } from 'flarum/common/components/Modal';
|
||||||
import type Post from 'flarum/common/models/Post';
|
import type Post from 'flarum/common/models/Post';
|
||||||
@@ -9,7 +9,6 @@ import type Mithril from 'mithril';
|
|||||||
import PostLikesModalState from '../states/PostLikesModalState';
|
import PostLikesModalState from '../states/PostLikesModalState';
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
||||||
import Form from 'flarum/common/components/Form';
|
|
||||||
|
|
||||||
export interface IPostLikesModalAttrs extends IInternalModalAttrs {
|
export interface IPostLikesModalAttrs extends IInternalModalAttrs {
|
||||||
post: Post;
|
post: Post;
|
||||||
@@ -48,7 +47,7 @@ export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = I
|
|||||||
page.items.map((user) => (
|
page.items.map((user) => (
|
||||||
<li>
|
<li>
|
||||||
<Link href={app.route.user(user)}>
|
<Link href={app.route.user(user)}>
|
||||||
<Avatar user={user} /> {username(user)}
|
{avatar(user)} {username(user)}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))
|
))
|
||||||
@@ -58,13 +57,13 @@ export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = I
|
|||||||
</div>
|
</div>
|
||||||
{this.state.hasNext() ? (
|
{this.state.hasNext() ? (
|
||||||
<div className="Modal-footer">
|
<div className="Modal-footer">
|
||||||
<Form className="Form--centered">
|
<div className="Form Form--centered">
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
|
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
|
||||||
{app.translator.trans('flarum-likes.forum.post_likes.load_more_button')}
|
{app.translator.trans('flarum-likes.forum.post_likes.load_more_button')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</>
|
</>
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--text-color);
|
color: @text-color;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: block;
|
display: block;
|
||||||
|
@@ -16,13 +16,13 @@ use Flarum\Post\Post;
|
|||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Query\Expression;
|
use Illuminate\Database\Query\Expression;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class LoadLikesRelationship
|
class LoadLikesRelationship
|
||||||
{
|
{
|
||||||
public static int $maxLikes = 4;
|
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);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
|
@@ -143,7 +143,7 @@ class LikePostTest extends TestCase
|
|||||||
$this->request('GET', '/')
|
$this->request('GET', '/')
|
||||||
);
|
);
|
||||||
|
|
||||||
$token = $initial->getHeaderLine('X-CSRF-Token');
|
$token = $initial->headers->get('X-CSRF-Token');
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $this->request('PATCH', "/api/posts/$postId", [
|
$request = $this->request('PATCH', "/api/posts/$postId", [
|
||||||
@@ -159,7 +159,7 @@ class LikePostTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (! isset($authenticatedAs)) {
|
if (! isset($authenticatedAs)) {
|
||||||
$request = $request->withHeader('X-CSRF-Token', $token);
|
$request->headers->set('X-CSRF-Token', $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->send($request);
|
return $this->send($request);
|
||||||
|
@@ -14,6 +14,7 @@ use Flarum\Group\Group;
|
|||||||
use Flarum\Likes\Api\LoadLikesRelationship;
|
use Flarum\Likes\Api\LoadLikesRelationship;
|
||||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||||
use Flarum\Testing\integration\TestCase;
|
use Flarum\Testing\integration\TestCase;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class ListPostsTest extends TestCase
|
class ListPostsTest extends TestCase
|
||||||
@@ -75,15 +76,17 @@ class ListPostsTest extends TestCase
|
|||||||
public function liked_filter_works()
|
public function liked_filter_works()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/users')
|
tap(
|
||||||
->withQueryParams([
|
$this->request('GET', '/api/users'),
|
||||||
|
fn (Request $request) => $request->query->add([
|
||||||
'filter' => ['liked' => 101],
|
'filter' => ['liked' => 101],
|
||||||
])
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
$data = json_decode($response->getContent(), true)['data'];
|
||||||
|
|
||||||
// Order-independent comparison
|
// Order-independent comparison
|
||||||
$ids = Arr::pluck($data, 'id');
|
$ids = Arr::pluck($data, 'id');
|
||||||
@@ -98,15 +101,17 @@ class ListPostsTest extends TestCase
|
|||||||
public function liked_filter_works_negated()
|
public function liked_filter_works_negated()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/users')
|
tap(
|
||||||
->withQueryParams([
|
$this->request('GET', '/api/users'),
|
||||||
'filter' => ['-liked' => 101],
|
fn (Request $request) => $request->query->add([
|
||||||
])
|
'filter' => ['-liked' => 101],
|
||||||
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
$data = json_decode($response->getContent(), true)['data'];
|
||||||
|
|
||||||
// Order-independent comparison
|
// Order-independent comparison
|
||||||
$ids = Arr::pluck($data, 'id');
|
$ids = Arr::pluck($data, 'id');
|
||||||
@@ -118,14 +123,17 @@ class ListPostsTest extends TestCase
|
|||||||
{
|
{
|
||||||
// List posts endpoint
|
// List posts endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts/101', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/posts/101', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'include' => 'likes',
|
]),
|
||||||
])
|
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());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
@@ -144,15 +152,18 @@ class ListPostsTest extends TestCase
|
|||||||
{
|
{
|
||||||
// List posts endpoint
|
// List posts endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/posts', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'filter' => ['discussion' => 100],
|
]),
|
||||||
'include' => 'likes',
|
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());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
@@ -174,14 +185,17 @@ class ListPostsTest extends TestCase
|
|||||||
{
|
{
|
||||||
// Show discussion endpoint
|
// Show discussion endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/discussions/100', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/discussions/100', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'include' => $include,
|
]),
|
||||||
])
|
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)
|
$likes = collect($included)
|
||||||
->where('type', 'posts')
|
->where('type', 'posts')
|
||||||
|
2
extensions/lock/js/dist/forum.js
generated
vendored
2
extensions/lock/js/dist/forum.js
generated
vendored
@@ -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
|
//# sourceMappingURL=forum.js.map
|
2
extensions/lock/js/dist/forum.js.map
generated
vendored
2
extensions/lock/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -15,8 +15,4 @@ export default class DiscussionLockedNotification extends Notification {
|
|||||||
content() {
|
content() {
|
||||||
return app.translator.trans('flarum-lock.forum.notifications.discussion_locked_text', { user: this.attrs.notification.fromUser() });
|
return app.translator.trans('flarum-lock.forum.notifications.discussion_locked_text', { user: this.attrs.notification.fromUser() });
|
||||||
}
|
}
|
||||||
|
|
||||||
excerpt() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
2
extensions/markdown/js/dist/admin.js
generated
vendored
2
extensions/markdown/js/dist/admin.js
generated
vendored
@@ -1,3 +1,3 @@
|
|||||||
/*! For license information please see admin.js.LICENSE.txt */
|
/*! 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:"",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:"",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
|
//# sourceMappingURL=admin.js.map
|
2
extensions/markdown/js/dist/admin.js.map
generated
vendored
2
extensions/markdown/js/dist/admin.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/markdown/js/dist/forum.js
generated
vendored
2
extensions/markdown/js/dist/forum.js
generated
vendored
@@ -1,3 +1,3 @@
|
|||||||
/*! For license information please see forum.js.LICENSE.txt */
|
/*! 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:"",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:"",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
|
//# sourceMappingURL=forum.js.map
|
2
extensions/markdown/js/dist/forum.js.map
generated
vendored
2
extensions/markdown/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
|||||||
import Component from 'flarum/common/Component';
|
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';
|
import Tooltip from 'flarum/common/components/Tooltip';
|
||||||
|
|
||||||
export default class MarkdownButton extends Component {
|
export default class MarkdownButton extends Component {
|
||||||
@@ -16,7 +16,7 @@ export default class MarkdownButton extends Component {
|
|||||||
onkeydown={this.keydown.bind(this)}
|
onkeydown={this.keydown.bind(this)}
|
||||||
onclick={this.attrs.onclick}
|
onclick={this.attrs.onclick}
|
||||||
>
|
>
|
||||||
<Icon name={this.attrs.icon} />
|
{icon(this.attrs.icon)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ use Flarum\Post\Event\Revised;
|
|||||||
use Flarum\Post\Filter\PostFilterer;
|
use Flarum\Post\Filter\PostFilterer;
|
||||||
use Flarum\Post\Post;
|
use Flarum\Post\Post;
|
||||||
use Flarum\Tags\Api\Serializer\TagSerializer;
|
use Flarum\Tags\Api\Serializer\TagSerializer;
|
||||||
|
use Flarum\Tags\Tag;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -125,7 +126,7 @@ return [
|
|||||||
|
|
||||||
// Tag mentions
|
// Tag mentions
|
||||||
(new Extend\Conditional())
|
(new Extend\Conditional())
|
||||||
->whenExtensionEnabled('flarum-tags', fn () => [
|
->whenExtensionEnabled('flarum-tags', [
|
||||||
(new Extend\Formatter)
|
(new Extend\Formatter)
|
||||||
->render(Formatter\FormatTagMentions::class)
|
->render(Formatter\FormatTagMentions::class)
|
||||||
->unparse(Formatter\UnparseTagMentions::class),
|
->unparse(Formatter\UnparseTagMentions::class),
|
||||||
|
2
extensions/mentions/js/dist/forum.js
generated
vendored
2
extensions/mentions/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/mentions/js/dist/forum.js.map
generated
vendored
2
extensions/mentions/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ import Link from 'flarum/common/components/Link';
|
|||||||
import PostPreview from 'flarum/forum/components/PostPreview';
|
import PostPreview from 'flarum/forum/components/PostPreview';
|
||||||
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
|
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
|
||||||
import username from 'flarum/common/helpers/username';
|
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 Button from 'flarum/common/components/Button';
|
||||||
import MentionedByModal from './components/MentionedByModal';
|
import MentionedByModal from './components/MentionedByModal';
|
||||||
|
|
||||||
@@ -54,9 +54,7 @@ export default function addMentionedByList() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="PostPreview-content">
|
<span className="PostPreview-content">
|
||||||
<span className="PostPreview-badge Avatar">
|
<span className="PostPreview-badge Avatar">{icon('fas fa-reply-all')}</span>
|
||||||
<Icon name={'fas fa-reply-all'} />
|
|
||||||
</span>
|
|
||||||
<span>
|
<span>
|
||||||
{app.translator.trans('flarum-mentions.forum.post.mentioned_by_more_text', { count: post.mentionedByCount() - replies.length })}
|
{app.translator.trans('flarum-mentions.forum.post.mentioned_by_more_text', { count: post.mentionedByCount() - replies.length })}
|
||||||
</span>
|
</span>
|
||||||
@@ -147,7 +145,7 @@ export default function addMentionedByList() {
|
|||||||
'replies',
|
'replies',
|
||||||
<div className="Post-mentionedBy">
|
<div className="Post-mentionedBy">
|
||||||
<span className="Post-mentionedBy-summary">
|
<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`, {
|
{app.translator.trans(`flarum-mentions.forum.post.mentioned_by${repliers[0].user() === app.session.user ? '_self' : ''}_text`, {
|
||||||
count: names.length,
|
count: names.length,
|
||||||
users: punctuateSeries(names),
|
users: punctuateSeries(names),
|
||||||
|
@@ -5,7 +5,7 @@ import CommentPost from 'flarum/forum/components/CommentPost';
|
|||||||
|
|
||||||
import reply from './utils/reply';
|
import reply from './utils/reply';
|
||||||
|
|
||||||
export default function addPostReplyAction() {
|
export default function () {
|
||||||
extend(CommentPost.prototype, 'actionItems', function (items) {
|
extend(CommentPost.prototype, 'actionItems', function (items) {
|
||||||
const post = this.attrs.post;
|
const post = this.attrs.post;
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@ import type Post from 'flarum/common/models/Post';
|
|||||||
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import MentionedByModalState from '../state/MentionedByModalState';
|
import MentionedByModalState from '../state/MentionedByModalState';
|
||||||
import Form from 'flarum/common/components/Form';
|
|
||||||
|
|
||||||
export interface IMentionedByModalAttrs extends IInternalModalAttrs {
|
export interface IMentionedByModalAttrs extends IInternalModalAttrs {
|
||||||
post: Post;
|
post: Post;
|
||||||
@@ -59,13 +58,13 @@ export default class MentionedByModal<CustomAttrs extends IMentionedByModalAttrs
|
|||||||
</div>
|
</div>
|
||||||
{this.state.hasNext() && (
|
{this.state.hasNext() && (
|
||||||
<div className="Modal-footer">
|
<div className="Modal-footer">
|
||||||
<Form className="Form--centered">
|
<div className="Form Form--centered">
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
|
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
|
||||||
{app.translator.trans('flarum-mentions.forum.mentioned_by.load_more_button')}
|
{app.translator.trans('flarum-mentions.forum.mentioned_by.load_more_button')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import app from 'flarum/forum/app';
|
import app from 'flarum/forum/app';
|
||||||
import Fragment from 'flarum/common/Fragment';
|
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';
|
import reply from '../utils/reply';
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export default class PostQuoteButton extends Fragment {
|
|||||||
reply(this.post, this.content);
|
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')}
|
{app.translator.trans('flarum-mentions.forum.post.quote_button')}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
@@ -3,7 +3,7 @@ import MentionableModel from './MentionableModel';
|
|||||||
import type Post from 'flarum/common/models/Post';
|
import type Post from 'flarum/common/models/Post';
|
||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import usernameHelper from 'flarum/common/helpers/username';
|
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 highlight from 'flarum/common/helpers/highlight';
|
||||||
import { truncate } from 'flarum/common/utils/string';
|
import { truncate } from 'flarum/common/utils/string';
|
||||||
import getCleanDisplayName from '../utils/getCleanDisplayName';
|
import getCleanDisplayName from '../utils/getCleanDisplayName';
|
||||||
@@ -63,7 +63,7 @@ export default class PostMention extends MentionableModel<Post, AtMentionFormat>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Avatar user={user} />
|
{avatar(user)}
|
||||||
{username}
|
{username}
|
||||||
{[
|
{[
|
||||||
app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: model.number() }),
|
app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: model.number() }),
|
||||||
|
@@ -2,7 +2,7 @@ import app from 'flarum/forum/app';
|
|||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import type User from 'flarum/common/models/User';
|
import type User from 'flarum/common/models/User';
|
||||||
import usernameHelper from 'flarum/common/helpers/username';
|
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 highlight from 'flarum/common/helpers/highlight';
|
||||||
import MentionableModel from './MentionableModel';
|
import MentionableModel from './MentionableModel';
|
||||||
import getCleanDisplayName, { shouldUseOldFormat } from '../utils/getCleanDisplayName';
|
import getCleanDisplayName, { shouldUseOldFormat } from '../utils/getCleanDisplayName';
|
||||||
@@ -46,7 +46,7 @@ export default class UserMention extends MentionableModel<User, AtMentionFormat>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Avatar user={model} />
|
{avatar(model)}
|
||||||
{username}
|
{username}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
.PostMention, .UserMention, .GroupMention {
|
.PostMention, .UserMention, .GroupMention {
|
||||||
background: var(--control-bg);
|
background: var(--control-bg);
|
||||||
color: var(--control-color);
|
color: var(--control-color);
|
||||||
border-radius: var(--border-radius);
|
border-radius: @border-radius;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|
||||||
blockquote & {
|
blockquote & {
|
||||||
@@ -30,7 +30,10 @@
|
|||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
// @TODO: 2.0 use an icon in the XSLT template.
|
||||||
|
&:before {
|
||||||
|
.fas();
|
||||||
|
content: @fa-var-reply;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +81,7 @@
|
|||||||
.MentionsDropdown, .PostMention-preview, .Post-mentionedBy-preview {
|
.MentionsDropdown, .PostMention-preview, .Post-mentionedBy-preview {
|
||||||
// @TODO: Rename to .MentionsDropdownItem, along with child classes. 2.0
|
// @TODO: Rename to .MentionsDropdownItem, along with child classes. 2.0
|
||||||
.PostPreview {
|
.PostPreview {
|
||||||
color: var(--muted-color);
|
color: @muted-color;
|
||||||
|
|
||||||
.Avatar {
|
.Avatar {
|
||||||
.Avatar--size(24px);
|
.Avatar--size(24px);
|
||||||
@@ -90,7 +93,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.username {
|
.username {
|
||||||
color: var(--text-color);
|
color: @text-color;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,43 +70,40 @@ flarum-mentions:
|
|||||||
# These translations are used in emails sent when a post is replied to
|
# These translations are used in emails sent when a post is replied to
|
||||||
post_mentioned:
|
post_mentioned:
|
||||||
subject: "{replier_display_name} replied to your post in {title}"
|
subject: "{replier_display_name} replied to your post in {title}"
|
||||||
plain:
|
body: |
|
||||||
body: |
|
Hey {recipient_display_name}!
|
||||||
{replier_display_name} replied to your post (#{post_number}) in {title}.
|
|
||||||
|
|
||||||
{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
|
# These translations are used in emails sent when a user is mentioned
|
||||||
user_mentioned:
|
user_mentioned:
|
||||||
subject: "{mentioner_display_name} mentioned you in {title}"
|
subject: "{mentioner_display_name} mentioned you in {title}"
|
||||||
plain:
|
body: |
|
||||||
body: |
|
Hey {recipient_display_name}!
|
||||||
{mentioner_display_name} mentioned you in a post in {title}.
|
|
||||||
|
|
||||||
{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
|
# These translations are used in emails sent when a group is mentioned
|
||||||
group_mentioned:
|
group_mentioned:
|
||||||
subject: "{mentioner_display_name} mentioned a group you're a member of in {title}"
|
subject: "{mentioner_display_name} mentioned a group you're a member of in {title}"
|
||||||
plain:
|
body: |
|
||||||
body: |
|
Hey {recipient_display_name}!
|
||||||
{mentioner_display_name} mentioned a group you're a member of in {title}.
|
|
||||||
|
|
||||||
{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}
|
||||||
|
@@ -15,7 +15,7 @@ use Flarum\Http\RequestUtil;
|
|||||||
use Flarum\Post\Post;
|
use Flarum\Post\Post;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply visibility permissions to API data's mentionedBy relationship.
|
* Apply visibility permissions to API data's mentionedBy relationship.
|
||||||
@@ -25,7 +25,7 @@ class LoadMentionedByRelationship
|
|||||||
{
|
{
|
||||||
public static int $maxMentionedBy = 4;
|
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);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class LoadMentionedByRelationship
|
|||||||
/**
|
/**
|
||||||
* Called using the @see ApiController::prepareDataForSerialization extender.
|
* 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);
|
$actor = RequestUtil::getActor($request);
|
||||||
$loadable = null;
|
$loadable = null;
|
||||||
|
@@ -50,7 +50,7 @@ class ConfigureMentions
|
|||||||
|
|
||||||
private function configureUserMentions(Configurator $config): void
|
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';
|
$tagName = 'USERMENTION';
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class ConfigureMentions
|
|||||||
|
|
||||||
private function configurePostMentions(Configurator $config): void
|
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';
|
$tagName = 'POSTMENTION';
|
||||||
|
|
||||||
@@ -122,10 +122,10 @@ class ConfigureMentions
|
|||||||
$tag->template = '
|
$tag->template = '
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@deleted != 1">
|
<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:when>
|
||||||
<xsl:otherwise>
|
<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:otherwise>
|
||||||
</xsl:choose>';
|
</xsl:choose>';
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ class ConfigureMentions
|
|||||||
|
|
||||||
private function configureTagMentions(Configurator $config): void
|
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';
|
$tagName = 'TAGMENTION';
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ namespace Flarum\Mentions\Formatter;
|
|||||||
use Flarum\Discussion\Discussion;
|
use Flarum\Discussion\Discussion;
|
||||||
use Flarum\Http\SlugManager;
|
use Flarum\Http\SlugManager;
|
||||||
use Flarum\Locale\TranslatorInterface;
|
use Flarum\Locale\TranslatorInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Illuminate\Http\Request;
|
||||||
use s9e\TextFormatter\Renderer;
|
use s9e\TextFormatter\Renderer;
|
||||||
use s9e\TextFormatter\Utils;
|
use s9e\TextFormatter\Utils;
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ namespace Flarum\Mentions\Formatter;
|
|||||||
|
|
||||||
use Flarum\Post\Post;
|
use Flarum\Post\Post;
|
||||||
use Flarum\Tags\Tag;
|
use Flarum\Tags\Tag;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Illuminate\Http\Request;
|
||||||
use s9e\TextFormatter\Renderer;
|
use s9e\TextFormatter\Renderer;
|
||||||
use s9e\TextFormatter\Utils;
|
use s9e\TextFormatter\Utils;
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ class UnparsePostMentions
|
|||||||
$attributes['displayname'] = $this->translator->trans('core.lib.username.deleted_text');
|
$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']);
|
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class UnparsePostMentions
|
|||||||
{
|
{
|
||||||
$tagName = 'POSTMENTION';
|
$tagName = 'POSTMENTION';
|
||||||
|
|
||||||
if (! str_contains($xml, $tagName)) {
|
if (strpos($xml, $tagName) === false) {
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ class UnparseTagMentions
|
|||||||
{
|
{
|
||||||
$tagName = 'TAGMENTION';
|
$tagName = 'TAGMENTION';
|
||||||
|
|
||||||
if (! str_contains($xml, $tagName)) {
|
if (strpos($xml, $tagName) === false) {
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ class UnparseUserMentions
|
|||||||
|
|
||||||
$attributes['displayname'] = $user?->display_name ?? $this->translator->trans('core.lib.username.deleted_text');
|
$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']);
|
$attributes['displayname'] = preg_replace('/"#[a-z]{0,3}[0-9]+/', '_', $attributes['displayname']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ class UnparseUserMentions
|
|||||||
{
|
{
|
||||||
$tagName = 'USERMENTION';
|
$tagName = 'USERMENTION';
|
||||||
|
|
||||||
if (! str_contains($xml, $tagName)) {
|
if (strpos($xml, $tagName) === false) {
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,11 +38,9 @@ class GroupMentionedBlueprint implements BlueprintInterface, MailableInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailViews(): array
|
public function getEmailView(): string|array
|
||||||
{
|
{
|
||||||
return [
|
return ['text' => 'flarum-mentions::emails.groupMentioned'];
|
||||||
'text' => 'flarum-mentions::emails.plain.groupMentioned',
|
|
||||||
'html' => 'flarum-mentions::emails.html.groupMentioned', ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailSubject(TranslatorInterface $translator): string
|
public function getEmailSubject(TranslatorInterface $translator): string
|
||||||
|
@@ -39,12 +39,9 @@ class PostMentionedBlueprint implements BlueprintInterface, MailableInterface
|
|||||||
return ['replyNumber' => (int) $this->reply->number];
|
return ['replyNumber' => (int) $this->reply->number];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailViews(): array
|
public function getEmailView(): string|array
|
||||||
{
|
{
|
||||||
return [
|
return ['text' => 'flarum-mentions::emails.postMentioned'];
|
||||||
'text' => 'flarum-mentions::emails.plain.postMentioned',
|
|
||||||
'html' => 'flarum-mentions::emails.html.postMentioned',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailSubject(TranslatorInterface $translator): string
|
public function getEmailSubject(TranslatorInterface $translator): string
|
||||||
|
@@ -38,12 +38,9 @@ class UserMentionedBlueprint implements BlueprintInterface, MailableInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailViews(): array
|
public function getEmailView(): string|array
|
||||||
{
|
{
|
||||||
return [
|
return ['text' => 'flarum-mentions::emails.userMentioned'];
|
||||||
'text' => 'flarum-mentions::emails.plain.userMentioned',
|
|
||||||
'html' => 'flarum-mentions::emails.html.userMentioned'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmailSubject(TranslatorInterface $translator): string
|
public function getEmailSubject(TranslatorInterface $translator): string
|
||||||
|
@@ -70,7 +70,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
$this->request('GET', '/api/posts/4')
|
$this->request('GET', '/api/posts/4')
|
||||||
);
|
);
|
||||||
|
|
||||||
$contents = $response->getBody()->getContents();
|
$contents = $response->getContent();
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode(), $contents);
|
$this->assertEquals(200, $response->getStatusCode(), $contents);
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('@"InvalidGroup"#g99', $response['data']['attributes']['content']);
|
||||||
$this->assertStringNotContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -126,7 +126,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -148,7 +148,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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('@Fresh Name', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('GroupMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -179,7 +179,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('fas fa-bolt', $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());
|
$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('@Admins', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -245,7 +245,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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('@Members', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringNotContainsString('@Guests', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('@Guests', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -301,7 +301,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('@Mods', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
|
||||||
@@ -332,7 +332,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"Mods"#g4', $response['data']['attributes']['content']);
|
||||||
@@ -363,7 +363,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('@Ninjas', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"Ninjas"#g10', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"Ninjas"#g10', $response['data']['attributes']['content']);
|
||||||
@@ -391,7 +391,7 @@ class GroupMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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->assertStringContainsString('@Mods', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('New content with @"Mods"#g4 mention', $response['data']['attributes']['content']);
|
$this->assertEquals('New content with @"Mods"#g4 mention', $response['data']['attributes']['content']);
|
||||||
|
@@ -13,6 +13,7 @@ use Carbon\Carbon;
|
|||||||
use Flarum\Mentions\Api\LoadMentionedByRelationship;
|
use Flarum\Mentions\Api\LoadMentionedByRelationship;
|
||||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||||
use Flarum\Testing\integration\TestCase;
|
use Flarum\Testing\integration\TestCase;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class ListPostsTest extends TestCase
|
class ListPostsTest extends TestCase
|
||||||
@@ -55,13 +56,15 @@ class ListPostsTest extends TestCase
|
|||||||
public function mentioned_filter_works()
|
public function mentioned_filter_works()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts')
|
tap(
|
||||||
->withQueryParams([
|
$this->request('GET', '/api/posts'),
|
||||||
|
fn (Request $request) => $request->query->add([
|
||||||
'filter' => ['mentioned' => 1],
|
'filter' => ['mentioned' => 1],
|
||||||
])
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
$data = json_decode($response->getContent(), true)['data'];
|
||||||
|
|
||||||
// Order-independent comparison
|
// Order-independent comparison
|
||||||
$ids = Arr::pluck($data, 'id');
|
$ids = Arr::pluck($data, 'id');
|
||||||
@@ -74,13 +77,15 @@ class ListPostsTest extends TestCase
|
|||||||
public function mentioned_filter_works_negated()
|
public function mentioned_filter_works_negated()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts')
|
tap(
|
||||||
->withQueryParams([
|
$this->request('GET', '/api/posts'),
|
||||||
'filter' => ['-mentioned' => 1],
|
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
|
// Order-independent comparison
|
||||||
$ids = Arr::pluck($data, 'id');
|
$ids = Arr::pluck($data, 'id');
|
||||||
@@ -93,14 +98,16 @@ class ListPostsTest extends TestCase
|
|||||||
public function mentioned_filter_works_with_sort()
|
public function mentioned_filter_works_with_sort()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts')
|
tap(
|
||||||
->withQueryParams([
|
$this->request('GET', '/api/posts'),
|
||||||
|
fn (Request $request) => $request->query->add([
|
||||||
'filter' => ['mentioned' => 1],
|
'filter' => ['mentioned' => 1],
|
||||||
'sort' => '-createdAt'
|
'sort' => '-createdAt'
|
||||||
])
|
])
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
$data = json_decode($response->getContent(), true)['data'];
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
@@ -153,14 +160,17 @@ class ListPostsTest extends TestCase
|
|||||||
|
|
||||||
// List posts endpoint
|
// List posts endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts/101', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/posts/101', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'include' => 'mentionedBy',
|
]),
|
||||||
])
|
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());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
@@ -179,15 +189,18 @@ class ListPostsTest extends TestCase
|
|||||||
|
|
||||||
// List posts endpoint
|
// List posts endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/posts', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/posts', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'filter' => ['discussion' => 100],
|
]),
|
||||||
'include' => 'mentionedBy',
|
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());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
@@ -209,14 +222,17 @@ class ListPostsTest extends TestCase
|
|||||||
|
|
||||||
// Show discussion endpoint
|
// Show discussion endpoint
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/discussions/100', [
|
tap(
|
||||||
'authenticatedAs' => 2,
|
$this->request('GET', '/api/discussions/100', [
|
||||||
])->withQueryParams([
|
'authenticatedAs' => 2,
|
||||||
'include' => $include,
|
]),
|
||||||
])
|
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)
|
$mentionedBy = collect($included)
|
||||||
->where('type', 'posts')
|
->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());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('POTATO$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@potato#4', $response['data']['attributes']['content']);
|
$this->assertEquals('@potato#4', $response['data']['attributes']['content']);
|
||||||
@@ -124,7 +124,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
|
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
|
||||||
@@ -155,7 +155,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"potato"#p50', $response['data']['attributes']['content']);
|
$this->assertEquals('@"potato"#p50', $response['data']['attributes']['content']);
|
||||||
@@ -186,7 +186,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
|
$this->assertEquals('@"POTATO$"#p4', $response['data']['attributes']['content']);
|
||||||
@@ -217,7 +217,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"franzofflarum"#p215', $response['data']['attributes']['content']);
|
$this->assertEquals('@"franzofflarum"#p215', $response['data']['attributes']['content']);
|
||||||
@@ -248,7 +248,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('TOBY$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringNotContainsString('FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -271,7 +271,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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('TOBY$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('PostMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('PostMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -291,7 +291,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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->assertStringContainsString('@"TOBY$"#p5', $response['data']['attributes']['content']);
|
||||||
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
|
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsPosts);
|
||||||
@@ -312,7 +312,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"'.$deleted_text.'"#p7', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"'.$deleted_text.'"#p7', $response['data']['attributes']['content']);
|
||||||
@@ -337,7 +337,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"'.$deleted_text.'"#p2010', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"'.$deleted_text.'"#p2010', $response['data']['attributes']['content']);
|
||||||
@@ -362,7 +362,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"'.$deleted_text.'"#p2020', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"'.$deleted_text.'"#p2020', $response['data']['attributes']['content']);
|
||||||
@@ -395,7 +395,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"POTATO$"#p6 User"#p9', $response['data']['attributes']['content']);
|
$this->assertEquals('@"POTATO$"#p6 User"#p9', $response['data']['attributes']['content']);
|
||||||
@@ -416,7 +416,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
||||||
@@ -447,7 +447,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
||||||
@@ -475,7 +475,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
||||||
@@ -503,7 +503,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#p9', $response['data']['attributes']['content']);
|
||||||
@@ -531,7 +531,7 @@ class PostMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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->assertStringContainsString('[deleted]', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"[deleted]"#p11', $response['data']['attributes']['content']);
|
$this->assertEquals('@"[deleted]"#p11', $response['data']['attributes']['content']);
|
||||||
|
@@ -81,7 +81,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringNotContainsString('TagMention--deleted', $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());
|
$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('Tatakai', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -138,7 +138,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertEquals('#franzofflarum', $response['data']['attributes']['content']);
|
||||||
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -168,7 +168,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertEquals('#test', $response['data']['attributes']['content']);
|
||||||
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -196,7 +196,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertEquals('#dev', $response['data']['attributes']['content']);
|
||||||
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -224,7 +224,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertEquals('#dev', $response['data']['attributes']['content']);
|
||||||
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -252,7 +252,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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('Test', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('Flarum', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('Flarum', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -273,7 +273,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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('Test', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('TagMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -305,7 +305,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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->assertStringContainsString('#test', $response['data']['attributes']['content']);
|
||||||
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
|
$this->assertCount(1, CommentPost::find($response['data']['id'])->mentionsTags);
|
||||||
@@ -325,7 +325,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
|
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
|
||||||
@@ -348,7 +348,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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('Support', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
|
$this->assertStringContainsString("#$deleted_text", $response['data']['attributes']['content']);
|
||||||
@@ -375,7 +375,7 @@ class TagMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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->assertStringContainsString('Laravel "#t6 Tag', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('#laravel', $response['data']['attributes']['content']);
|
$this->assertEquals('#laravel', $response['data']['attributes']['content']);
|
||||||
|
@@ -85,7 +85,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('@POTATO$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@potato', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@potato', $response['data']['attributes']['content']);
|
||||||
@@ -118,7 +118,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"POTATO$"#3', $response['data']['attributes']['content']);
|
$this->assertEquals('@"POTATO$"#3', $response['data']['attributes']['content']);
|
||||||
@@ -149,7 +149,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
|
||||||
@@ -180,7 +180,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
|
||||||
@@ -211,7 +211,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('@FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"franzofflarum"#82', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"franzofflarum"#82', $response['data']['attributes']['content']);
|
||||||
@@ -242,7 +242,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('@TOBY$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringNotContainsString('@FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
$this->assertStringNotContainsString('@FRANZOFFLARUM$', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -265,7 +265,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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('@TOBY$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -295,7 +295,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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$', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
|
$this->assertStringContainsString('UserMention', $response['data']['attributes']['contentHtml']);
|
||||||
@@ -325,7 +325,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('@"POTATO$"#3', $response['data']['attributes']['content']);
|
||||||
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
|
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsUsers->find(3));
|
||||||
@@ -346,7 +346,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"'.$deleted_text.'"#2021', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"'.$deleted_text.'"#2021', $response['data']['attributes']['content']);
|
||||||
@@ -380,7 +380,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringNotContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertNotEquals('@"Bad "#p6 User"#5', $response['data']['attributes']['content']);
|
$this->assertNotEquals('@"Bad "#p6 User"#5', $response['data']['attributes']['content']);
|
||||||
@@ -401,7 +401,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertStringContainsString('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
$this->assertStringContainsString('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
||||||
@@ -432,7 +432,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$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->assertStringContainsString('Bad "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
||||||
@@ -460,7 +460,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
||||||
@@ -488,7 +488,7 @@ class UserMentionsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$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 "#p6 User', $response['data']['attributes']['contentHtml']);
|
||||||
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
$this->assertEquals('@"Bad _ User"#5', $response['data']['attributes']['content']);
|
||||||
|
@@ -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
|
||||||
|
]) !!}
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
8
extensions/mentions/views/emails/postMentioned.blade.php
Normal file
8
extensions/mentions/views/emails/postMentioned.blade.php
Normal 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
|
||||||
|
]) !!}
|
7
extensions/mentions/views/emails/userMentioned.blade.php
Normal file
7
extensions/mentions/views/emails/userMentioned.blade.php
Normal 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
|
||||||
|
]) !!}
|
2
extensions/nicknames/js/dist/forum.js
generated
vendored
2
extensions/nicknames/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/nicknames/js/dist/forum.js.map
generated
vendored
2
extensions/nicknames/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -2,7 +2,6 @@ import app from 'flarum/forum/app';
|
|||||||
import Modal from 'flarum/common/components/Modal';
|
import Modal from 'flarum/common/components/Modal';
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import Stream from 'flarum/common/utils/Stream';
|
import Stream from 'flarum/common/utils/Stream';
|
||||||
import Form from '@flarum/core/src/common/components/Form';
|
|
||||||
|
|
||||||
export default class NicknameModal extends Modal {
|
export default class NicknameModal extends Modal {
|
||||||
oninit(vnode) {
|
oninit(vnode) {
|
||||||
@@ -21,16 +20,16 @@ export default class NicknameModal extends Modal {
|
|||||||
content() {
|
content() {
|
||||||
return (
|
return (
|
||||||
<div className="Modal-body">
|
<div className="Modal-body">
|
||||||
<Form className="Form--centered">
|
<div className="Form Form--centered">
|
||||||
<div className="Form-group">
|
<div className="Form-group">
|
||||||
<input type="text" autocomplete="off" name="nickname" className="FormControl" bidi={this.nickname} disabled={this.loading} />
|
<input type="text" autocomplete="off" name="nickname" className="FormControl" bidi={this.nickname} disabled={this.loading} />
|
||||||
</div>
|
</div>
|
||||||
<div className="Form-group Form-controls">
|
<div className="Form-group">
|
||||||
<Button className="Button Button--primary Button--block" type="submit" loading={this.loading}>
|
<Button className="Button Button--primary Button--block" type="submit" loading={this.loading}>
|
||||||
{app.translator.trans('flarum-nicknames.forum.change_nickname.submit_button')}
|
{app.translator.trans('flarum-nicknames.forum.change_nickname.submit_button')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ class RegisterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->extension('flarum-nicknames');
|
$this->extension('flarum-nicknames');
|
||||||
$this->extend(
|
$this->extend(
|
||||||
(new Extend\Csrf)->exemptRoute('register')
|
(new Extend\Csrf)->exemptRoute('forum.register')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
extensions/package-manager/js/dist/admin.js
generated
vendored
2
extensions/package-manager/js/dist/admin.js
generated
vendored
File diff suppressed because one or more lines are too long
2
extensions/package-manager/js/dist/admin.js.map
generated
vendored
2
extensions/package-manager/js/dist/admin.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@ import type Mithril from 'mithril';
|
|||||||
import app from 'flarum/admin/app';
|
import app from 'flarum/admin/app';
|
||||||
import Component, { ComponentAttrs } from 'flarum/common/Component';
|
import Component, { ComponentAttrs } from 'flarum/common/Component';
|
||||||
import classList from 'flarum/common/utils/classList';
|
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 Tooltip from 'flarum/common/components/Tooltip';
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import { Extension } from 'flarum/admin/AdminApplication';
|
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}>
|
<div className="PackageManager-extension-icon ExtensionIcon" style={extension.icon}>
|
||||||
{extension.icon ? <Icon name={extension.icon.name} /> : ''}
|
{extension.icon ? icon(extension.icon.name) : ''}
|
||||||
</div>
|
</div>
|
||||||
<div className="PackageManager-extension-info">
|
<div className="PackageManager-extension-info">
|
||||||
<div className="PackageManager-extension-name">{extension.extra['flarum-extension'].title}</div>
|
<div className="PackageManager-extension-name">{extension.extra['flarum-extension'].title}</div>
|
||||||
|
@@ -5,7 +5,7 @@ import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
|||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import Tooltip from 'flarum/common/components/Tooltip';
|
import Tooltip from 'flarum/common/components/Tooltip';
|
||||||
import { Extension } from 'flarum/admin/AdminApplication';
|
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 ItemList from 'flarum/common/utils/ItemList';
|
||||||
import extractText from 'flarum/common/utils/extractText';
|
import extractText from 'flarum/common/utils/extractText';
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ export default class QueueSection extends Component<{}> {
|
|||||||
return extension ? (
|
return extension ? (
|
||||||
<div className="PackageManager-queueTable-package">
|
<div className="PackageManager-queueTable-package">
|
||||||
<div className="PackageManager-queueTable-package-icon ExtensionIcon" style={extension.icon}>
|
<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>
|
||||||
<div className="PackageManager-queueTable-package-details">
|
<div className="PackageManager-queueTable-package-details">
|
||||||
<span className="PackageManager-queueTable-package-title">{extension.extra['flarum-extension'].title}</span>
|
<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 {
|
operationIcon(operation: TaskOperations): Mithril.Children {
|
||||||
const iconName = {
|
return icon(
|
||||||
update_check: 'fas fa-sync-alt',
|
{
|
||||||
update_major: 'fas fa-play',
|
update_check: 'fas fa-sync-alt',
|
||||||
update_minor: 'fas fa-play',
|
update_major: 'fas fa-play',
|
||||||
update_global: 'fas fa-play',
|
update_minor: 'fas fa-play',
|
||||||
extension_install: 'fas fa-download',
|
update_global: 'fas fa-play',
|
||||||
extension_remove: 'fas fa-times',
|
extension_install: 'fas fa-download',
|
||||||
extension_update: 'fas fa-arrow-alt-circle-up',
|
extension_remove: 'fas fa-times',
|
||||||
why_not: 'fas fa-exclamation-circle',
|
extension_update: 'fas fa-arrow-alt-circle-up',
|
||||||
}[operation];
|
why_not: 'fas fa-exclamation-circle',
|
||||||
|
}[operation]
|
||||||
return <Icon name={iconName} />;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,22 +9,22 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\CheckForUpdates;
|
use Flarum\PackageManager\Command\CheckForUpdates;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
|
@@ -9,23 +9,23 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\GlobalUpdate;
|
use Flarum\PackageManager\Command\GlobalUpdate;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ use Flarum\Http\RequestUtil;
|
|||||||
use Flarum\Http\UrlGenerator;
|
use Flarum\Http\UrlGenerator;
|
||||||
use Flarum\PackageManager\Api\Serializer\TaskSerializer;
|
use Flarum\PackageManager\Api\Serializer\TaskSerializer;
|
||||||
use Flarum\PackageManager\Task\TaskRepository;
|
use Flarum\PackageManager\Task\TaskRepository;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Illuminate\Http\Request;
|
||||||
use Tobscure\JsonApi\Document;
|
use Tobscure\JsonApi\Document;
|
||||||
|
|
||||||
class ListTasksController extends AbstractListController
|
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);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
@@ -48,8 +48,8 @@ class ListTasksController extends AbstractListController
|
|||||||
$document->addMeta('total', (string) $total);
|
$document->addMeta('total', (string) $total);
|
||||||
|
|
||||||
$document->addPaginationLinks(
|
$document->addPaginationLinks(
|
||||||
$this->url->to('api')->route('package-manager.tasks.index'),
|
$this->url->route('api.package-manager.tasks.index'),
|
||||||
$request->getQueryParams(),
|
$request->query(),
|
||||||
$offset,
|
$offset,
|
||||||
$limit,
|
$limit,
|
||||||
$total
|
$total
|
||||||
|
@@ -9,27 +9,26 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\MajorUpdate;
|
use Flarum\PackageManager\Command\MajorUpdate;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$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(
|
$response = $this->bus->dispatch(
|
||||||
new MajorUpdate($actor, $dryRun)
|
new MajorUpdate($actor, $dryRun)
|
||||||
|
@@ -9,23 +9,23 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\MinorUpdate;
|
use Flarum\PackageManager\Command\MinorUpdate;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
|
|
||||||
|
@@ -9,30 +9,28 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\RemoveExtension;
|
use Flarum\PackageManager\Command\RemoveExtension;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request, int $id): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
$extensionId = Arr::get($request->getQueryParams(), 'id');
|
|
||||||
|
|
||||||
$response = $this->bus->dispatch(
|
$response = $this->bus->dispatch(
|
||||||
new RemoveExtension($actor, $extensionId)
|
new RemoveExtension($actor, $id)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response->queueJobs
|
return $response->queueJobs
|
||||||
|
@@ -9,26 +9,25 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\RequireExtension;
|
use Flarum\PackageManager\Command\RequireExtension;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
$package = Arr::get($request->getParsedBody(), 'data.package');
|
$package = $request->json('data.package');
|
||||||
|
|
||||||
$response = $this->bus->dispatch(
|
$response = $this->bus->dispatch(
|
||||||
new RequireExtension($actor, $package)
|
new RequireExtension($actor, $package)
|
||||||
|
@@ -9,30 +9,28 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\UpdateExtension;
|
use Flarum\PackageManager\Command\UpdateExtension;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\EmptyResponse;
|
use Laminas\Diactoros\Response\EmptyResponse;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request, int $id): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
$extensionId = Arr::get($request->getQueryParams(), 'id');
|
|
||||||
|
|
||||||
$response = $this->bus->dispatch(
|
$response = $this->bus->dispatch(
|
||||||
new UpdateExtension($actor, $extensionId)
|
new UpdateExtension($actor, $id)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $response->queueJobs
|
return $response->queueJobs
|
||||||
|
@@ -9,27 +9,26 @@
|
|||||||
|
|
||||||
namespace Flarum\PackageManager\Api\Controller;
|
namespace Flarum\PackageManager\Api\Controller;
|
||||||
|
|
||||||
|
use Flarum\Http\Controller\AbstractController;
|
||||||
use Flarum\Http\RequestUtil;
|
use Flarum\Http\RequestUtil;
|
||||||
use Flarum\PackageManager\Command\WhyNot;
|
use Flarum\PackageManager\Command\WhyNot;
|
||||||
use Flarum\PackageManager\Job\Dispatcher;
|
use Flarum\PackageManager\Job\Dispatcher;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Http\Request;
|
||||||
use Laminas\Diactoros\Response\JsonResponse;
|
use Laminas\Diactoros\Response\JsonResponse;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
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(
|
public function __construct(
|
||||||
protected Dispatcher $bus
|
protected Dispatcher $bus
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
public function __invoke(Request $request): ResponseInterface
|
||||||
{
|
{
|
||||||
$actor = RequestUtil::getActor($request);
|
$actor = RequestUtil::getActor($request);
|
||||||
$package = Arr::get($request->getParsedBody(), 'data.package', '');
|
$package = $request->json('data.package', '');
|
||||||
$version = Arr::get($request->getParsedBody(), 'data.version', '*');
|
$version = $request->json('data.version', '*');
|
||||||
|
|
||||||
$whyNot = $this->bus->sync()->dispatch(
|
$whyNot = $this->bus->sync()->dispatch(
|
||||||
new WhyNot($actor, $package, $version)
|
new WhyNot($actor, $package, $version)
|
||||||
|
@@ -24,7 +24,7 @@ class TaskSerializer extends AbstractSerializer
|
|||||||
{
|
{
|
||||||
if (! ($model instanceof Task)) {
|
if (! ($model instanceof Task)) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
$this::class.' can only serialize instances of '.Task::class
|
get_class($this).' can only serialize instances of '.Task::class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ class RequireExtensionHandler
|
|||||||
$packageName = $command->package;
|
$packageName = $command->package;
|
||||||
|
|
||||||
// Auto append :* if not requiring a specific version.
|
// Auto append :* if not requiring a specific version.
|
||||||
if (! str_contains($packageName, ':')) {
|
if (strpos($packageName, ':') === false) {
|
||||||
$packageName .= ':*';
|
$packageName .= ':*';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ class TestCase extends \Flarum\Testing\integration\TestCase
|
|||||||
|
|
||||||
protected function errorDetails(ResponseInterface $response): array
|
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] ?? []) : [];
|
return $json['errors'] ? ($json['errors'][0] ?? []) : [];
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user