mirror of
https://github.com/flarum/core.git
synced 2025-08-13 20:04:24 +02:00
Compare commits
17 Commits
dk/likes/l
...
v1.4.0
Author | SHA1 | Date | |
---|---|---|---|
|
556d461cfb | ||
|
6cfebe381a | ||
|
8ab2827f4c | ||
|
024155a608 | ||
|
4da21463c1 | ||
|
abc12b4ba5 | ||
|
d8d4eae9f5 | ||
|
d82a73feed | ||
|
ab6cee1a25 | ||
|
2e840dc73d | ||
|
ae9139bd73 | ||
|
2e3d6dfa2c | ||
|
7cd28710bc | ||
|
bc1d6f9e91 | ||
|
bf4c543692 | ||
|
709c5566bb | ||
|
9a62c32c28 |
@@ -6,6 +6,6 @@ jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/approval
|
||||
|
2
.github/workflows/flarum-likes-backend.yml
vendored
2
.github/workflows/flarum-likes-backend.yml
vendored
@@ -6,6 +6,6 @@ jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/likes
|
||||
|
2
.github/workflows/flarum-sticky-backend.yml
vendored
2
.github/workflows/flarum-sticky-backend.yml
vendored
@@ -6,6 +6,6 @@ jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/sticky
|
||||
|
@@ -6,6 +6,6 @@ jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/subscriptions
|
||||
|
2
.github/workflows/flarum-suspend-backend.yml
vendored
2
.github/workflows/flarum-suspend-backend.yml
vendored
@@ -6,6 +6,6 @@ jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/suspend
|
||||
|
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,5 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
## [1.4.0](https://github.com/flarum/framework/compare/v1.3.1...v1.4.0)
|
||||
|
||||
### Added
|
||||
- `created_at` and `updated_at` columns added to several tables (https://github.com/flarum/framework/pull/3435)
|
||||
- Priorities added to AdminNav links (https://github.com/flarum/framework/pull/3453)
|
||||
- `app.translator` allows retrieving and setting locale (https://github.com/flarum/framework/pull/3451)
|
||||
- Extensions can now declare custom settings components for use with `buildSettingComponent` (https://github.com/flarum/framework/pull/3494)
|
||||
- Implement extensibility on `rel` and `target` attributes on links (https://github.com/flarum/framework/pull/3455)
|
||||
- New backend tests were added to some of the bundled extensions (https://github.com/flarum/framework/issues/3508)
|
||||
|
||||
### Changed
|
||||
- Split boot script for Flarum in HTML footer into two parts for CSP hashing (https://github.com/flarum/framework/pull/3461)
|
||||
- Split asset compilation by giving assembling compilers its own method (https://github.com/flarum/framework/pull/3446)
|
||||
- Increase visibility of Component typescript class for better extensibility (https://github.com/flarum/framework/pull/3437)
|
||||
|
||||
### Fixed
|
||||
- Mentioning an event post breaks the notification dropdown (https://github.com/flarum/framework/pull/3493)
|
||||
- Suspension modal shows after suspension is over (https://github.com/flarum/framework/pull/3449)
|
||||
- CLI based installations don't exit with an error code on failure (https://github.com/flarum/framework/pull/3452)
|
||||
- Tabbing through dropdown controls doesn't make them visible (https://github.com/flarum/framework/pull/3450)
|
||||
- Requiring zero tags on new discussions forces the user to select tags (https://github.com/flarum/framework/pull/3448)
|
||||
- Long topic titles in the notification list don't overflow (https://github.com/flarum/framework/pull/3500)
|
||||
- Subtags of tags the user has access to are visible even if these are not accessible (https://github.com/flarum/framework/pull/3419)
|
||||
- `assertAdmin` tests access based on wrong gate ability (https://github.com/flarum/framework/pull/3501)
|
||||
- Increasing the composer header size causes elements to slip underneath (https://github.com/flarum/framework/pull/3502)
|
||||
- The profile mentions tab errors when sorting by `created_at` (https://github.com/flarum/framework/pull/3506)
|
||||
|
||||
## [1.3.1](https://github.com/flarum/framework/compare/v1.3.0...v1.3.1)
|
||||
|
||||
### Changed
|
||||
|
@@ -29,8 +29,8 @@
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"source": "https://github.com/flarum/core",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/framework",
|
||||
"docs": "https://docs.flarum.org",
|
||||
"forum": "https://discuss.flarum.org",
|
||||
"chat": "https://flarum.org/chat"
|
||||
@@ -86,7 +86,6 @@
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">=7.3",
|
||||
"axy/sourcemap": "^0.1.4",
|
||||
"components/font-awesome": "^5.14.0",
|
||||
"composer/composer": "^2.0",
|
||||
"dflydev/fig-cookies": "^3.0.0",
|
||||
@@ -127,6 +126,8 @@
|
||||
"psr/http-server-middleware": "^1.0",
|
||||
"pusher/pusher-php-server": "^2.2",
|
||||
"s9e/text-formatter": "^2.3.6",
|
||||
"sycho/json-api": "^0.5.0",
|
||||
"sycho/sourcemap": "^2.0.0",
|
||||
"symfony/config": "^5.2.2",
|
||||
"symfony/console": "^5.2.2",
|
||||
"symfony/event-dispatcher": "^5.2.2",
|
||||
@@ -134,7 +135,6 @@
|
||||
"symfony/polyfill-intl-messageformatter": "^1.22.0",
|
||||
"symfony/translation": "^5.1.5",
|
||||
"symfony/yaml": "^5.2.2",
|
||||
"tobscure/json-api": "^0.3.0",
|
||||
"wikimedia/less.php": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
|
20
extensions/akismet/.gitattributes
vendored
Normal file
20
extensions/akismet/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/akismet",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3",
|
||||
"flarum/core": "^1.4",
|
||||
"flarum/approval": "^1.2",
|
||||
"guzzlehttp/guzzle": "^7.4"
|
||||
},
|
||||
|
20
extensions/approval/.gitattributes
vendored
Normal file
20
extensions/approval/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/approval",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3",
|
||||
"flarum/core": "^1.4",
|
||||
"flarum/flags": "^1.2"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -52,7 +52,7 @@
|
||||
"prettier": true,
|
||||
"typescript": false,
|
||||
"bundlewatch": false,
|
||||
"backendTesting": false,
|
||||
"backendTesting": true,
|
||||
"editorConfig": true,
|
||||
"styleci": true
|
||||
}
|
||||
@@ -65,5 +65,28 @@
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
"prefer-stable": true,
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flarum\\Approval\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@test:unit",
|
||||
"@test:integration"
|
||||
],
|
||||
"test:unit": "phpunit -c tests/phpunit.unit.xml",
|
||||
"test:integration": "phpunit -c tests/phpunit.integration.xml",
|
||||
"test:setup": "@php tests/integration/setup.php"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Runs all tests.",
|
||||
"test:unit": "Runs all unit tests.",
|
||||
"test:integration": "Runs all integration tests.",
|
||||
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/testing": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace Flarum\Approval\Access;
|
||||
|
||||
use Closure;
|
||||
use Flarum\Discussion\Discussion;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -39,14 +40,23 @@ class ScopePrivatePostVisibility
|
||||
});
|
||||
}
|
||||
|
||||
private function discussionWhereCanApprovePosts(User $actor)
|
||||
/**
|
||||
* Looks if the actor has permission to approve posts,
|
||||
* within the discussion which the post is a part of.
|
||||
*
|
||||
* For example, the tags extension,
|
||||
* turns the `approvePosts` ability into per tag basis.
|
||||
*/
|
||||
private function discussionWhereCanApprovePosts(User $actor): Closure
|
||||
{
|
||||
return function ($query) use ($actor) {
|
||||
$query->selectRaw('1')
|
||||
->from('discussions')
|
||||
->whereColumn('discussions.id', 'posts.discussion_id')
|
||||
->where(function ($query) use ($actor) {
|
||||
Discussion::query()->setQuery($query)->whereVisibleTo($actor, 'approvePosts');
|
||||
$query->whereRaw('1 != 1')->orWhere(function ($query) use ($actor) {
|
||||
Discussion::query()->setQuery($query)->whereVisibleTo($actor, 'approvePosts');
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
0
extensions/approval/tests/fixtures/.gitkeep
vendored
Normal file
0
extensions/approval/tests/fixtures/.gitkeep
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Approval\Tests\integration;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
trait InteractsWithUnapprovedContent
|
||||
{
|
||||
protected function prepareUnapprovedDatabaseContent()
|
||||
{
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
$this->normalUser(),
|
||||
['id' => 3, 'username' => 'acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
|
||||
['id' => 4, 'username' => 'luceos', 'email' => 'luceos@machine.local', 'is_email_confirmed' => 1],
|
||||
],
|
||||
'discussions' => [
|
||||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 1, 'comment_count' => 1, 'is_approved' => 1, 'is_private' => 0],
|
||||
['id' => 2, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 2, 'comment_count' => 1, 'is_approved' => 0, 'is_private' => 1],
|
||||
['id' => 3, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 3, 'comment_count' => 1, 'is_approved' => 0, 'is_private' => 1],
|
||||
['id' => 4, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 4, 'comment_count' => 1, 'is_approved' => 1, 'is_private' => 0],
|
||||
['id' => 5, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 5, 'comment_count' => 1, 'is_approved' => 1, 'is_private' => 0],
|
||||
['id' => 6, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 6, 'comment_count' => 1, 'is_approved' => 0, 'is_private' => 1],
|
||||
['id' => 7, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 4, 'first_post_id' => 7, 'comment_count' => 1, 'is_approved' => 1, 'is_private' => 0],
|
||||
],
|
||||
'posts' => [
|
||||
['id' => 1, 'discussion_id' => 1, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 2, 'discussion_id' => 2, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 3, 'discussion_id' => 3, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 4, 'discussion_id' => 4, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 5, 'discussion_id' => 5, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 6, 'discussion_id' => 6, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
['id' => 7, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 1],
|
||||
|
||||
['id' => 8, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 2],
|
||||
['id' => 9, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 1, 'is_approved' => 0, 'number' => 3],
|
||||
['id' => 10, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 4],
|
||||
['id' => 11, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 1, 'is_approved' => 0, 'number' => 5],
|
||||
],
|
||||
'groups' => [
|
||||
['id' => 4, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0]
|
||||
],
|
||||
'group_user' => [
|
||||
['user_id' => 3, 'group_id' => 4]
|
||||
],
|
||||
'group_permission' => [
|
||||
['permission' => 'discussion.approvePosts', 'group_id' => 4]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* null: Guest, 2: Normal User.
|
||||
*/
|
||||
public function unallowedUsers(): array
|
||||
{
|
||||
return [[null], [2]];
|
||||
}
|
||||
|
||||
/**
|
||||
* 1: Admin, 3: Permission Given, 4: Discussions Author.
|
||||
*/
|
||||
public function allowedUsers(): array
|
||||
{
|
||||
return [[1], [3], [4]];
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Approval\Tests\integration\api;
|
||||
|
||||
use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ListDiscussionsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use InteractsWithUnapprovedContent;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-approval');
|
||||
|
||||
$this->prepareUnapprovedDatabaseContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unallowedUsers
|
||||
* @test
|
||||
*/
|
||||
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions', compact('authenticatedAs'))
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([1, 4, 5, 7], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider allowedUsers
|
||||
* @test
|
||||
*/
|
||||
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions', compact('authenticatedAs'))
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6, 7], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
}
|
74
extensions/approval/tests/integration/api/ListPostsTest.php
Normal file
74
extensions/approval/tests/integration/api/ListPostsTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Approval\Tests\integration\api;
|
||||
|
||||
use Flarum\Approval\Tests\integration\InteractsWithUnapprovedContent;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ListPostsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use InteractsWithUnapprovedContent;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-approval');
|
||||
|
||||
$this->prepareUnapprovedDatabaseContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unallowedUsers
|
||||
* @test
|
||||
*/
|
||||
public function can_only_see_approved_if_not_allowed_to_approve(?int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this
|
||||
->request('GET', '/api/posts', compact('authenticatedAs'))
|
||||
->withQueryParams([
|
||||
'filter' => [
|
||||
'discussion' => 7
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([7, 8, 10], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider allowedUsers
|
||||
* @test
|
||||
*/
|
||||
public function can_see_unapproved_if_allowed_to_approve(int $authenticatedAs)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this
|
||||
->request('GET', '/api/posts', compact('authenticatedAs'))
|
||||
->withQueryParams([
|
||||
'filter' => [
|
||||
'discussion' => 7
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([7, 8, 9, 10, 11], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
}
|
16
extensions/approval/tests/integration/setup.php
Normal file
16
extensions/approval/tests/integration/setup.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
|
||||
$setup->run();
|
25
extensions/approval/tests/phpunit.integration.xml
Normal file
25
extensions/approval/tests/phpunit.integration.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Integration Tests">
|
||||
<directory suffix="Test.php">./integration</directory>
|
||||
<exclude>./integration/tmp</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
27
extensions/approval/tests/phpunit.unit.xml
Normal file
27
extensions/approval/tests/phpunit.unit.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Unit Tests">
|
||||
<directory suffix="Test.php">./unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
0
extensions/approval/tests/unit/.gitkeep
Normal file
0
extensions/approval/tests/unit/.gitkeep
Normal file
20
extensions/bbcode/.gitattributes
vendored
Normal file
20
extensions/bbcode/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/bbcode",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
20
extensions/embed/.gitattributes
vendored
Normal file
20
extensions/embed/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/embed",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/emoji/.gitattributes
vendored
Normal file
20
extensions/emoji/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/emoji",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
20
extensions/flags/.gitattributes
vendored
Normal file
20
extensions/flags/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/flags",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/lang-english/.gitattributes
vendored
Normal file
20
extensions/lang-english/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
20
extensions/likes/.gitattributes
vendored
Normal file
20
extensions/likes/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/likes",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -51,7 +51,7 @@
|
||||
"prettier": true,
|
||||
"typescript": false,
|
||||
"bundlewatch": false,
|
||||
"backendTesting": false,
|
||||
"backendTesting": true,
|
||||
"editorConfig": true,
|
||||
"styleci": true
|
||||
}
|
||||
@@ -64,5 +64,28 @@
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
"prefer-stable": true,
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flarum\\Likes\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@test:unit",
|
||||
"@test:integration"
|
||||
],
|
||||
"test:unit": "phpunit -c tests/phpunit.unit.xml",
|
||||
"test:integration": "phpunit -c tests/phpunit.integration.xml",
|
||||
"test:setup": "@php tests/integration/setup.php"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Runs all tests.",
|
||||
"test:unit": "Runs all unit tests.",
|
||||
"test:integration": "Runs all integration tests.",
|
||||
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/testing": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
@@ -7,12 +7,14 @@
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Likes;
|
||||
|
||||
use Flarum\Api\Controller;
|
||||
use Flarum\Api\Serializer\BasicUserSerializer;
|
||||
use Flarum\Api\Serializer\PostSerializer;
|
||||
use Flarum\Extend;
|
||||
use Flarum\Likes\Event\PostWasLiked;
|
||||
use Flarum\Likes\Event\PostWasUnliked;
|
||||
use Flarum\Likes\Listener;
|
||||
use Flarum\Likes\Notification\PostLikedBlueprint;
|
||||
use Flarum\Post\Event\Deleted;
|
||||
use Flarum\Post\Event\Saving;
|
||||
use Flarum\Post\Post;
|
||||
@@ -27,54 +29,34 @@ return [
|
||||
->js(__DIR__.'/js/dist/admin.js'),
|
||||
|
||||
(new Extend\Model(Post::class))
|
||||
->belongsToMany('likes', User::class, 'post_likes', 'post_id', 'user_id')
|
||||
->relationship('recentLikes', Model\RecentLikesRelationship::class),
|
||||
->belongsToMany('likes', User::class, 'post_likes', 'post_id', 'user_id'),
|
||||
|
||||
new Extend\Locales(__DIR__.'/locale'),
|
||||
|
||||
(new Extend\Notification())
|
||||
->type(Notification\PostLikedBlueprint::class, PostSerializer::class, ['alert']),
|
||||
->type(PostLikedBlueprint::class, PostSerializer::class, ['alert']),
|
||||
|
||||
(new Extend\ApiSerializer(PostSerializer::class))
|
||||
->relationship('recentLikes', Api\RecentLikesRelationship::class)
|
||||
->attributes(function (PostSerializer $serializer, $model, $attributes) {
|
||||
$actor = $serializer->getActor();
|
||||
$model->loadCount('likes');
|
||||
$attributes['likesCount'] = $model->likes_count;
|
||||
$attributes['likedByActor'] = $actor && $model->likes()->where('id', $actor->id)->exists();
|
||||
|
||||
return $attributes;
|
||||
})
|
||||
->hasMany('likes', BasicUserSerializer::class)
|
||||
->attribute('canLike', function (PostSerializer $serializer, $model) {
|
||||
return $serializer->getActor()->can('like', $model);
|
||||
return (bool) $serializer->getActor()->can('like', $model);
|
||||
}),
|
||||
|
||||
(new Extend\ApiController(Controller\ShowDiscussionController::class))
|
||||
->addOptionalInclude('posts.likes')
|
||||
->addInclude('posts.recentLikes')
|
||||
->load('posts.recentLikes'),
|
||||
->addInclude('posts.likes'),
|
||||
|
||||
(new Extend\ApiController(Controller\ListPostsController::class))
|
||||
->addOptionalInclude('likes')
|
||||
->addInclude('recentLikes')
|
||||
->load('posts.recentLikes'),
|
||||
->addInclude('likes'),
|
||||
(new Extend\ApiController(Controller\ShowPostController::class))
|
||||
->addOptionalInclude('likes')
|
||||
->addInclude('recentLikes')
|
||||
->load('posts.recentLikes'),
|
||||
->addInclude('likes'),
|
||||
(new Extend\ApiController(Controller\CreatePostController::class))
|
||||
->addOptionalInclude('likes')
|
||||
->addInclude('recentLikes')
|
||||
->load('posts.recentLikes'),
|
||||
->addInclude('likes'),
|
||||
(new Extend\ApiController(Controller\UpdatePostController::class))
|
||||
->addOptionalInclude('likes')
|
||||
->addInclude('recentLikes')
|
||||
->load('posts.recentLikes'),
|
||||
->addInclude('likes'),
|
||||
|
||||
(new Extend\Event())
|
||||
->listen(Event\PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
|
||||
->listen(Event\PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
|
||||
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
|
||||
->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
|
||||
->listen(Deleted::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsDeleted'])
|
||||
->listen(Saving::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsSaving']),
|
||||
];
|
||||
|
120
extensions/likes/js/dist/admin.js
generated
vendored
120
extensions/likes/js/dist/admin.js
generated
vendored
@@ -1,120 +1,2 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ // runtime can't be in strict mode because a global variable is assign and maybe created.
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./src/admin/index.js":
|
||||
/*!****************************!*\
|
||||
!*** ./src/admin/index.js ***!
|
||||
\****************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var flarum_admin_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/admin/app */ "flarum/admin/app");
|
||||
/* harmony import */ var flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_admin_app__WEBPACK_IMPORTED_MODULE_0__);
|
||||
|
||||
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('flarum-likes', function () {
|
||||
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().extensionData["for"]('flarum-likes').registerPermission({
|
||||
icon: 'far fa-thumbs-up',
|
||||
label: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('flarum-likes.admin.permissions.like_posts_label'),
|
||||
permission: 'discussion.likePosts'
|
||||
}, 'reply');
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/admin/app":
|
||||
/*!**************************************************!*\
|
||||
!*** external "flarum.core.compat['admin/app']" ***!
|
||||
\**************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['admin/app'];
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (exports, definition) => {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (exports) => {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
||||
(() => {
|
||||
"use strict";
|
||||
/*!******************!*\
|
||||
!*** ./admin.js ***!
|
||||
\******************/
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _src_admin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/admin */ "./src/admin/index.js");
|
||||
|
||||
})();
|
||||
|
||||
module.exports = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
(()=>{var e={n:r=>{var o=r&&r.__esModule?()=>r.default:()=>r;return e.d(o,{a:o}),o},d:(r,o)=>{for(var t in o)e.o(o,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:o[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};(()=>{"use strict";e.r(r);const o=flarum.core.compat["admin/app"];var t=e.n(o);t().initializers.add("flarum-likes",(function(){t().extensionData.for("flarum-likes").registerPermission({icon:"far fa-thumbs-up",label:t().translator.trans("flarum-likes.admin.permissions.like_posts_label"),permission:"discussion.likePosts"},"reply")}))})(),module.exports=r})();
|
||||
//# sourceMappingURL=admin.js.map
|
2
extensions/likes/js/dist/admin.js.map
generated
vendored
2
extensions/likes/js/dist/admin.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"file":"admin.js","mappings":";;;;;;;;;;;;;;AAAA;AAEAA,wEAAA,CAAqB,cAArB,EAAqC,YAAM;AACzCA,EAAAA,4EAAA,CAAsB,cAAtB,EAAsCI,kBAAtC,CACE;AACEC,IAAAA,IAAI,EAAE,kBADR;AAEEC,IAAAA,KAAK,EAAEN,wEAAA,CAAqB,iDAArB,CAFT;AAGES,IAAAA,UAAU,EAAE;AAHd,GADF,EAME,OANF;AAQD,CATD;;;;;;;;;;;ACFA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D","sources":["webpack://@flarum/likes/./src/admin/index.js","webpack://@flarum/likes/external root \"flarum.core.compat['admin/app']\"","webpack://@flarum/likes/webpack/bootstrap","webpack://@flarum/likes/webpack/runtime/compat get default export","webpack://@flarum/likes/webpack/runtime/define property getters","webpack://@flarum/likes/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/likes/webpack/runtime/make namespace object","webpack://@flarum/likes/./admin.js"],"sourcesContent":["import app from 'flarum/admin/app';\n\napp.initializers.add('flarum-likes', () => {\n app.extensionData.for('flarum-likes').registerPermission(\n {\n icon: 'far fa-thumbs-up',\n label: app.translator.trans('flarum-likes.admin.permissions.like_posts_label'),\n permission: 'discussion.likePosts',\n },\n 'reply'\n );\n});\n","module.exports = flarum.core.compat['admin/app'];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './src/admin';\n"],"names":["app","initializers","add","extensionData","registerPermission","icon","label","translator","trans","permission"],"sourceRoot":""}
|
||||
{"version":3,"file":"admin.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,+BCLvD,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCExDC,IAAAA,aAAAA,IAAqB,gBAAgB,WACnCA,IAAAA,cAAAA,IAAsB,gBAAgBC,mBACpC,CACEC,KAAM,mBACNC,MAAOH,IAAAA,WAAAA,MAAqB,mDAC5BI,WAAY,wBAEd,a","sources":["webpack://@flarum/likes/webpack/bootstrap","webpack://@flarum/likes/webpack/runtime/compat get default export","webpack://@flarum/likes/webpack/runtime/define property getters","webpack://@flarum/likes/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/likes/webpack/runtime/make namespace object","webpack://@flarum/likes/external root \"flarum.core.compat['admin/app']\"","webpack://@flarum/likes/./src/admin/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/app'];","import app from 'flarum/admin/app';\n\napp.initializers.add('flarum-likes', () => {\n app.extensionData.for('flarum-likes').registerPermission(\n {\n icon: 'far fa-thumbs-up',\n label: app.translator.trans('flarum-likes.admin.permissions.like_posts_label'),\n permission: 'discussion.likePosts',\n },\n 'reply'\n );\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","registerPermission","icon","label","permission"],"sourceRoot":""}
|
622
extensions/likes/js/dist/forum.js
generated
vendored
622
extensions/likes/js/dist/forum.js
generated
vendored
@@ -1,622 +1,2 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ // runtime can't be in strict mode because a global variable is assign and maybe created.
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./src/forum/addLikeAction.js":
|
||||
/*!************************************!*\
|
||||
!*** ./src/forum/addLikeAction.js ***!
|
||||
\************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/components/Button */ "flarum/common/components/Button");
|
||||
/* harmony import */ var flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/forum/components/CommentPost */ "flarum/forum/components/CommentPost");
|
||||
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3__);
|
||||
|
||||
|
||||
|
||||
|
||||
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
|
||||
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3___default().prototype), 'actionItems', function (items) {
|
||||
var post = this.attrs.post;
|
||||
if (post.isHidden() || !post.canLike()) return;
|
||||
var likes = post.likes();
|
||||
var isLiked = (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) && likes && likes.some(function (user) {
|
||||
return user === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user);
|
||||
});
|
||||
items.add('like', flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2___default().component({
|
||||
className: 'Button Button--link',
|
||||
onclick: function onclick() {
|
||||
isLiked = !isLiked;
|
||||
post.save({
|
||||
isLiked: isLiked
|
||||
}); // We've saved the fact that we do or don't like the post, but in order
|
||||
// to provide instantaneous feedback to the user, we'll need to add or
|
||||
// remove the like from the relationship data manually.
|
||||
|
||||
var data = post.data.relationships.likes.data;
|
||||
data.some(function (like, i) {
|
||||
if (like.id === flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user.id()) {
|
||||
data.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (isLiked) {
|
||||
data.unshift({
|
||||
type: 'users',
|
||||
id: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user.id()
|
||||
});
|
||||
}
|
||||
}
|
||||
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link')));
|
||||
});
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/forum/addLikesList.js":
|
||||
/*!***********************************!*\
|
||||
!*** ./src/forum/addLikesList.js ***!
|
||||
\***********************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/forum/components/CommentPost */ "flarum/forum/components/CommentPost");
|
||||
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/components/Link */ "flarum/common/components/Link");
|
||||
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/common/helpers/punctuateSeries */ "flarum/common/helpers/punctuateSeries");
|
||||
/* harmony import */ var flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/common/helpers/username */ "flarum/common/helpers/username");
|
||||
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__);
|
||||
/* harmony import */ var flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! flarum/common/helpers/icon */ "flarum/common/helpers/icon");
|
||||
/* harmony import */ var flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6__);
|
||||
/* harmony import */ var _components_PostLikesModal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/PostLikesModal */ "./src/forum/components/PostLikesModal.js");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
|
||||
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2___default().prototype), 'footerItems', function (items) {
|
||||
var post = this.attrs.post;
|
||||
var likes = post.recentLikes();
|
||||
var count = post.likesCount();
|
||||
|
||||
if (likes && likes.length) {
|
||||
// the limit is dynamic through the backend, we only load those we need
|
||||
var limit = likes.length; // overLimit indicates there are more likes than the ones we render (and load)
|
||||
|
||||
var overLimit = count > likes.length; // Construct a list of names of users who have liked this post. Make sure the
|
||||
// current user is first in the list, and cap a maximum of 4 items.
|
||||
|
||||
var names = likes.filter(function (a) {
|
||||
return a !== (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user);
|
||||
}).slice(0, limit).map(function (user) {
|
||||
return m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
|
||||
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user(user)
|
||||
}, user === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) ? flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.you_text') : flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default()(user));
|
||||
});
|
||||
|
||||
if (post.likedByActor()) {
|
||||
names.unshift(m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
|
||||
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user((flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user))
|
||||
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.you_text')));
|
||||
} // If there are more users that we've run out of room to display, add a "x
|
||||
// others" name to the end of the list. Clicking on it will display a modal
|
||||
// with a full list of names.
|
||||
|
||||
|
||||
if (overLimit) {
|
||||
names.push(m("a", {
|
||||
href: "#",
|
||||
onclick: function onclick(e) {
|
||||
e.preventDefault();
|
||||
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().modal.show(_components_PostLikesModal__WEBPACK_IMPORTED_MODULE_7__["default"], {
|
||||
post: post
|
||||
});
|
||||
}
|
||||
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.others_link', {
|
||||
count: count - likes.length
|
||||
})));
|
||||
}
|
||||
|
||||
items.add('liked', m("div", {
|
||||
className: "Post-likedBy"
|
||||
}, flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6___default()('far fa-thumbs-up'), flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.liked_by' + (likes[0] === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) ? '_self' : '') + '_text', {
|
||||
count: names.length,
|
||||
users: flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4___default()(names)
|
||||
})));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/forum/components/PostLikedNotification.js":
|
||||
/*!*******************************************************!*\
|
||||
!*** ./src/forum/components/PostLikedNotification.js ***!
|
||||
\*******************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ PostLikedNotification)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/forum/components/Notification */ "flarum/forum/components/Notification");
|
||||
/* harmony import */ var flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/utils/string */ "flarum/common/utils/string");
|
||||
/* harmony import */ var flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var PostLikedNotification = /*#__PURE__*/function (_Notification) {
|
||||
(0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PostLikedNotification, _Notification);
|
||||
|
||||
function PostLikedNotification() {
|
||||
return _Notification.apply(this, arguments) || this;
|
||||
}
|
||||
|
||||
var _proto = PostLikedNotification.prototype;
|
||||
|
||||
_proto.icon = function icon() {
|
||||
return 'far fa-thumbs-up';
|
||||
};
|
||||
|
||||
_proto.href = function href() {
|
||||
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.post(this.attrs.notification.subject());
|
||||
};
|
||||
|
||||
_proto.content = function content() {
|
||||
var notification = this.attrs.notification;
|
||||
var user = notification.fromUser();
|
||||
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.notifications.post_liked_text', {
|
||||
user: user,
|
||||
count: 1
|
||||
});
|
||||
};
|
||||
|
||||
_proto.excerpt = function excerpt() {
|
||||
return (0,flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__.truncate)(this.attrs.notification.subject().contentPlain(), 200);
|
||||
};
|
||||
|
||||
return PostLikedNotification;
|
||||
}((flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2___default()));
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/forum/components/PostLikesModal.js":
|
||||
/*!************************************************!*\
|
||||
!*** ./src/forum/components/PostLikesModal.js ***!
|
||||
\************************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ PostLikesModal)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/components/Modal */ "flarum/common/components/Modal");
|
||||
/* harmony import */ var flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/components/Link */ "flarum/common/components/Link");
|
||||
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/common/helpers/avatar */ "flarum/common/helpers/avatar");
|
||||
/* harmony import */ var flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/common/helpers/username */ "flarum/common/helpers/username");
|
||||
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var PostLikesModal = /*#__PURE__*/function (_Modal) {
|
||||
(0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PostLikesModal, _Modal);
|
||||
|
||||
function PostLikesModal() {
|
||||
return _Modal.apply(this, arguments) || this;
|
||||
}
|
||||
|
||||
var _proto = PostLikesModal.prototype;
|
||||
|
||||
_proto.className = function className() {
|
||||
return 'PostLikesModal Modal--small';
|
||||
};
|
||||
|
||||
_proto.title = function title() {
|
||||
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post_likes.title');
|
||||
};
|
||||
|
||||
_proto.content = function content() {
|
||||
return m("div", {
|
||||
className: "Modal-body"
|
||||
}, m("ul", {
|
||||
className: "PostLikesModal-list"
|
||||
}, this.attrs.post.likes().map(function (user) {
|
||||
return m("li", null, m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
|
||||
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user(user)
|
||||
}, flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4___default()(user), " ", flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default()(user)));
|
||||
})));
|
||||
};
|
||||
|
||||
return PostLikesModal;
|
||||
}((flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2___default()));
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/forum/index.js":
|
||||
/*!****************************!*\
|
||||
!*** ./src/forum/index.js ***!
|
||||
\****************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
|
||||
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
|
||||
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/models/Post */ "flarum/common/models/Post");
|
||||
/* harmony import */ var flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var flarum_common_Model__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/Model */ "flarum/common/Model");
|
||||
/* harmony import */ var flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_Model__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/forum/components/NotificationGrid */ "flarum/forum/components/NotificationGrid");
|
||||
/* harmony import */ var flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony import */ var _addLikeAction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./addLikeAction */ "./src/forum/addLikeAction.js");
|
||||
/* harmony import */ var _addLikesList__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./addLikesList */ "./src/forum/addLikesList.js");
|
||||
/* harmony import */ var _components_PostLikedNotification__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/PostLikedNotification */ "./src/forum/components/PostLikedNotification.js");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().initializers.add('flarum-likes', function () {
|
||||
(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().notificationComponents.postLiked) = _components_PostLikedNotification__WEBPACK_IMPORTED_MODULE_7__["default"];
|
||||
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.canLike) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('canLike');
|
||||
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likes) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().hasMany('likes');
|
||||
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likesCount) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('likesCount');
|
||||
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.recentLikes) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().hasMany('recentLikes');
|
||||
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likedByActor) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('likedByActor');
|
||||
(0,_addLikeAction__WEBPACK_IMPORTED_MODULE_5__["default"])();
|
||||
(0,_addLikesList__WEBPACK_IMPORTED_MODULE_6__["default"])();
|
||||
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4___default().prototype), 'notificationTypes', function (items) {
|
||||
items.add('postLiked', {
|
||||
name: 'postLiked',
|
||||
icon: 'far fa-thumbs-up',
|
||||
label: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.settings.notify_post_liked_label')
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/Model":
|
||||
/*!*****************************************************!*\
|
||||
!*** external "flarum.core.compat['common/Model']" ***!
|
||||
\*****************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/Model'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/components/Button":
|
||||
/*!*****************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/components/Button']" ***!
|
||||
\*****************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/components/Button'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/components/Link":
|
||||
/*!***************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/components/Link']" ***!
|
||||
\***************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/components/Link'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/components/Modal":
|
||||
/*!****************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/components/Modal']" ***!
|
||||
\****************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/components/Modal'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/extend":
|
||||
/*!******************************************************!*\
|
||||
!*** external "flarum.core.compat['common/extend']" ***!
|
||||
\******************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/extend'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/helpers/avatar":
|
||||
/*!**************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/helpers/avatar']" ***!
|
||||
\**************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/helpers/avatar'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/helpers/icon":
|
||||
/*!************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/helpers/icon']" ***!
|
||||
\************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/helpers/icon'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/helpers/punctuateSeries":
|
||||
/*!***********************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/helpers/punctuateSeries']" ***!
|
||||
\***********************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/helpers/punctuateSeries'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/helpers/username":
|
||||
/*!****************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/helpers/username']" ***!
|
||||
\****************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/helpers/username'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/models/Post":
|
||||
/*!***********************************************************!*\
|
||||
!*** external "flarum.core.compat['common/models/Post']" ***!
|
||||
\***********************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/models/Post'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/common/utils/string":
|
||||
/*!************************************************************!*\
|
||||
!*** external "flarum.core.compat['common/utils/string']" ***!
|
||||
\************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['common/utils/string'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/forum/app":
|
||||
/*!**************************************************!*\
|
||||
!*** external "flarum.core.compat['forum/app']" ***!
|
||||
\**************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['forum/app'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/forum/components/CommentPost":
|
||||
/*!*********************************************************************!*\
|
||||
!*** external "flarum.core.compat['forum/components/CommentPost']" ***!
|
||||
\*********************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['forum/components/CommentPost'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/forum/components/Notification":
|
||||
/*!**********************************************************************!*\
|
||||
!*** external "flarum.core.compat['forum/components/Notification']" ***!
|
||||
\**********************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['forum/components/Notification'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "flarum/forum/components/NotificationGrid":
|
||||
/*!**************************************************************************!*\
|
||||
!*** external "flarum.core.compat['forum/components/NotificationGrid']" ***!
|
||||
\**************************************************************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = flarum.core.compat['forum/components/NotificationGrid'];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js":
|
||||
/*!*************************************************************************!*\
|
||||
!*** ../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***!
|
||||
\*************************************************************************/
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ _inheritsLoose)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setPrototypeOf.js */ "../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js");
|
||||
|
||||
function _inheritsLoose(subClass, superClass) {
|
||||
subClass.prototype = Object.create(superClass.prototype);
|
||||
subClass.prototype.constructor = subClass;
|
||||
(0,_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__["default"])(subClass, superClass);
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js":
|
||||
/*!**************************************************************************!*\
|
||||
!*** ../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js ***!
|
||||
\**************************************************************************/
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ _setPrototypeOf)
|
||||
/* harmony export */ });
|
||||
function _setPrototypeOf(o, p) {
|
||||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
||||
o.__proto__ = p;
|
||||
return o;
|
||||
};
|
||||
|
||||
return _setPrototypeOf(o, p);
|
||||
}
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (exports, definition) => {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (exports) => {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
|
||||
(() => {
|
||||
"use strict";
|
||||
/*!******************!*\
|
||||
!*** ./forum.js ***!
|
||||
\******************/
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _src_forum__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/forum */ "./src/forum/index.js");
|
||||
|
||||
})();
|
||||
|
||||
module.exports = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
(()=>{var t={n:o=>{var n=o&&o.__esModule?()=>o.default:()=>o;return t.d(n,{a:n}),n},d:(o,n)=>{for(var e in n)t.o(n,e)&&!t.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:n[e]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const n=flarum.core.compat["common/extend"],e=flarum.core.compat["forum/app"];var r=t.n(e);const s=flarum.core.compat["common/models/Post"];var a=t.n(s);const i=flarum.core.compat["common/Model"];var c=t.n(i);const u=flarum.core.compat["forum/components/NotificationGrid"];var l=t.n(u);const f=flarum.core.compat["common/components/Button"];var p=t.n(f);const d=flarum.core.compat["forum/components/CommentPost"];var k=t.n(d);const h=flarum.core.compat["common/components/Link"];var v=t.n(h);const y=flarum.core.compat["common/helpers/punctuateSeries"];var _=t.n(y);const b=flarum.core.compat["common/helpers/username"];var g=t.n(b);const P=flarum.core.compat["common/helpers/icon"];var L=t.n(P);function M(t,o){return M=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t},M(t,o)}function x(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,M(t,o)}const j=flarum.core.compat["common/components/Modal"];var O=t.n(j);const N=flarum.core.compat["common/helpers/avatar"];var S=t.n(N),B=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.className=function(){return"PostLikesModal Modal--small"},n.title=function(){return r().translator.trans("flarum-likes.forum.post_likes.title")},n.content=function(){return m("div",{className:"Modal-body"},m("ul",{className:"PostLikesModal-list"},this.attrs.post.likes().map((function(t){return m("li",null,m(v(),{href:r().route.user(t)},S()(t)," ",g()(t)))}))))},o}(O());const T=flarum.core.compat["forum/components/Notification"];var w=t.n(T);const C=flarum.core.compat["common/utils/string"];var I=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.icon=function(){return"far fa-thumbs-up"},n.href=function(){return r().route.post(this.attrs.notification.subject())},n.content=function(){var t=this.attrs.notification.fromUser();return r().translator.trans("flarum-likes.forum.notifications.post_liked_text",{user:t,count:1})},n.excerpt=function(){return(0,C.truncate)(this.attrs.notification.subject().contentPlain(),200)},o}(w());r().initializers.add("flarum-likes",(function(){r().notificationComponents.postLiked=I,a().prototype.canLike=c().attribute("canLike"),a().prototype.likes=c().hasMany("likes"),(0,n.extend)(k().prototype,"actionItems",(function(t){var o=this.attrs.post;if(!o.isHidden()&&o.canLike()){var n=o.likes(),e=r().session.user&&n&&n.some((function(t){return t===r().session.user}));t.add("like",p().component({className:"Button Button--link",onclick:function(){e=!e,o.save({isLiked:e});var t=o.data.relationships.likes.data;t.some((function(o,n){if(o.id===r().session.user.id())return t.splice(n,1),!0})),e&&t.unshift({type:"users",id:r().session.user.id()})}},r().translator.trans(e?"flarum-likes.forum.post.unlike_link":"flarum-likes.forum.post.like_link")))}})),(0,n.extend)(k().prototype,"footerItems",(function(t){var o=this.attrs.post,n=o.likes();if(n&&n.length){var e=n.length>4,s=n.sort((function(t){return t===r().session.user?-1:1})).slice(0,e?3:4).map((function(t){return m(v(),{href:r().route.user(t)},t===r().session.user?r().translator.trans("flarum-likes.forum.post.you_text"):g()(t))}));if(e){var a=n.length-s.length;s.push(m("a",{href:"#",onclick:function(t){t.preventDefault(),r().modal.show(B,{post:o})}},r().translator.trans("flarum-likes.forum.post.others_link",{count:a})))}t.add("liked",m("div",{className:"Post-likedBy"},L()("far fa-thumbs-up"),r().translator.trans("flarum-likes.forum.post.liked_by"+(n[0]===r().session.user?"_self":"")+"_text",{count:s.length,users:_()(s)})))}})),(0,n.extend)(l().prototype,"notificationTypes",(function(t){t.add("postLiked",{name:"postLiked",icon:"far fa-thumbs-up",label:r().translator.trans("flarum-likes.forum.settings.notify_post_liked_label")})}))}))})(),module.exports=o})();
|
||||
//# sourceMappingURL=forum.js.map
|
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
@@ -11,20 +11,17 @@ import PostLikesModal from './components/PostLikesModal';
|
||||
export default function () {
|
||||
extend(CommentPost.prototype, 'footerItems', function (items) {
|
||||
const post = this.attrs.post;
|
||||
const likes = post.recentLikes();
|
||||
const count = post.likesCount();
|
||||
const likes = post.likes();
|
||||
|
||||
if (likes && likes.length) {
|
||||
// the limit is dynamic through the backend, we only load those we need
|
||||
const limit = likes.length;
|
||||
// overLimit indicates there are more likes than the ones we render (and load)
|
||||
const overLimit = count > likes.length;
|
||||
const limit = 4;
|
||||
const overLimit = likes.length > limit;
|
||||
|
||||
// Construct a list of names of users who have liked this post. Make sure the
|
||||
// current user is first in the list, and cap a maximum of 4 items.
|
||||
const names = likes
|
||||
.filter((a) => a !== app.session.user)
|
||||
.slice(0, limit)
|
||||
.sort((a) => (a === app.session.user ? -1 : 1))
|
||||
.slice(0, overLimit ? limit - 1 : limit)
|
||||
.map((user) => {
|
||||
return (
|
||||
<Link href={app.route.user(user)}>
|
||||
@@ -33,14 +30,12 @@ export default function () {
|
||||
);
|
||||
});
|
||||
|
||||
if (post.likedByActor()) {
|
||||
names.unshift(<Link href={app.route.user(app.session.user)}>{app.translator.trans('flarum-likes.forum.post.you_text')}</Link>);
|
||||
}
|
||||
|
||||
// If there are more users that we've run out of room to display, add a "x
|
||||
// others" name to the end of the list. Clicking on it will display a modal
|
||||
// with a full list of names.
|
||||
if (overLimit) {
|
||||
const count = likes.length - names.length;
|
||||
|
||||
names.push(
|
||||
<a
|
||||
href="#"
|
||||
@@ -49,7 +44,7 @@ export default function () {
|
||||
app.modal.show(PostLikesModal, { post });
|
||||
}}
|
||||
>
|
||||
{app.translator.trans('flarum-likes.forum.post.others_link', { count: count - likes.length })}
|
||||
{app.translator.trans('flarum-likes.forum.post.others_link', { count })}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
@@ -14,10 +14,6 @@ app.initializers.add('flarum-likes', () => {
|
||||
Post.prototype.canLike = Model.attribute('canLike');
|
||||
Post.prototype.likes = Model.hasMany('likes');
|
||||
|
||||
Post.prototype.likesCount = Model.attribute('likesCount');
|
||||
Post.prototype.recentLikes = Model.hasMany('recentLikes');
|
||||
Post.prototype.likedByActor = Model.attribute('likedByActor');
|
||||
|
||||
addLikeAction();
|
||||
addLikesList();
|
||||
|
||||
|
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Likes\Api;
|
||||
|
||||
use Flarum\Api\Serializer\BasicUserSerializer;
|
||||
use Flarum\Api\Serializer\PostSerializer;
|
||||
use Flarum\Post\Post;
|
||||
use Tobscure\JsonApi\Collection;
|
||||
use Tobscure\JsonApi\Relationship;
|
||||
|
||||
class RecentLikesRelationship
|
||||
{
|
||||
private BasicUserSerializer $serializer;
|
||||
|
||||
public function __construct(BasicUserSerializer $serializer)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function __invoke(PostSerializer $serializer, Post $post): Relationship
|
||||
{
|
||||
return new Relationship(new Collection(
|
||||
$post->recentLikes,
|
||||
$this->serializer
|
||||
));
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Likes\Model;
|
||||
|
||||
use Flarum\Post\Post;
|
||||
use Flarum\User\User;
|
||||
|
||||
class RecentLikesRelationship
|
||||
{
|
||||
public function __invoke(Post $post)
|
||||
{
|
||||
return $post->belongsToMany(
|
||||
User::class,
|
||||
'post_likes',
|
||||
'post_id',
|
||||
'user_id'
|
||||
)
|
||||
->limit(3)
|
||||
->orderBy('post_likes.created_at');
|
||||
}
|
||||
}
|
0
extensions/likes/tests/fixtures/.gitkeep
vendored
Normal file
0
extensions/likes/tests/fixtures/.gitkeep
vendored
Normal file
144
extensions/likes/tests/integration/api/LikePostTest.php
Normal file
144
extensions/likes/tests/integration/api/LikePostTest.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Likes\Tests\integration\api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Post\CommentPost;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class LikePostTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-likes');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
$this->normalUser(),
|
||||
['id' => 3, 'username' => 'Acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
|
||||
],
|
||||
'discussions' => [
|
||||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 2],
|
||||
],
|
||||
'posts' => [
|
||||
['id' => 1, 'number' => 1, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>something</p></t>'],
|
||||
['id' => 3, 'number' => 2, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>something</p></t>'],
|
||||
['id' => 5, 'number' => 3, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 3, 'type' => 'discussionRenamed', 'content' => '<t><p>something</p></t>'],
|
||||
['id' => 6, 'number' => 4, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>something</p></t>'],
|
||||
],
|
||||
'groups' => [
|
||||
['id' => 5, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0],
|
||||
['id' => 6, 'name_singular' => 'Acme1', 'name_plural' => 'Acme1', 'is_hidden' => 0]
|
||||
],
|
||||
'group_user' => [
|
||||
['user_id' => 3, 'group_id' => 5]
|
||||
]
|
||||
]);
|
||||
|
||||
$this->database()->table('group_permission')->where('permission', 'discussion.likePosts')->delete();
|
||||
$this->database()->table('group_permission')->insert(['permission' => 'discussion.likePosts', 'group_id' => 5]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider allowedUsersToLike
|
||||
* @test
|
||||
*/
|
||||
public function can_like_a_post_if_allowed(int $postId, ?int $authenticatedAs, string $message)
|
||||
{
|
||||
$response = $this->sendLikeRequest($postId, $authenticatedAs);
|
||||
|
||||
$post = CommentPost::query()->find($postId);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertNotNull($post->likes->where('id', $authenticatedAs)->first(), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unallowedUsersToLike
|
||||
* @test
|
||||
*/
|
||||
public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message)
|
||||
{
|
||||
$response = $this->sendLikeRequest($postId, $authenticatedAs);
|
||||
|
||||
$post = CommentPost::query()->find($postId);
|
||||
|
||||
$this->assertEquals(403, $response->getStatusCode(), $message);
|
||||
$this->assertNull($post->likes->where('id', $authenticatedAs)->first());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider allowedUsersToLike
|
||||
* @test
|
||||
*/
|
||||
public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message)
|
||||
{
|
||||
$this->sendLikeRequest($postId, $authenticatedAs);
|
||||
$response = $this->sendLikeRequest($postId, $authenticatedAs, false);
|
||||
|
||||
$post = CommentPost::query()->find($postId);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertNull($post->likes->where('id', $authenticatedAs)->first(), $message);
|
||||
}
|
||||
|
||||
public function allowedUsersToLike(): array
|
||||
{
|
||||
return [
|
||||
[1, 1, 'Admin can like any post'],
|
||||
[1, 3, 'User with permission can like other posts'],
|
||||
[6, 3, 'User with permission can like own post']
|
||||
];
|
||||
}
|
||||
|
||||
public function unallowedUsersToLike(): array
|
||||
{
|
||||
return [
|
||||
[1, null, 'Guest cannot like any post'],
|
||||
[1, 2, 'User without permission cannot like any post']
|
||||
];
|
||||
}
|
||||
|
||||
protected function sendLikeRequest(int $postId, ?int $authenticatedAs, bool $liked = true): ResponseInterface
|
||||
{
|
||||
if (! isset($authenticatedAs)) {
|
||||
$initial = $this->send(
|
||||
$this->request('GET', '/')
|
||||
);
|
||||
|
||||
$token = $initial->getHeaderLine('X-CSRF-Token');
|
||||
}
|
||||
|
||||
$request = $this->request('PATCH', "/api/posts/$postId", [
|
||||
'authenticatedAs' => $authenticatedAs,
|
||||
'cookiesFrom' => $initial ?? null,
|
||||
'json' => [
|
||||
'data' => [
|
||||
'attributes' => [
|
||||
'isLiked' => $liked
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
if (! isset($authenticatedAs)) {
|
||||
$request = $request->withHeader('X-CSRF-Token', $token);
|
||||
}
|
||||
|
||||
return $this->send($request);
|
||||
}
|
||||
}
|
16
extensions/likes/tests/integration/setup.php
Normal file
16
extensions/likes/tests/integration/setup.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
|
||||
$setup->run();
|
25
extensions/likes/tests/phpunit.integration.xml
Normal file
25
extensions/likes/tests/phpunit.integration.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Integration Tests">
|
||||
<directory suffix="Test.php">./integration</directory>
|
||||
<exclude>./integration/tmp</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
27
extensions/likes/tests/phpunit.unit.xml
Normal file
27
extensions/likes/tests/phpunit.unit.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Unit Tests">
|
||||
<directory suffix="Test.php">./unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
0
extensions/likes/tests/unit/.gitkeep
Normal file
0
extensions/likes/tests/unit/.gitkeep
Normal file
20
extensions/lock/.gitattributes
vendored
Normal file
20
extensions/lock/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/lock",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/markdown/.gitattributes
vendored
Normal file
20
extensions/markdown/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/markdown",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
20
extensions/mentions/.gitattributes
vendored
Normal file
20
extensions/mentions/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/mentions",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@@ -14,7 +14,7 @@ use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ListTest extends TestCase
|
||||
class ListPostsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
@@ -85,4 +85,26 @@ class ListTest extends TestCase
|
||||
$ids = Arr::pluck($data, 'id');
|
||||
$this->assertEqualsCanonicalizing(['4'], $ids, 'IDs do not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function mentioned_filter_works_with_sort()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/posts')
|
||||
->withQueryParams([
|
||||
'filter' => ['mentioned' => 1],
|
||||
'sort' => '-createdAt'
|
||||
])
|
||||
);
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true)['data'];
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
// Order-independent comparison
|
||||
$ids = Arr::pluck($data, 'id');
|
||||
$this->assertEqualsCanonicalizing(['3', '2'], $ids, 'IDs do not match');
|
||||
}
|
||||
}
|
||||
|
20
extensions/nicknames/.gitattributes
vendored
Normal file
20
extensions/nicknames/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/nicknames",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/package-manager/.gitattributes
vendored
Normal file
20
extensions/package-manager/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
20
extensions/pusher/.gitattributes
vendored
Normal file
20
extensions/pusher/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/pusher",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3",
|
||||
"flarum/core": "^1.4",
|
||||
"pusher/pusher-php-server": "^2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
|
20
extensions/statistics/.gitattributes
vendored
Normal file
20
extensions/statistics/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/statistics",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/sticky/.gitattributes
vendored
Normal file
20
extensions/sticky/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/sticky",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -51,7 +51,7 @@
|
||||
"prettier": true,
|
||||
"typescript": false,
|
||||
"bundlewatch": false,
|
||||
"backendTesting": false,
|
||||
"backendTesting": true,
|
||||
"editorConfig": true,
|
||||
"styleci": true
|
||||
}
|
||||
@@ -64,5 +64,29 @@
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
"prefer-stable": true,
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flarum\\Sticky\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@test:unit",
|
||||
"@test:integration"
|
||||
],
|
||||
"test:unit": "phpunit -c tests/phpunit.unit.xml",
|
||||
"test:integration": "phpunit -c tests/phpunit.integration.xml",
|
||||
"test:setup": "@php tests/integration/setup.php"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Runs all tests.",
|
||||
"test:unit": "Runs all unit tests.",
|
||||
"test:integration": "Runs all integration tests.",
|
||||
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/tags": "*@dev",
|
||||
"flarum/testing": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
0
extensions/sticky/tests/fixtures/.gitkeep
vendored
Normal file
0
extensions/sticky/tests/fixtures/.gitkeep
vendored
Normal file
120
extensions/sticky/tests/integration/api/ListDiscussionsTest.php
Normal file
120
extensions/sticky/tests/integration/api/ListDiscussionsTest.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Sticky\tests\integration\api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ListDiscussionsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-tags', 'flarum-sticky');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
$this->normalUser(),
|
||||
['id' => 3, 'username' => 'Muralf_', 'email' => 'muralf_@machine.local', 'is_email_confirmed' => 1],
|
||||
],
|
||||
'discussions' => [
|
||||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'is_sticky' => true, 'last_post_number' => 1],
|
||||
['id' => 2, 'title' => __CLASS__, 'created_at' => Carbon::now()->addMinutes(2), 'last_posted_at' => Carbon::now()->addMinutes(5), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'is_sticky' => false, 'last_post_number' => 1],
|
||||
['id' => 3, 'title' => __CLASS__, 'created_at' => Carbon::now()->addMinutes(3), 'last_posted_at' => Carbon::now()->addMinute(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'is_sticky' => true, 'last_post_number' => 1],
|
||||
['id' => 4, 'title' => __CLASS__, 'created_at' => Carbon::now()->addMinutes(4), 'last_posted_at' => Carbon::now()->addMinutes(2), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'is_sticky' => false, 'last_post_number' => 1],
|
||||
],
|
||||
'discussion_user' => [
|
||||
['discussion_id' => 1, 'user_id' => 3, 'last_read_post_number' => 1],
|
||||
['discussion_id' => 3, 'user_id' => 3, 'last_read_post_number' => 1],
|
||||
],
|
||||
'tags' => [
|
||||
['id' => 1, 'slug' => 'general', 'position' => 0, 'parent_id' => null]
|
||||
],
|
||||
'discussion_tag' => [
|
||||
['discussion_id' => 1, 'tag_id' => 1],
|
||||
['discussion_id' => 2, 'tag_id' => 1],
|
||||
['discussion_id' => 3, 'tag_id' => 1],
|
||||
['discussion_id' => 4, 'tag_id' => 1],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function list_discussions_shows_sticky_first_as_guest()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions')
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals([3, 1, 2, 4], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function list_discussions_shows_sticky_unread_first_as_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions', [
|
||||
'authenticatedAs' => 2
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals([3, 1, 2, 4], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function list_discussions_shows_normal_order_when_all_read_as_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions', [
|
||||
'authenticatedAs' => 3
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals([2, 4, 3, 1], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function list_discussions_shows_stick_first_on_a_tag()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/discussions', [
|
||||
'authenticatedAs' => 3
|
||||
])->withQueryParams([
|
||||
'filter' => [
|
||||
'tag' => 'general'
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals([3, 1, 2, 4], Arr::pluck($data['data'], 'id'));
|
||||
}
|
||||
}
|
16
extensions/sticky/tests/integration/setup.php
Normal file
16
extensions/sticky/tests/integration/setup.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
|
||||
$setup->run();
|
25
extensions/sticky/tests/phpunit.integration.xml
Normal file
25
extensions/sticky/tests/phpunit.integration.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Integration Tests">
|
||||
<directory suffix="Test.php">./integration</directory>
|
||||
<exclude>./integration/tmp</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
27
extensions/sticky/tests/phpunit.unit.xml
Normal file
27
extensions/sticky/tests/phpunit.unit.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Unit Tests">
|
||||
<directory suffix="Test.php">./unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
0
extensions/sticky/tests/unit/.gitkeep
Normal file
0
extensions/sticky/tests/unit/.gitkeep
Normal file
20
extensions/subscriptions/.gitattributes
vendored
Normal file
20
extensions/subscriptions/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/subscriptions",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
20
extensions/suspend/.gitattributes
vendored
Normal file
20
extensions/suspend/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/suspend",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -51,7 +51,7 @@
|
||||
"prettier": true,
|
||||
"typescript": false,
|
||||
"bundlewatch": false,
|
||||
"backendTesting": false,
|
||||
"backendTesting": true,
|
||||
"editorConfig": true,
|
||||
"styleci": true
|
||||
}
|
||||
@@ -64,5 +64,28 @@
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
"prefer-stable": true,
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flarum\\Suspend\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@test:unit",
|
||||
"@test:integration"
|
||||
],
|
||||
"test:unit": "phpunit -c tests/phpunit.unit.xml",
|
||||
"test:integration": "phpunit -c tests/phpunit.integration.xml",
|
||||
"test:setup": "@php tests/integration/setup.php"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"test": "Runs all tests.",
|
||||
"test:unit": "Runs all unit tests.",
|
||||
"test:integration": "Runs all integration tests.",
|
||||
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/testing": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
0
extensions/suspend/tests/fixtures/.gitkeep
vendored
Normal file
0
extensions/suspend/tests/fixtures/.gitkeep
vendored
Normal file
86
extensions/suspend/tests/integration/api/UseForumTest.php
Normal file
86
extensions/suspend/tests/integration/api/UseForumTest.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Suspend\Tests\integration\api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
|
||||
class UseForumTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-suspend');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
['id' => 2, 'username' => 'SuspendedDonny', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->addDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'],
|
||||
],
|
||||
'discussions' => [
|
||||
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1],
|
||||
],
|
||||
'posts' => [
|
||||
['id' => 1, 'number' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'discussion_id' => 1, 'content' => '<t><p>Hello, world!</p></t>'],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function suspended_user_cannot_create_discussions()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('POST', '/api/discussions', [
|
||||
'authenticatedAs' => 2,
|
||||
'json' => [
|
||||
'data' => [
|
||||
'attributes' => [
|
||||
'title' => 'Test post',
|
||||
'content' => '<t><p>Hello, world!</p></t>'
|
||||
],
|
||||
],
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function suspended_user_cannot_reply_to_discussions()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('POST', '/api/posts', [
|
||||
'authenticatedAs' => 2,
|
||||
'json' => [
|
||||
'data' => [
|
||||
'attributes' => [
|
||||
'content' => '<t><p>Hello, world!</p></t>'
|
||||
],
|
||||
'relationships' => [
|
||||
'discussion' => [
|
||||
'data' => [
|
||||
'type' => 'discussions',
|
||||
'id' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Suspend\Tests\integration\api\users;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ListUsersTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-suspend');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
['id' => 2, 'username' => 'SuspendedDonny1', 'email' => 'acme1@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->addDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'],
|
||||
['id' => 3, 'username' => 'SuspendedDonny2', 'email' => 'acme2@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->addDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'],
|
||||
['id' => 4, 'username' => 'SuspendedDonny3', 'email' => 'acme3@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->subDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'],
|
||||
['id' => 5, 'username' => 'SuspendedDonny4', 'email' => 'acme4@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->addDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'],
|
||||
['id' => 6, 'username' => 'Acme', 'email' => 'acme5@machine.local', 'is_email_confirmed' => 1],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function can_view_default_users_list()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/users', [
|
||||
'authenticatedAs' => 1,
|
||||
])->withQueryParams([
|
||||
'filter' => [
|
||||
'suspended' => true,
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([1, 2, 3, 4, 5, 6], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function can_filter_users_by_suspension()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/users', [
|
||||
'authenticatedAs' => 1,
|
||||
])->withQueryParams([
|
||||
'filter' => [
|
||||
'suspended' => true,
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEqualsCanonicalizing([2, 3, 5], Arr::pluck($body['data'], 'id'));
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Suspend\Tests\integration\api\users;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class SuspendUserTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-suspend');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
|
||||
$this->normalUser(),
|
||||
['id' => 3, 'username' => 'acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
|
||||
],
|
||||
'groups' => [
|
||||
['id' => 5, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0]
|
||||
],
|
||||
'group_user' => [
|
||||
['user_id' => 3, 'group_id' => 5]
|
||||
],
|
||||
'group_permission' => [
|
||||
['permission' => 'user.suspend', 'group_id' => 5]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider allowedToSuspendUser
|
||||
* @test
|
||||
*/
|
||||
public function can_suspend_user_if_allowed(?int $authenticatedAs, int $targetUserId, string $message)
|
||||
{
|
||||
$response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider unallowedToSuspendUser
|
||||
* @test
|
||||
*/
|
||||
public function cannot_suspend_user_if_not_allowed(?int $authenticatedAs, int $targetUserId, string $message)
|
||||
{
|
||||
$response = $this->sendSuspensionRequest($authenticatedAs, $targetUserId);
|
||||
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function allowedToSuspendUser(): array
|
||||
{
|
||||
return [
|
||||
[1, 2, 'Admin can suspend any user'],
|
||||
[1, 3, 'Admin can suspend any user'],
|
||||
[3, 2, 'User with permission can suspend any user'],
|
||||
];
|
||||
}
|
||||
|
||||
public function unallowedToSuspendUser(): array
|
||||
{
|
||||
return [
|
||||
[1, 1, 'Admin cannot suspend self'],
|
||||
[2, 2, 'User without permission cannot suspend self'],
|
||||
[2, 3, 'User without permission cannot suspend other user'],
|
||||
[3, 3, 'User with permission cannot suspend self'],
|
||||
[3, 1, 'User with permission cannot suspend admin'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function sendSuspensionRequest(?int $authenticatedAs, int $targetUserId): ResponseInterface
|
||||
{
|
||||
return $this->send(
|
||||
$this->request('PATCH', "/api/users/$targetUserId", [
|
||||
'authenticatedAs' => $authenticatedAs,
|
||||
'json' => [
|
||||
'data' => [
|
||||
'attributes' => [
|
||||
'suspendedUntil' => Carbon::now()->addDay(),
|
||||
'suspendReason' => 'Suspended for acme reasons.',
|
||||
'suspendMessage' => 'You have been suspended.',
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
16
extensions/suspend/tests/integration/setup.php
Normal file
16
extensions/suspend/tests/integration/setup.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
|
||||
$setup->run();
|
25
extensions/suspend/tests/phpunit.integration.xml
Normal file
25
extensions/suspend/tests/phpunit.integration.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Integration Tests">
|
||||
<directory suffix="Test.php">./integration</directory>
|
||||
<exclude>./integration/tmp</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
27
extensions/suspend/tests/phpunit.unit.xml
Normal file
27
extensions/suspend/tests/phpunit.unit.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">../src/</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Flarum Unit Tests">
|
||||
<directory suffix="Test.php">./unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<listeners>
|
||||
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
0
extensions/suspend/tests/unit/.gitkeep
Normal file
0
extensions/suspend/tests/unit/.gitkeep
Normal file
20
extensions/tags/.gitattributes
vendored
Normal file
20
extensions/tags/.gitattributes
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
**/.gitattributes export-ignore
|
||||
**/.gitignore export-ignore
|
||||
**/.gitmodules export-ignore
|
||||
**/.github export-ignore
|
||||
**/.travis export-ignore
|
||||
**/.travis.yml export-ignore
|
||||
**/.editorconfig export-ignore
|
||||
**/.styleci.yml export-ignore
|
||||
|
||||
**/phpunit.xml export-ignore
|
||||
**/tests export-ignore
|
||||
|
||||
**/js/dist/**/* -diff
|
||||
**/js/dist/**/* linguist-generated
|
||||
**/js/dist-typings/**/* -diff
|
||||
**/js/dist-typings/**/* linguist-generated
|
||||
**/js/yarn.lock -diff
|
||||
**/js/package-lock.json -diff
|
||||
|
||||
* text=auto eol=lf
|
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/tags",
|
||||
"forum": "https://discuss.flarum.org"
|
||||
},
|
||||
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"flarum/core": "^1.3"
|
||||
"flarum/core": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@@ -49,11 +49,26 @@ class ShowTagController extends AbstractShowController
|
||||
$slug = Arr::get($request->getQueryParams(), 'slug');
|
||||
$actor = RequestUtil::getActor($request);
|
||||
$include = $this->extractInclude($request);
|
||||
$setParentOnChildren = false;
|
||||
|
||||
return $this->tags
|
||||
if (in_array('parent.children.parent', $include, true)) {
|
||||
$setParentOnChildren = true;
|
||||
$include[] = 'parent.children';
|
||||
$include = array_unique(array_diff($include, ['parent.children.parent']));
|
||||
}
|
||||
|
||||
$tag = $this->tags
|
||||
->with($include, $actor)
|
||||
->whereVisibleTo($actor)
|
||||
->where('slug', $slug)
|
||||
->firstOrFail();
|
||||
|
||||
if ($setParentOnChildren && $tag->parent) {
|
||||
foreach ($tag->parent->children as $child) {
|
||||
$child->parent = $tag->parent;
|
||||
}
|
||||
}
|
||||
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TagRepository
|
||||
{
|
||||
private const TAG_RELATIONS = ['children', 'parent'];
|
||||
private const TAG_RELATIONS = ['children', 'parent', 'parent.children'];
|
||||
|
||||
/**
|
||||
* Get a new query builder for the tags table.
|
||||
|
@@ -83,15 +83,16 @@ class ListTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider listTagsIncludes
|
||||
* @test
|
||||
*/
|
||||
public function user_sees_where_allowed_with_included_tags()
|
||||
public function user_sees_where_allowed_with_included_tags(string $include, array $expectedIncludes)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/tags', [
|
||||
'authenticatedAs' => 2,
|
||||
])->withQueryParams([
|
||||
'include' => 'children'
|
||||
'include' => $include
|
||||
])
|
||||
);
|
||||
|
||||
@@ -106,7 +107,7 @@ class ListTest extends TestCase
|
||||
// 6, 7, 8 aren't included because child access shouldnt work unless parent
|
||||
// access is also given.
|
||||
$this->assertEquals(['1', '2', '3', '4', '9', '10', '11'], Arr::pluck($data, 'id'));
|
||||
$this->assertEquals(['3', '4'], Arr::pluck($included, 'id'));
|
||||
$this->assertEquals($expectedIncludes, Arr::pluck($included, 'id'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,4 +126,12 @@ class ListTest extends TestCase
|
||||
$ids = Arr::pluck($data, 'id');
|
||||
$this->assertEquals(['1', '2', '3', '4', '9', '10'], $ids);
|
||||
}
|
||||
|
||||
public function listTagsIncludes(): array
|
||||
{
|
||||
return [
|
||||
['children', ['3', '4']],
|
||||
['parent', ['2']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
75
extensions/tags/tests/integration/api/tags/ShowTest.php
Normal file
75
extensions/tags/tests/integration/api/tags/ShowTest.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tags\Tests\integration\api\tags;
|
||||
|
||||
use Flarum\Group\Group;
|
||||
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ShowTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use RetrievesRepresentativeTags;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->extension('flarum-tags');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'tags' => $this->tags(),
|
||||
'users' => [
|
||||
$this->normalUser(),
|
||||
],
|
||||
'group_permission' => [
|
||||
['group_id' => Group::MEMBER_ID, 'permission' => 'tag8.viewForum'],
|
||||
['group_id' => Group::MEMBER_ID, 'permission' => 'tag11.viewForum']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider showTagIncludes
|
||||
* @test
|
||||
*/
|
||||
public function user_sees_tag_relations_where_allowed(string $include, array $expectedIncludes)
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/tags/primary-2-child-2', [
|
||||
'authenticatedAs' => 2,
|
||||
])->withQueryParams([
|
||||
'include' => $include
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$responseBody = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$included = $responseBody['included'] ?? [];
|
||||
$this->assertEqualsCanonicalizing($expectedIncludes, Arr::pluck($included, 'id'));
|
||||
}
|
||||
|
||||
public function showTagIncludes(): array
|
||||
{
|
||||
return [
|
||||
['children', []],
|
||||
['parent', ['2']],
|
||||
['parent.children', ['3', '2']],
|
||||
['parent.children.parent', ['3', '2']],
|
||||
];
|
||||
}
|
||||
}
|
@@ -29,8 +29,8 @@
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/flarum/core/issues",
|
||||
"source": "https://github.com/flarum/core",
|
||||
"issues": "https://github.com/flarum/framework/issues",
|
||||
"source": "https://github.com/flarum/flarum-core",
|
||||
"docs": "https://docs.flarum.org",
|
||||
"forum": "https://discuss.flarum.org",
|
||||
"chat": "https://flarum.org/chat"
|
||||
|
@@ -190,6 +190,7 @@
|
||||
}
|
||||
|
||||
.normal &:first-child {
|
||||
height: var(--header-height-phone);
|
||||
margin: calc(~"0px - var(--header-height-phone)") 50px 0;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
@@ -198,6 +199,9 @@
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
h3 {
|
||||
color: var(--header-control-color);
|
||||
|
@@ -68,14 +68,17 @@
|
||||
color: var(--heading-color) !important;
|
||||
padding: 8px 16px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
// Prevent outline overflowing parent
|
||||
.add-keyboard-focus-ring-offset(-1px);
|
||||
|
||||
&, span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
&-badges {
|
||||
|
@@ -113,6 +113,20 @@ class ListPostsController extends AbstractListController
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://github.com/flarum/framework/pull/3506
|
||||
*/
|
||||
protected function extractSort(ServerRequestInterface $request)
|
||||
{
|
||||
$sort = [];
|
||||
|
||||
foreach ((parent::extractSort($request) ?: []) as $field => $direction) {
|
||||
$sort["posts.$field"] = $direction;
|
||||
}
|
||||
|
||||
return $sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -21,7 +21,7 @@ class Application
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1.3.1';
|
||||
const VERSION = '1.4.0';
|
||||
|
||||
/**
|
||||
* The IoC container for the Flarum application.
|
||||
|
@@ -53,7 +53,7 @@ class Assets
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __invoke(Document $document, Request $request): void
|
||||
public function __invoke(Document $document, Request $request)
|
||||
{
|
||||
$locale = $request->getAttribute('locale');
|
||||
|
||||
|
@@ -650,7 +650,7 @@ class User extends AbstractModel
|
||||
*/
|
||||
public function assertAdmin()
|
||||
{
|
||||
$this->assertCan($this, 'administrate');
|
||||
$this->assertCan('administrate');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user