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

Compare commits

...

217 Commits

Author SHA1 Message Date
flarum-bot
6de38ff4c9 Bundled output for commit 391a8613cf
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-26 22:18:59 +00:00
Davide Iadeluca
391a8613cf fix: resolve regression in typing errors (#4097) 2024-10-26 23:15:50 +01:00
IanM
448f201fa6 chore: bump tsconfig version 2024-10-22 19:17:00 +01:00
flarum-bot
0694651fe9 Bundled output for commit 92b2b4aad1
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-22 09:18:09 +00:00
Davide Iadeluca
92b2b4aad1 [1.x] chore: resolve node deprecation warnings in workflows (#4081)
* chore: update frontend workflow

Backport of 356f97641e

* chore: bump default node version and `flarum/action-build`

* fix

* dummy commit
2024-10-22 10:14:06 +01:00
flarum-bot
0b55830693 Bundled output for commit c42f0a5d0e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-21 20:40:33 +00:00
IanM
c42f0a5d0e fix: postfooter did not apply the empty subclass (#4085) 2024-10-21 21:35:52 +01:00
flarum-bot
821ca01460 Bundled output for commit 6f48557c3a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-21 19:01:58 +00:00
IanM
6f48557c3a fix new search term not being passed (#4083) 2024-10-21 19:57:55 +01:00
IanM
cc1d2aaade chore: set appver to 1.8.8 (#4084) 2024-10-21 19:50:41 +01:00
IanM
3a45ebc716 [1.x] [suspend] fix: previously suspended admin users cannot remove their avatar after suspension (#4071)
* [1.x][suspend] fix: formally suspended admin users cannot remove their avatar after suspension

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-10-15 12:10:55 +01:00
IanM
5bd7e5dfe3 chore: create changelog 2024-10-09 14:00:11 +01:00
IanM
956ac20c4c chore: bump appver 2024-10-09 10:45:06 +01:00
flarum-bot
b7e41ce82f Bundled output for commit c737d7b8f5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-08 14:07:09 +00:00
IanM
c737d7b8f5 fix: basicspage broken when no displayname drivers enabled (#4062) 2024-10-08 15:00:43 +01:00
Davide Iadeluca
9295e7b96f chore(flags): require flarum/core ^1.8.6 (#4061) 2024-10-08 07:40:35 +01:00
Davide Iadeluca
9377256409 chore: 1.8.6 changelog (#4058)
* chore: `1.8.6` changelog

* chore: add recent fix

* chore: remove interim fixes
2024-10-08 07:13:56 +01:00
Davide Iadeluca
9c91c89326 [1.x] fix(core, mentions): return null if content left empty in formatter (#4059)
* test(core): implement test for creating discussion without content

* fix(core): handle `null` case in XML parser

* fix(mentions): change/remove typings in unparser

* fix(mentions): return early if xml null

* chore: fix PHPStan

* chore: move tests to mentions

* chore: remove unused import

* chore: remove unused imports

* test(mentions): implement test for post editing with content empty

* test(mentions): change post edit tests

* test(mentions): add test for creating discussion with empty string
2024-10-08 06:56:09 +01:00
flarum-bot
8169550f1c Bundled output for commit d5a1653d24
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 08:51:49 +00:00
Robert Korulczyk
d5a1653d24 [1.x] feat: allow to customize time formats through translations (#4053)
* Allow to customize time formats

* Fix CS
2024-10-03 09:47:48 +01:00
flarum-bot
db605bdbaa Bundled output for commit 1665d47adc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 08:04:40 +00:00
IanM
1665d47adc fix: compat: still return controls view item, even if empty (#4057) 2024-10-03 09:01:17 +01:00
flarum-bot
1c71ee0968 Bundled output for commit 6846f4232c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 06:29:46 +00:00
IanM
6846f4232c fix: js error as guest on DiscussionListItem (#4056) 2024-10-03 08:25:00 +02:00
Davide Iadeluca
88f182cc93 [1.x] [extensibility] Add (some) missing shims (#4027)
* chore: add some missing shims

* chore: remove unused import
2024-10-02 12:13:26 +01:00
flarum-bot
ed72aa0128 Bundled output for commit 12d21cdbfc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 10:25:42 +00:00
Davide Iadeluca
12d21cdbfc [1.x] [extensibility] refactor(core): allow labels of PostStreamScrubber to be customized (#4049)
* refactor(core): allow labels to be customized

* chore: change type annotation

* chore: remove type annotations

Importing `NestedStringArray` did cause issues in the CI
2024-10-02 11:19:26 +01:00
flarum-bot
359681f3c6 Bundled output for commit 1a4c4a0275
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 09:25:35 +00:00
IanM
1a4c4a0275 feat: provide an 'actions' dropdown for extensions to add their additional buttons (#4054) 2024-10-02 10:18:00 +01:00
IanM
ea2fd2cade Revert "feat: provide an 'actions' dropdown for extensions to add their additional buttons"
This reverts commit 772852b3b3.
2024-10-02 09:53:12 +01:00
IanM
772852b3b3 feat: provide an 'actions' dropdown for extensions to add their additional buttons 2024-10-02 09:52:07 +01:00
flarum-bot
71717f9ebb Bundled output for commit 449ba48ba3
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 07:10:53 +00:00
Davide Iadeluca
449ba48ba3 [1.x] [extensibility] Export all missing modules in compat (#4044)
* chore(emoji): export missing modules in compat API

* chore(flags): export missing modules in compat API

* chore(likes): export missing modules in compat API

* chore(lock): export missing modules in compat API

* chore(markdown): export missing modules in compat API

* chore(mentions): export missing modules in compat API

* chore(nicknames): export missing modules in compat API

* chore(extension-manager): export missing modules in compat API

* chore(statistics): export missing modules in compat API

* chore(sticky): export missing modules in compat API

* chore(subscriptions): export missing modules in compat API

* chore(suspend): export missing modules in compat API

* chore(tags): export missing modules in compat API

* chore(core): export missing modules in compat API

* chore: fix tsconfig
2024-10-02 08:04:10 +01:00
flarum-bot
4d75da36b8 Bundled output for commit d4fe5f5a7a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 06:54:38 +00:00
Davide Iadeluca
d4fe5f5a7a [1.x] [extensibility] refactor(core, flags): improve & use extensibility of CommentPost & Post (#4047)
* refactor(core): improve extensibility of `CommentPost`

* refactor(core): rename method to more appropriate name

* refactor(core): further improve extensibility of `CommentPost`

* refactor(core): improve extensibility of `Post`

* refactor(flags): use new extensibility for flagged posts
2024-10-02 07:47:05 +01:00
flarum-bot
256c1846b7 Bundled output for commit 1fee96aebe
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 14:45:34 +00:00
Davide Iadeluca
1fee96aebe fix(core): revert extensibility improvements for replyCountItem() (#4051)
This fixes a breaking change with third-party extensions calling `replyCountItem()` and not expecting it to be an array.
2024-09-30 15:38:30 +01:00
flarum-bot
b49b3104e4 Bundled output for commit 7d8cfdfaec
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:38:37 +00:00
Davide Iadeluca
7d8cfdfaec refactor(core): backport & improve extensibility of DiscussionListItem (#4048) 2024-09-30 12:32:23 +01:00
flarum-bot
845c38d6cb Bundled output for commit 4912a2e059
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:26:09 +00:00
Davide Iadeluca
4912a2e059 [1.x] [extensibility] refactor(core): improve extensibility of DiscussionPage (#4046)
* refactor(core): improve extensibility of `DiscussionPage`

* chore(core): improve type safety
2024-09-30 12:19:14 +01:00
flarum-bot
ca6d826f79 Bundled output for commit dce2549ff7
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:08:05 +00:00
Davide Iadeluca
dce2549ff7 [1.x] [extensibility] refactor(core): improve extensibility of IndexPage (#4045)
* refactor(core): improve extensibility of `IndexPage`

* refactor(core): refactor the extensibility refactor
2024-09-30 12:02:58 +01:00
flarum-bot
306d0bc124 Bundled output for commit e3d07cb8cc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 10:46:59 +00:00
IanM
e3d07cb8cc feat: make it easier to add content after the first post (#4050) 2024-09-30 11:43:40 +01:00
flarum-bot
9bc8c7de99 Bundled output for commit 5076da9b38
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 19:16:08 +00:00
IanM
5076da9b38 feat: use common component for ip address display (#4042) 2024-09-29 20:12:53 +01:00
IanM
2c4d64cd20 [1.x] [extensibility] feat: allow classes that extends AbstractJob to be placed on a specified queue (#4026)
* feat: allow classes that extends AbstractJob to be placed on a specific queue

* Apply fixes from StyleCI

* php 7.3 compat

* Apply fixes from StyleCI

* change  to  to avoid conflicts with extensions that already do this

* chore: add docblock explaining that this solution only works for Redis queues

* Apply fixes from StyleCI

* chore: update docblock

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-09-29 15:35:29 +01:00
flarum-bot
c9bd7dab1e Bundled output for commit df14216e1b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 13:48:02 +00:00
IanM
df14216e1b chore: allow extending PostPreview content (#4043) 2024-09-29 14:44:51 +01:00
flarum-bot
de36551b45 Bundled output for commit 54fbcdedd5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 11:30:04 +00:00
IanM
54fbcdedd5 chore: extensible TagHero (#4041) 2024-09-29 12:26:53 +01:00
flarum-bot
e9c8890686 Bundled output for commit 6dd0c0e915
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 11:12:28 +00:00
IanM
6dd0c0e915 [1.x] [extensibility] chore: make PostMeta extensible (#4040)
* chore: make PostMeta extensible

* add prio for ip item
2024-09-29 12:06:04 +01:00
flarum-bot
444df80caf Bundled output for commit 3ebd218588
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 09:03:25 +00:00
IanM
3ebd218588 chore: make WelcomeHero extensible (#4039) 2024-09-29 09:58:12 +01:00
IanM
9038ff64f8 [suspend][core] [1.x] fix: suspended users can remove avatar (#3998)
* fix: suspended users can remove avatar

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-09-29 08:54:13 +01:00
flarum-bot
f8c30c96dc Bundled output for commit 3743bc0886
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 07:41:13 +00:00
IanM
3743bc0886 chore: point fontawesome links at v5 free (#4038) 2024-09-29 08:35:57 +01:00
flarum-bot
5855134b79 Bundled output for commit 7f657dac04
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 07:12:08 +00:00
IanM
7f657dac04 feat: make it easier to modify AppearancePage, BasicsPage, MailPage (#4037) 2024-09-29 08:07:10 +01:00
flarum-bot
84414c6699 Bundled output for commit bf0d895106
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 08:23:34 +00:00
IanM
bf0d895106 chore: fix Flarum logo url, remove huntr link 2024-09-28 09:17:05 +01:00
IanM
c942f3100d Revert "Export all missing modules in compat (#4006)" (#4032)
This reverts commit e0adf90453.
2024-09-28 09:11:37 +01:00
flarum-bot
d5882d9357 Bundled output for commit 7540ede897
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 07:59:41 +00:00
IanM
7540ede897 feat: allow modifying the discussion title on PostsUserPage (#4031) 2024-09-28 08:54:03 +01:00
flarum-bot
77d1a3d04b Bundled output for commit c79d2892de
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 06:44:31 +00:00
IanM
c79d2892de feat: [1.x] [extensibility] feat: allow to be extended (#4025) 2024-09-28 07:36:58 +01:00
IanM
46cdaf5d1a chore: bump version to 1.8.6 2024-09-28 07:31:05 +01:00
flarum-bot
4d59ec4600 Bundled output for commit e0adf90453
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-27 06:54:45 +00:00
Davide Iadeluca
e0adf90453 Export all missing modules in compat (#4006)
* chore(emoji): export missing modules in compat API

* chore(flags): export missing modules in compat API

* chore(likes): export missing modules in compat API

* chore(lock): export missing modules in compat API

* chore(markdown): export missing modules in compat API

* chore(mentions): export missing modules in compat API

* chore(nicknames): export missing modules in compat API

* chore(extension-manager): export missing modules in compat API

* chore(statistics): export missing modules in compat API

* chore(sticky): export missing modules in compat API

* chore(subscriptions): export missing modules in compat API

* chore(suspend): export missing modules in compat API

* chore(tags): export missing modules in compat API

* chore(core): export missing modules in compat API
2024-09-27 07:44:06 +01:00
flarum-bot
07a1781181 Bundled output for commit 80e70f4980
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-26 18:12:40 +00:00
80e70f4980 fix: reset admin page save button in catch (#3963) 2024-09-26 19:07:35 +01:00
StyleCI Bot
e43530e40a Apply fixes from StyleCI 2024-09-26 15:55:20 +00:00
IanM
24e88d12b8 chore: dummy commit to trigger style CI on 1.x 2024-09-26 16:38:56 +01:00
Rafał Całka
b3366e4c93 fix(tags): load correct user tag state and prevent N+1 queries in stateFor (#4008)
* fix: load tag state for correct user
* fix: prevent loading state if loaded previously
* fix(PHPStan): TagState can be null
2024-08-10 18:29:26 +01:00
Davide Iadeluca
8415d2233e ci: allow custom actions runner to be defined (#3989) 2024-05-16 17:30:30 +01:00
Daniël Klabbers
a52959ccf2 Patch vulnerability advisory (#3966)
Seems composer has a vulnerability, see https://github.com/advisories/GHSA-7c6p-848j-wh5h

Affected versions
>= 2.0.0-alpha1, < 2.2.23 -- patched in 2.2.23
>= 2.3.0-rc1, < 2.7.0 -- patched in 2.7.0

---

Let's raise the minimum to enforce the latest.

Thank you @peopleinside for reporting this.

(cherry picked from commit e771b908d5)
2024-02-22 11:43:31 +01:00
Sami Mazouz
b2044ff312 fix(em): breaks when composer deps get updated 2024-02-04 13:56:09 +01:00
IanM
50dd73b07c feat: support passing composer_auth values 2024-01-19 16:29:51 +00:00
Sami Mazouz
4f4977b7a5 fix(em): phpstan 2024-01-12 17:59:59 +01:00
Sami Mazouz
24b7dcb102 fix(em): composer.json schema issues 2024-01-12 17:57:08 +01:00
Sami Mazouz
25beb7919d fix: broken paths 2024-01-10 16:03:12 +01:00
Sami Mazouz
207032f6ff chore: rename package-manager to extension-manager 2024-01-10 15:56:32 +01:00
Davide Iadeluca
8205ae5bf5 [1.x] fix(Mentions): allow renderer to be used without context (#3953)
* fix(Mentions): allow renderer to be used without context

* test(Mentions): implement test for rendering post without context
2024-01-10 09:53:10 +00:00
flarum-bot
ac6f4d4d0c Bundled output for commit 56b2b3b2bc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-01-06 17:07:40 +00:00
Sami Mazouz
56b2b3b2bc fix(package-manager): bugs 2024-01-06 18:00:09 +01:00
Sami Mazouz
7fb0e08c0a fix(package-manager): file not found exception 2024-01-06 13:07:02 +01:00
IanM
2a693db1b6 chore: prep 1.8.5 release 2024-01-05 15:47:32 +00:00
IanM
7d70328471 [1.x] fix: Logout controller allows open redirects (#3948)
* fix: prevent open redirects on logout controller

* use clearer config key

* cast url as string, reinstate guest redirect

* clean up a little

* simplify

* return Uri

* resolve ternary always true

* simplify some more

* remove extra newline

* handle malformed uri

* chore: requested changes
2024-01-05 15:33:10 +00:00
Sami Mazouz
45a8b572e3 fix: package name require format 2024-01-04 14:14:45 +01:00
flarum-bot
5d14f96c32 Bundled output for commit 2299541e4d
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-12-18 12:50:33 +00:00
Sami Mazouz
2299541e4d feat: package manager improvements (#3943)
* chore: track
* Apply fixes from StyleCI
* chore: track
* Apply fixes from StyleCI
* fix: installing beta packages #3792
* chore: guess package not found error
* Apply fixes from StyleCI
* feat: queue improvements
* feat: queue improvements
* fix: issues with job failure and unique runs
* fix: enforce one composer action at a time
* feat: add cause to queued command output
* Apply fixes from StyleCI
* feat: add soft & hard extension update options
* chore: explain why an extension cannot be removed
* chore: remove test
* chore: simplify
* docs: readme
* Apply fixes from StyleCI
* fea: allow adding repositories and auth methods
* chore: prevent future issues when min stability is set
* chore: typings check
* fix: phpstan
* Apply fixes from StyleCI
* fix: bugs
2023-12-18 13:44:33 +01:00
Sami Mazouz
a131132654 chore: prepare 1.8.4 2023-12-14 14:56:10 +01:00
Sami Mazouz
7743a2bcd4 chore: apply textformatter constraint to monorepo as well 2023-12-14 14:51:46 +01:00
Sami Mazouz
62080303bf fix(1.x): textformatter 2.15 has breaking changes (#3946) 2023-12-14 14:44:30 +01:00
IanM
480093d023 chore(1.x): enable testing on PHP 8.3 (#3933) 2023-11-23 19:02:08 +01:00
Rafał Całka
1c421fc266 fix(1.x,approval): correct PostWasApproved event trigger condition (#3925) 2023-11-17 17:58:14 +01:00
Ian Morland
f07336e204 chore: prep 1.8.3 release 2023-10-18 19:47:50 +01:00
IanM
95061a2ed4 fix: console extender does not accept ::class (#3900) 2023-10-18 19:39:45 +01:00
IanM
c3fadbf6b1 [1.x] Conditional extender instantiation (#3898)
* chore: create tests to highlight the conditional instantiation problem

* Apply fixes from StyleCI

* add callback and invokable class + tests

* Apply fixes from StyleCI

* address stan issue on php 8.2

* Revert "address stan issue on php 8.2"

This reverts commit 1fc2c8801a.

* attempt to make stan happy

* Revert "attempt to make stan happy"

This reverts commit 1cc327bb3b.

* is it really that simple?

* Revert "is it really that simple?"

This reverts commit 2006755cf1.

* let's try this

* Update framework/core/src/Extend/Conditional.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2023-10-18 19:36:59 +01:00
Ian Morland
82e08e3fa5 chore: prep 1.8.2 release 2023-09-22 20:01:59 +01:00
flarum-bot
2c4a2b8d9e Bundled output for commit 00866fbba9
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-09-22 18:51:39 +00:00
Ian Morland
00866fbba9 chore: bump version 2023-09-22 19:46:39 +01:00
IanM
0d1d4d46d1 fix: missing compat exports (#3888) 2023-09-22 19:38:59 +01:00
Sami Mazouz
b1383a955f fix(1.x,suspend): suspended users can abuse avatar upload (#3890)
* fix(1.x,suspend): suspended users can abuse avatar upload

* test: works as expected

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-09-22 19:38:33 +01:00
Sami Mazouz
daeab48ae8 chore: turn on frontend build on 1.x branch 2023-09-20 21:12:54 +01:00
Ian Morland
e03ca4406d chore: build js 2023-07-06 12:03:30 +01:00
StyleCI Bot
7894c6a69b Apply fixes from StyleCI 2023-07-05 09:31:05 +00:00
Sami Mazouz
102e31754a chore: not 1.8.2 2023-07-04 11:19:15 +01:00
Sami Mazouz
8538f9c8f6 chore: prepare v1.8.2 release 2023-07-04 11:12:55 +01:00
Sami Mazouz
5a4bb7ccf2 fix: missing slug from post mention links 2023-07-04 11:00:45 +01:00
Sami Mazouz
d2a6329689 fix(mentions): cannot use mentionables extender (#3849) 2023-07-04 10:56:52 +01:00
Rafael Horvat
2bc2899a1d fix(mentions): missed post mentions UI changes (#3832)
Co-authored-by: Ian Morland <ian@morland.me>
2023-07-01 17:44:59 +01:00
Sami Mazouz
5437bf5c23 chore: prepare v1.8.1 release
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-23 19:24:51 +01:00
flarum-bot
717af13bb1 Bundled output for commit e72541e35d
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-22 21:58:15 +00:00
Sami Mazouz
e72541e35d fix: recover temporary solution for html entities in browser title
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-22 22:49:20 +01:00
Sami Mazouz
577890d89c fix: custom contrast color affected by parents
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-22 22:23:11 +01:00
Sami Mazouz
253a3d281d fix: reply placeholder wrong positioning
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-22 21:58:38 +01:00
flarum-bot
d27f952584 Bundled output for commit e5abffc75b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-20 16:46:42 +00:00
Sami Mazouz
e5abffc75b chore: v1.8 preparations
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-20 16:08:42 +01:00
Sami Mazouz
d1059c1cc7 fix: improve avatar upload functionality
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-20 15:15:53 +01:00
flarum-bot
777c304ab7 Bundled output for commit 789246b621
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-17 10:47:32 +00:00
Sami Mazouz
789246b621 fix(regression): slidable mark read showing for read discussions
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-17 11:37:33 +01:00
Sami Mazouz
980cfd6c28 Update prepare-release.yml 2023-05-17 09:51:06 +01:00
Sami Mazouz
65390a4fc0 test: patch phpstan error
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-16 19:57:57 +01:00
Sami Mazouz
c7c86a77e9 fix(regression): newCollection does not accept base collection
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-16 19:25:23 +01:00
Sami Mazouz
f1f6051deb fix(regression): lost spacing between tag label icon and text
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-16 19:21:04 +01:00
Sami Mazouz
bded3da42d fix(regression): queryVisibleTo accepts nullable actor
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-16 19:17:07 +01:00
Sami Mazouz
231cee1f78 fix(regression): newCollection accepts collections
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-15 17:31:23 +01:00
flarum-bot
f6c9bbb427 Bundled output for commit feb968780a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-14 20:41:53 +00:00
Sami Mazouz
feb968780a fix(regression): missing TagsLabel class
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-14 21:34:34 +01:00
Sami Mazouz
5b89d3e91a chore(regression): use correct imports from core js
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-14 21:34:17 +01:00
Daniël Klabbers
ba7599e6fe chore: bbcode not psr autoloaded 2023-05-09 09:10:37 +02:00
Sami Mazouz
80b34d1164 fix: discussion page showing horizontal scroll on iOS (#3821)
Co-authored-by: David Wheatley <david@davwheat.dev>
2023-05-08 09:28:32 +01:00
Sami Mazouz
3accdc322c fix(regression): fetch promise rejections not handled
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-07 22:44:25 +01:00
flarum-bot
4247e54c64 Bundled output for commit ef35faaded
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-07 21:37:58 +00:00
Sami Mazouz
ef35faaded fix(regression): wrong app import in forum JS
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-07 22:31:07 +01:00
flarum-bot
715b8c39ae Bundled output for commit 232618aba6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-07 21:24:30 +00:00
Sami Mazouz
232618aba6 fix: UserSecurityPage not exported
Fixes #3820

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-05-07 22:18:21 +01:00
flarum-bot
96e1411b7d Bundled output for commit 21b483625e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-07 17:49:29 +00:00
David Wheatley
21b483625e feat: add user creation to users list page (#3744) 2023-05-07 18:38:37 +01:00
Sami Mazouz
9363682e1c fix: filter values are not validated (#3795) 2023-05-07 18:37:53 +01:00
flarum-bot
c766881e1f Bundled output for commit e63e161be6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-05-07 16:49:15 +00:00
David Wheatley
e63e161be6 chore: major frontend JS cleanup (#3609) 2023-05-07 17:40:18 +01:00
Nicolas Peugnet
3264455068 fix(testing): always clear cache in integration test's tearDown (#3818)
This prevent tests from interacting between each other through the cache.
2023-05-02 19:24:14 +01:00
Sami Mazouz
d7fcd8a9e5 fix(bbcode): highlight.js does not work after changing post content (#3817)
* fix(bbcode): highlight.js does not work after changing post content

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore(bbcode): organize bbcode code

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-05-02 09:39:43 +01:00
IanM
b4f3f0558e feat: cli command for enabling or disabling an extension (#3816) 2023-05-01 08:06:52 +01:00
Sami Mazouz
919c3bb770 perf: speed up post creation time (#3808)
* chore: drop unused visibility checking in notif syncer

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* perf: eager load parsed mentions

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* perf: eager load some relations needed for visibility checking

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* perf: trigger mentions notifications in a queueable job

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* fix: broken tag mentions

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-04-30 10:10:31 +01:00
Sami Mazouz
7298ccb301 feat(testing): add a trait to flush the formatter cache in tests (#3811) 2023-04-30 09:48:46 +01:00
flarum-bot
cfdd6910eb Bundled output for commit 7ebeb9c0a5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-29 17:42:13 +00:00
Sami Mazouz
7ebeb9c0a5 fix: unreadable badge icon on certain colors (#3810) 2023-04-29 18:35:18 +01:00
Sami Mazouz
af3f91ca5b fix(tags): DiscussionTaggedPost shows tags as deleted (#3812)
* fix(tags): `DiscussionTaggedPost` shows tags as `deleted`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-04-29 09:48:01 +02:00
Sami Mazouz
4784307e26 fix(bbcode): localize quote wrote string (#3809)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-27 20:26:28 +01:00
flarum-bot
105b22976e Bundled output for commit fea31a8290
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-24 17:10:43 +00:00
Robert Korulczyk
fea31a8290 Fix encoding of page title. (#3768) 2023-04-24 18:00:22 +01:00
Sami Mazouz
accdfde6e1 fix(mentions): mentions XHR fired even after mentioning is done (#3806)
* fix(mentions): mentions XHR fired even after mentioning is done

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: simplify diff

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-24 17:57:41 +01:00
flarum-bot
7684a1086a Bundled output for commit f8577c8078
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-22 08:52:48 +00:00
luk
f8577c8078 fix: isDark() utility can receive null value (#3774)
* Make isDark() not fail as easily with invalid input

Add early return if input looks fishy, minor refactoring and improvements of the entire method.

* Fix double quotes

* Run prettier 🙄

* chore: review

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-22 09:45:51 +01:00
flarum-bot
e55844f3db Bundled output for commit 1d20f4d4aa
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-21 06:52:38 +00:00
Rafael Horvat
1d20f4d4aa Change some methods from private to protected, to be able to extend the affected classes (#3802) 2023-04-21 07:42:42 +01:00
Sami Mazouz
803f0cd0f4 fix(tags): not all tags are loaded in the permission grid (#3804)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-21 07:38:09 +01:00
IanM
8576df1a43 fix: null as 2nd param is deprecated (#3801) 2023-04-19 19:07:10 +02:00
flarum-bot
1792e22639 Bundled output for commit 5e281136f6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-19 12:05:15 +00:00
Sami Mazouz
5e281136f6 feat(mentions,tags): tag mentions (#3769)
* feat: add tag search

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat(mentions): tag mentions backend

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat: tag mention design

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* refactor: revamp mentions autocomplete

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: unauthorized mention of hidden groups

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat(mentions,tags): use hash format for tag mentions

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* refactor: frontend mention format API with mentionable models

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat: implement tag search on the frontend

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: tag color contrast

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: tag suggestions styling

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* test: works with disabled tags extension

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: move `MentionFormats` to `formats`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: mentions preview bad styling

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* docs: further migration location clarification

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* fix: bad test namespace

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: phpstan

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: conditionally add tag related extenders

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* feat(phpstan): evaluate conditional extenders

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* feat: use mithril routing for tag mentions

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-04-19 12:58:11 +01:00
flarum-bot
b868c3d763 Bundled output for commit 297a2d8c5c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-19 11:48:24 +00:00
Sami Mazouz
297a2d8c5c fix: deleting a discussion from the profile does not visually remove it (#3799)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-19 12:37:30 +01:00
flarum-bot
c0af41c305 Bundled output for commit d0669b08aa
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-19 08:32:02 +00:00
Sami Mazouz
d0669b08aa perf(likes): limit likes relationship results (#3781)
* perf(core,mentions): limit `mentionedBy` post relation results

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: use a static property to allow customization

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: use a static property to allow customization

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: include count in show post endpoint

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: consistent locale key format

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: forgot to delete `FilterVisiblePosts`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* test: `mentionedByCount` must not include invisible posts to actor

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: visibility scoping on `mentionedByCount`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: `loadAggregates` conflicts with visibility scopers

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: phpstan

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* perf(likes): limit `likes` relationship results

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: simplify

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* test: `likesCount` is as expected

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: IanM <16573496+imorland@users.noreply.github.com>
2023-04-19 09:22:41 +01:00
flarum-bot
6b8e9ce1db Bundled output for commit fbbece4bda
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-19 07:30:05 +00:00
Sami Mazouz
fbbece4bda perf(core,mentions): limit mentionedBy post relation results (#3780)
* perf(core,mentions): limit `mentionedBy` post relation results

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: use a static property to allow customization

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: use a static property to allow customization

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: include count in show post endpoint

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: consistent locale key format

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* chore: forgot to delete `FilterVisiblePosts`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* test: `mentionedByCount` must not include invisible posts to actor

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: visibility scoping on `mentionedByCount`

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* fix: `loadAggregates` conflicts with visibility scopers

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

* Apply fixes from StyleCI

* chore: phpstan

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-04-19 08:23:08 +01:00
dependabot[bot]
13e655aca5 chore(deps): bump webpack from 5.75.0 to 5.76.0 (#3761)
Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.75.0...v5.76.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-19 07:45:00 +01:00
flarum-bot
c00e8706e1 Bundled output for commit 1b5da13e8a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-17 08:14:57 +00:00
Robert Korulczyk
1b5da13e8a fix: infinite scroll not initialized for notifications on big screens (#3733) 2023-04-17 09:07:00 +01:00
flarum-bot
ecfbcd1c30 Bundled output for commit 818a100625
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-17 08:01:58 +00:00
Tristian Kelly
818a100625 feat: add delete own posts permission (#3784) 2023-04-17 08:53:51 +01:00
flarum-bot
176b5540d8 Bundled output for commit 2e76a8ecb5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-16 20:54:45 +00:00
Sami Mazouz
2e76a8ecb5 fix: color input overflowing the input box (#3796)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:33:57 +01:00
Sami Mazouz
11aa7bbb35 fix: unread count in post stream not visible (#3791)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:14:54 +01:00
Sami Mazouz
3a26c29935 feat: provide old content to Revised event (#3789)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:14:17 +01:00
Sami Mazouz
94e92cf24e fix: approving a post does not bump user comment_count (#3790)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:13:57 +01:00
Sami Mazouz
aa33cfd1f8 fix(a11y): reply placeholder not accessible (#3793)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:13:32 +01:00
Sami Mazouz
4901c586ce chore: drop usage of jquery in install and update interfaces (#3797) 2023-04-16 21:12:47 +01:00
Sami Mazouz
7a6d477550 fix: notification subject discussion eager loading fails (#3788) 2023-04-16 21:12:01 +01:00
Sami Mazouz
b89a01c010 chore: extensibility improvements (#3729)
* chore: improve tags page extensibility
* chore: improve discussion list item extensibility
* chore: improve change password modal extensibility
* chore: item-listify tags page
* chore: item-listify change email modal
* chore: simplify data flow

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 21:05:23 +01:00
flarum-bot
8b11fef3ee Bundled output for commit 8a114cd826
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-16 11:48:33 +00:00
Sami Mazouz
8a114cd826 fix(regression): styling and semantics of header tag are incorrect
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-16 12:41:51 +01:00
flarum-bot
62c93b4a05 Bundled output for commit fab71f2d01
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-15 15:29:22 +00:00
Sami Mazouz
fab71f2d01 fix(package-manager): available core updates cause an error in the dashboard
Fixes #3776

Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-04-15 16:21:45 +01:00
Sami Mazouz
e8c867dcac fix: circular dependencies disable all involved extensions (#3785) 2023-04-12 21:59:06 +01:00
flarum-bot
1247a7f1dd Bundled output for commit b0aad1a2d6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-04-10 20:09:56 +00:00
Rafał Całka
b0aad1a2d6 fix(tags): tag discussion modal filters with exact matches only after first index (#3786)
* feat: Update tag filtering to include partial matches

* fix: Case insensitive filtering
2023-04-10 21:01:18 +01:00
flarum-bot
bddc9d96f2 Bundled output for commit d684248492
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-23 08:10:20 +00:00
IanM
d684248492 fix: empty string displayed as SelectDropdown title (#3773)
* fix: empty string displayed as SelectDropdown title

* chore: remove import

* chore: ts-ignore

* Update framework/core/js/src/common/components/SelectDropdown.tsx

Co-authored-by: David Wheatley <david@davwheat.dev>

---------

Co-authored-by: David Wheatley <david@davwheat.dev>
2023-03-23 08:02:59 +00:00
Rafael Horvat
85b63681ae Fix: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous (#3772) 2023-03-21 10:32:23 +00:00
Sami Mazouz
8372363cc2 feat: conditional extenders (#3759) 2023-03-14 21:53:16 +01:00
Ngô Quốc Đạt
a6a067ad48 chore: update to PHP 8.2 in frontend workflow (#3755) 2023-03-12 13:58:06 +01:00
Sami Mazouz
241eba4d0c chore: mark start of 1.8.0 development
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-12 13:56:39 +01:00
Sami Mazouz
a6b12826c3 chore: 1.7.1 preparations
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-12 13:28:04 +01:00
Sami Mazouz
dd868ab44e fix: improve sessions user UI on mobile
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-12 13:21:21 +01:00
flarum-bot
5f3e0d6a09 Bundled output for commit 661b9d7d9a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-12 11:45:23 +00:00
Robert Korulczyk
661b9d7d9a chore: hide developer tokens section in if there is nothing to display or create (#3753) 2023-03-12 12:37:49 +01:00
flarum-bot
b7498d6cb1 Bundled output for commit e7c55532a0
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-12 09:46:12 +00:00
Robert Korulczyk
e7c55532a0 fix: hardcoded language strings in StatusWidget (#3754) 2023-03-12 10:37:57 +01:00
Robert Korulczyk
cce6b74fce fix: missing parameter names in token title translation. (#3752) 2023-03-12 10:33:19 +01:00
flarum-bot
da651c722b Bundled output for commit abc9670659
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-11 08:14:06 +00:00
Sami Mazouz
abc9670659 fix(tags): incorrect max and min primary tags used
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-11 09:05:12 +01:00
Sami Mazouz
b66fe5dd5f chore(release): preparations
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-09 19:00:32 +01:00
flarum-bot
7d79895ae0 Bundled output for commit 3ab4529232
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-09 15:35:22 +00:00
Sami Mazouz
3ab4529232 fix(qa): apply color contrast fix when colored only
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-09 16:28:32 +01:00
flarum-bot
360a2ba1d8 Bundled output for commit eaa4063fef
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-08 19:21:16 +00:00
Sami Mazouz
eaa4063fef fix(qa): attempt to fix akismet error
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-08 20:14:09 +01:00
flarum-bot
72d277bd45 Bundled output for commit 28e3ccfde6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-03-08 17:34:35 +00:00
Sami Mazouz
28e3ccfde6 fix(qa): increase YIQ and fix menu item title
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-08 18:25:04 +01:00
Sami Mazouz
3f864bafc8 fix(regression): custom less validation check
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-06 15:24:03 +01:00
Sami Mazouz
3af0481f30 test: remove use of deprecated phpunit assertion
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-06 15:03:33 +01:00
Sami Mazouz
1761660c98 fix: disallow certain dangerous LESS features
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
2023-03-04 20:38:19 +01:00
633 changed files with 10755 additions and 3384 deletions

View File

@@ -25,7 +25,7 @@ on:
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
type: string
required: false
default: '["7.3", "7.4", "8.0", "8.1", "8.2"]'
default: '["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]'
php_extensions:
description: PHP extensions to install.
@@ -45,13 +45,25 @@ on:
required: false
default: error_reporting=E_ALL
runner_type:
description: The type of runner to use for the jobs. This should be one of the types supported by the `runs-on` keyword.
type: string
required: false
default: 'ubuntu-latest'
secrets:
composer_auth:
description: The Composer auth tokens to use for private packages.
required: false
env:
COMPOSER_ROOT_VERSION: dev-main
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
COMPOSER_AUTH: ${{ secrets.composer_auth }}
jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
strategy:
matrix:
@@ -91,6 +103,8 @@ jobs:
# Include testing PHP 8.2 with deprecation warnings disabled.
- php: 8.2
php_ini_values: error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
- php: 8.3
php_ini_values: error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
# To reduce number of actions, we exclude some PHP versions from running with some DB versions.
exclude:
@@ -158,7 +172,7 @@ jobs:
COMPOSER_PROCESS_TIMEOUT: 600
phpstan:
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
strategy:
matrix:

View File

@@ -74,7 +74,7 @@ on:
description: The node version to use for the workflow.
type: number
required: false
default: 16
default: 20
js_package_manager:
description: "Enable TypeScript?"
@@ -86,30 +86,41 @@ on:
type: string
required: false
runner_type:
description: The type of runner to use for the jobs. This should be one of the types supported by the `runs-on` keyword.
type: string
required: false
default: 'ubuntu-latest'
secrets:
bundlewatch_github_token:
description: The GitHub token to use for Bundlewatch.
required: false
composer_auth:
description: The Composer auth tokens to use for private packages.
required: false
env:
COMPOSER_ROOT_VERSION: dev-main
ci_script: ${{ inputs.js_package_manager == 'yarn' && 'yarn install --immutable' || 'npm ci' }}
cache_dependency_path: ${{ inputs.cache_dependency_path || format(inputs.js_package_manager == 'yarn' && '{0}/yarn.lock' || '{0}/package-lock.json', inputs.frontend_directory) }}
COMPOSER_AUTH: ${{ secrets.composer_auth }}
DISABLE_V8_COMPILE_CACHE: 1
jobs:
build:
name: Checks & Build
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
if: >-
((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.event_name != 'pull_request')
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
@@ -118,7 +129,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.2'
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
tools: composer:v2
@@ -132,7 +143,7 @@ jobs:
working-directory: ${{ inputs.frontend_directory }}
- name: JS Checks & Production Build
uses: flarum/action-build@v3
uses: flarum/action-build@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: ${{ inputs.build_script }}

View File

@@ -1,4 +1,4 @@
name: Package Manager PHP
name: Extension Manager PHP
on: [workflow_dispatch, push, pull_request]

View File

@@ -10,7 +10,7 @@ jobs:
backend_directory: ./
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
main_git_branch: 1.x
enable_tests: true
# @TODO: fix bundlewatch
enable_bundlewatch: false

View File

@@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v3
- name: Prepare release
uses: flarum/action-release@master
env:
NEXT_TAG: ${{ inputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPEN_COLLECTIVE_TOKEN: ${{ secrets.OPEN_COLLECTIVE_TOKEN }}
with:
next_tag: ${{ inputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
open_collective_token: ${{ secrets.OPEN_COLLECTIVE_TOKEN }}

View File

@@ -1,6 +1,174 @@
# Changelog
# [v1.6.3](https://github.com/flarum/framework/compare/v1.6.2...v1.6.3)
## [v1.8.7](https://github.com/flarum/framework/compare/v1.8.6...v1.8.7)
### Fixed
* BasicsPage not viewable if only one language pack enabled, and/or `flarum/nicknames` not enabled (https://github.com/flarum/framework/pull/4062)
## [v1.8.6](https://github.com/flarum/framework/compare/v1.8.5...v1.8.6)
### Fixed
* reset admin page save button in catch handler (https://github.com/flarum/framework/pull/3963)
* suspended users can remove avatar (https://github.com/flarum/framework/pull/3998)
* return null if content left empty in formatter (https://github.com/flarum/framework/pull/4059)
### Changed
* allow DiscussionsSearchSource to be extended (https://github.com/flarum/framework/pull/4025)
* allow modifying the discussion title on PostsUserPage (https://github.com/flarum/framework/pull/4031)
* make it easier to modify AppearancePage, BasicsPage, MailPage (https://github.com/flarum/framework/pull/4037)
* point fontawesome links at v5 free (https://github.com/flarum/framework/pull/4038)
* make WelcomeHero extensible (https://github.com/flarum/framework/pull/4039)
* make PostMeta extensible (https://github.com/flarum/framework/pull/4040)
* extensible TagHero (https://github.com/flarum/framework/pull/4041)
* allow extending PostPreview content (https://github.com/flarum/framework/pull/4043)
* allow classes that extends AbstractJob to be placed on a specified queue (https://github.com/flarum/framework/pull/4026)
* use common component for ip address display (https://github.com/flarum/framework/pull/4042)
* make it easier to add content after the first post (https://github.com/flarum/framework/pull/4050)
* improve extensibility of IndexPage (https://github.com/flarum/framework/pull/4045)
* improve extensibility of DiscussionPage (https://github.com/flarum/framework/pull/4046)
* backport & improve extensibility of DiscussionListItem (https://github.com/flarum/framework/pull/4048)
* improve & use extensibility of CommentPost & Post (https://github.com/flarum/framework/pull/4047)
* allow labels of PostStreamScrubber to be customized (https://github.com/flarum/framework/pull/4049)
* allow to customize time formats through translations (https://github.com/flarum/framework/pull/4053)
### Added
* Export all missing modules in compat (https://github.com/flarum/framework/pull/4044)
* Add (some) missing shims (https://github.com/flarum/framework/pull/4027)
* provide an 'actions' dropdown for extensions to add their additional buttons to the admin UserListPage (https://github.com/flarum/framework/pull/4054)
## [v1.8.5](https://github.com/flarum/framework/compare/v1.8.4...v1.8.5)
### Fixed
* Logout controller allows open redirects [#3948]
## [v1.8.4](https://github.com/flarum/framework/compare/v1.8.3...v1.8.4)
### Fixed
* `s9e/textformatter` 2.15 has breaking changes [#3946]
## [v1.8.3](https://github.com/flarum/framework/compare/v1.8.2...v1.8.3)
### Fixed
* Console extender does not accept ::class [#3900]
* Conditional extender instantiation [#3898]
## [v1.8.2](https://github.com/flarum/framework/compare/v1.8.1...v1.8.2)
### Fixed
* suspended users can abuse avatar upload [#3890]
* missing compat exports [#3888]
## [v1.8.1](https://github.com/flarum/framework/compare/v1.8.0...v1.8.1)
### Fixed
* recover temporary solution for html entities in browser title (e72541e35de4f71f9d870bbd9bb46ddf586bdf1d)
* custom contrast color affected by parents (577890d89c593ae5b6cb96083fab69e2f1ae600c)
* reply placeholder wrong positioning (253a3d281dbf5ce3fa712b629b80587cf67e7dbe)
* (mentions) missed post mentions UI changes with lazy loading [#3832]
* (mentions) cannot use newly introduced mentionables extender [#3849]
* (mentions) missing slug from post mention links ([5a4bb7c](5a4bb7ccf226f66dd44816cb69b3d7cfe4ad7f7c))
## [v1.8.0](https://github.com/flarum/framework/compare/v1.7.1...v1.8.0)
### Fixed
- (a11y) reply placeholder not accessible [#3793]
- (bbcode) highlight.js does not work after changing post content [#3817]
- (bbcode) localize quote `wrote` string [#3809]
- (mentions) mentions XHR fired even after mentioning is done [#3806]
- (package-manager) available core updates cause an error in the dashboard ([fab71f2](fab71f2d01fa20ce9b3002833339dc5ea3ea6301))
- (tags) not all tags are loaded in the permission grid [#3804]
- (tags) tag discussion modal filters with exact matches only after first index [#3786]
- (testing) always clear cache in integration test's tearDown [#3818]
- `UserSecurityPage` not exported ([232618a](232618aba604ab003425df38b895208c863d3260))
- `isDark()` utility can receive null value [#3774]
- approving a post does not bump user `comment_count` [#3790]
- circular dependencies disable all involved extensions [#3785]
- color input overflowing the input box [#3796]
- deleting a discussion from the profile does not visually remove it [#3799]
- discussion page showing horizontal scroll on iOS [#3821]
- empty string displayed as SelectDropdown title [#3773]
- filter values are not validated [#3795]
- infinite scroll not initialized for notifications on big screens [#3733]
- notification subject discussion eager loading fails [#3788]
- null as 2nd param in `preg_match` is deprecated [#3801]
- unread count in post stream not visible [#3791]
- unreadable badge icon on certain colors [#3810]
- integrity constraint violation [#3772]
### Changed
- (core,mentions) limit `mentionedBy` post relation results [#3780]
- (likes) limit `likes` relationship results [#3781]
- Change some methods from private to protected, to be able to extend the affected classes [#3802]
- Do not catch exceptions when testing Console commands [#3813]
- drop usage of jquery in `install` and `update` interfaces [#3797]
- extensibility improvements [#3729]
- major frontend JS cleanup [#3609]
- revert ineffective code for encoding of page title [#3768]
- speed up post creation time [#3808]
### Added
- (mentions,tags) tag mentions [#3769]
- add delete own posts permission [#3784]
- add a trait to flush the formatter cache in tests [#3811]
- add user creation to users list page [#3744]
- cli command for enabling or disabling an extension [#3816]
- conditional extenders [#3759]
- provide old content to `Revised` event [#3789]
## [v1.7.1](https://github.com/flarum/framework/compare/v1.7.0...v1.7.1)
### Fixed
- (tags) composer tag selection modal using wrong primary max & min numbers (abc9670659426b765274376945b818b70d84848c)
- missing parameter names in token title translation. (#3752)
- hardcoded language strings in StatusWidget (#3754)
- hide developer tokens section in if there is nothing to display or create (#3753)
- improve sessions user UI on mobile (dd868ab44e11e892d020e3b9412553c6a789e68d)
## [v1.7.0](https://github.com/flarum/framework/compare/v1.6.3...v1.7.0)
### Added
- (actions) allow running JS tests in GH actions [#3730]
- (core) PHP 8.2 Support [#3709]
- (jest) create jest config package for unit testing [#3678]
- (jest) mithril component testing [#3679]
- (phpstan) foundation for usage in extensions [#3666]
- (seo) Do not use h3 header for poster author in posts stream [#3732]
- (seo) Use h2 header for discussions on discussions list [#3731]
- (seo) shift h1 tag from logo to discussion title [#3724]
- (tags) admin tag selection component (reusable tag selection modal) [#3686]
- Admin User Search [#3712]
- access tokens user management UI [#3587]
- add display name column to admin users list [#3740]
- allow push additional items to the end of the poststream [#3691]
- allow using utf8 characters in tag slugs [#3588]
- expose queue driver, schedule status [#3593]
- expose {time} to eventPost data, fix renamed tooltip [#3698]
- frontend `Model` extender [#3646]
- global logout to clear all sessions, access tokens, email tokens and password tokens [#3605]
- improved page navigation for users list [#3741]
- introduce frontend extenders [#3645]
### Fixed
- (mentions) correctly convert a 3 char. hex color to a 6 char. one [#3694]
- (mentions) post reply mention missing notification on approval [#3738]
- (phpstan) adapt phpstan package for extension use [#3727]
- (tags) clickable tag labels have underline [#3737]
- (tags) tag text color contrast [#3653]
- 3 digit hex color value in color input not supported [#3706]
- column `id` can be ambiguous in group filter with extensions [#3696]
- disallow certain dangerous LESS features ([1761660](1761660c98ea5a3e9665fb8e6041d1f2ee62a444))
- evaluated page title content [#3684]
- invalid translation key for scheduler dashboard [#3736]
- load actor.groups on showforumcontroller [#3716]
- make go-to-page input number-like [#3743]
- normal logout affects all sessions [#3571]
- permissions table on mobile is unusable [#3722]
- post dropdown opens all dropdowns in `.Post-actions` [#3675]
- typo in Formatter extender docblock [#3676]
- undefined showing in dropdown active title [#3700]
### Changed
- (phpstan) enable phpstan in bundled extensions [#3667]
- Add missing states exports to `compat.ts` [#3683]
- Indicate cross-origin request in generic error message [#3669]
- Merge branch 'release/v1.6.2' ([e0b9dcf](e0b9dcfbcd7db175368dbc98255f9223da8df17d))
- The negate field doesn't get used, which means you cant exclude tags [#3713]
- Update forum.less to fix the misalignment of the choose tags button [#3726]
- `yarn audit-fix` ([8ddb0fe](8ddb0feb097dad06c5763107d7a7f7b5a55562c4))
- `yarn` ([ee1e04c](ee1e04cdc26b3e63057a58899f32f482901a95fd))
- convert `Dropdown` components to TS [#3608]
- fix php 8.1 on preg_match 2nd argument being null, which also optimizes slightly ([d7b9a03](d7b9a03f31847c39631ba495df8f515509774610))
- improve group mentions parsing [#3723]
- prepare `@flarum/jest-config` for release ([748cca6](748cca6d12f8b1744a6017c09395725bdbb4a118))
- remove use of deprecated phpunit assertion ([3af0481](3af0481f304277f5380fac9c9b169a7fa651f53b))
- set flarum version to 1.7.0 for dev ([2517bc0](2517bc0f70b0f0e3d3ea3f6ae06af8604d89b25d))
- update JS dependencies [#3695]
## [v1.6.3](https://github.com/flarum/framework/compare/v1.6.2...v1.6.3)
### Fixed
* Post mentions can be used to read any post on the forum without access control (ab1c868b978e8b0d09a5d682c54665dae17d0985).
* Notifications can leak restricted content (d0a2b95dca57d3dae9a0d77b610b1cb1d0b1766a).

View File

@@ -1,5 +1,5 @@
<p align="center">
<a href="https://flarum.org/"><img src="https://flarum.org/assets/img/logo.png"></a>
<a href="https://flarum.org/"><img src="https://flarum.org/images/flarum.svg"></a>
</p>
<p align="center">
@@ -7,7 +7,6 @@
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/packagist/dt/flarum/core" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/github/v/release/flarum/core?sort=semver" alt="Latest Version"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/packagist/l/flarum/core" alt="License"></a>
<a href="https://huntr.dev/bounties/disclose/?target=https://github.com/flarum/core"><img src="https://cdn.huntr.dev/huntr_security_badge_mono.svg" alt="huntr"></a>
<a href="https://github.styleci.io/repos/28257573"><img src="https://github.styleci.io/repos/28257573/shield?style=flat" alt="StyleCI"></a>
</p>
@@ -38,3 +37,4 @@ If you discover a security vulnerability within Flarum, please send an e-mail to
## License
Flarum is open-source software licensed under the [MIT License](https://github.com/flarum/flarum/blob/master/LICENSE).

View File

@@ -40,12 +40,13 @@
"Flarum\\": "framework/core/src",
"Flarum\\Akismet\\": "extensions/akismet/src",
"Flarum\\Approval\\": "extensions/approval/src",
"Flarum\\BBCode\\": "extensions/bbcode/src",
"Flarum\\Flags\\": "extensions/flags/src",
"Flarum\\Likes\\": "extensions/likes/src",
"Flarum\\Lock\\": "extensions/lock/src",
"Flarum\\Mentions\\": "extensions/mentions/src",
"Flarum\\Nicknames\\": "extensions/nicknames/src",
"Flarum\\PackageManager\\": "extensions/package-manager/src",
"Flarum\\ExtensionManager\\": "extensions/package-manager/src",
"Flarum\\Pusher\\": "extensions/pusher/src",
"Flarum\\Statistics\\": "extensions/statistics/src",
"Flarum\\Sticky\\": "extensions/sticky/src",
@@ -73,7 +74,7 @@
"flarum/markdown": "self.version",
"flarum/mentions": "self.version",
"flarum/nicknames": "self.version",
"flarum/package-manager": "self.version",
"flarum/extension-manager": "self.version",
"flarum/pusher": "self.version",
"flarum/statistics": "self.version",
"flarum/sticky": "self.version",
@@ -126,7 +127,8 @@
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"pusher/pusher-php-server": "^2.2",
"s9e/text-formatter": "^2.3.6",
"s9e/text-formatter": ">=2.3.6 <2.15",
"staudenmeir/eloquent-eager-limit": "^1.0",
"sycho/json-api": "^0.5.0",
"sycho/sourcemap": "^2.0.0",
"symfony/config": "^5.2.2",

View File

@@ -19,8 +19,8 @@
}
],
"require": {
"flarum/core": "^1.6",
"flarum/approval": "^1.2"
"flarum/core": "^1.8",
"flarum/approval": "^1.7"
},
"autoload": {
"psr-4": {

View File

@@ -1,2 +1,2 @@
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.core.compat["common/extend"],r=flarum.core.compat["forum/app"];var a=t.n(r);const n=flarum.core.compat["forum/utils/PostControls"];var m=t.n(n);const s=flarum.core.compat["forum/components/CommentPost"];var l=t.n(s);a().initializers.add("flarum-akismet",(function(){(0,o.extend)(m(),"destructiveControls",(function(t,e){if(t.has("approve")){var o=e.flags();if(o&&o.some((function(t){return"akismet"===(null==t?void 0:t.type())}))){var r=t.get("approve");r&&"object"==typeof r&&"children"in r&&(r.children=a().translator.trans("flarum-akismet.forum.post.not_spam_button"))}}})),(0,o.override)(l().prototype,"flagReason",(function(t,e){return"akismet"===e.type()?a().translator.trans("flarum-akismet.forum.post.akismet_flagged_text"):t(e)}))}))})(),module.exports=e})();
(()=>{var t={n:e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const o=flarum.core.compat["common/extend"],r=flarum.core.compat["forum/app"];var a=t.n(r);const n=flarum.core.compat["forum/utils/PostControls"];var s=t.n(n);const l=flarum.core.compat["forum/components/Post"];var u=t.n(l);a().initializers.add("flarum-akismet",(function(){(0,o.extend)(s(),"destructiveControls",(function(t,e){if(t.has("approve")){var o=e.flags();if(o&&o.some((function(t){return"akismet"===(null==t?void 0:t.type())}))){var r=t.get("approve");r&&"object"==typeof r&&"children"in r&&(r.children=a().translator.trans("flarum-akismet.forum.post.not_spam_button"))}}})),(0,o.override)(u().prototype,"flagReason",(function(t,e){return"akismet"===e.type()?a().translator.trans("flarum-akismet.forum.post.akismet_flagged_text"):t(e)}))}))})(),module.exports=e})();
//# sourceMappingURL=forum.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"forum.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,CAAM,ECLdF,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,IAE1E,ECNDR,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,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,iBCAlD,EAA+BF,OAAOC,KAAKC,OAAO,a,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,4B,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,gC,aCSxDC,IAAAA,aAAAA,IAAqB,kBAAkB,YACrCC,EAAAA,EAAAA,QAAOC,IAAc,uBAAuB,SAAUC,EAAmCC,GACvF,GAAID,EAAME,IAAI,WAAY,CACxB,IAAMC,EAAQF,EAAKE,QAEnB,GAAIA,GAASA,EAAMC,MAAK,SAACC,GAAI,MAAsB,aAAb,MAAJA,OAAI,EAAJA,EAAMC,OAAoB,IAAG,CAC7D,IAAMC,EAAcP,EAAMf,IAAI,WAC1BsB,GAAsC,iBAAhBA,GAA4B,aAAcA,IAClEA,EAAYC,SAAWX,IAAAA,WAAAA,MAAqB,6CAEhD,CACF,CACF,KAEAY,EAAAA,EAAAA,UAASC,IAAAA,UAAuB,cAAc,SAAUC,EAAUN,GAChE,MAAoB,YAAhBA,EAAKC,OACAT,IAAAA,WAAAA,MAAqB,kDAGvBc,EAASN,EAClB,GACF,G","sources":["webpack://@flarum/akismet/webpack/bootstrap","webpack://@flarum/akismet/webpack/runtime/compat get default export","webpack://@flarum/akismet/webpack/runtime/define property getters","webpack://@flarum/akismet/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/akismet/webpack/runtime/make namespace object","webpack://@flarum/akismet/external root \"flarum.core.compat['common/extend']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/app']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/utils/PostControls']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/components/CommentPost']\"","webpack://@flarum/akismet/./src/forum/index.ts"],"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['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/PostControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/CommentPost'];","import { extend, override } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport type Post from 'flarum/common/models/Post';\nimport type ItemList from 'flarum/common/utils/ItemList';\n\nimport PostControls from 'flarum/forum/utils/PostControls';\nimport CommentPost from 'flarum/forum/components/CommentPost';\nimport type Mithril from 'mithril';\n\napp.initializers.add('flarum-akismet', () => {\n extend(PostControls, 'destructiveControls', function (items: ItemList<Mithril.Children>, post: Post) {\n if (items.has('approve')) {\n const flags = post.flags();\n\n if (flags && flags.some((flag) => flag?.type() === 'akismet')) {\n const approveItem = items.get('approve');\n if (approveItem && typeof approveItem === 'object' && 'children' in approveItem) {\n approveItem.children = app.translator.trans('flarum-akismet.forum.post.not_spam_button');\n }\n }\n }\n });\n\n override(CommentPost.prototype, 'flagReason', function (original, flag) {\n if (flag.type() === 'akismet') {\n return app.translator.trans('flarum-akismet.forum.post.akismet_flagged_text');\n }\n\n return original(flag);\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","extend","PostControls","items","post","has","flags","some","flag","type","approveItem","children","override","CommentPost","original"],"sourceRoot":""}
{"version":3,"file":"forum.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,CAAM,ECLdF,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,IAE1E,ECNDR,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,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,iBCAlD,EAA+BF,OAAOC,KAAKC,OAAO,a,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,4B,aCAxD,MAAM,EAA+BF,OAAOC,KAAKC,OAAO,yB,aCSxDC,IAAAA,aAAAA,IAAqB,kBAAkB,YACrCC,EAAAA,EAAAA,QAAOC,IAAc,uBAAuB,SAAUC,EAAmCC,GACvF,GAAID,EAAME,IAAI,WAAY,CACxB,IAAMC,EAAQF,EAAKE,QAEnB,GAAIA,GAASA,EAAMC,MAAK,SAACC,GAAI,MAAsB,aAAb,MAAJA,OAAI,EAAJA,EAAMC,OAAoB,IAAG,CAC7D,IAAMC,EAAcP,EAAMf,IAAI,WAC1BsB,GAAsC,iBAAhBA,GAA4B,aAAcA,IAClEA,EAAYC,SAAWX,IAAAA,WAAAA,MAAqB,6CAEhD,CACF,CACF,KAEAY,EAAAA,EAAAA,UAASC,IAAAA,UAAyB,cAAc,SAAUC,EAAUN,GAClE,MAAoB,YAAhBA,EAAKC,OACAT,IAAAA,WAAAA,MAAqB,kDAGvBc,EAASN,EAClB,GACF,G","sources":["webpack://@flarum/akismet/webpack/bootstrap","webpack://@flarum/akismet/webpack/runtime/compat get default export","webpack://@flarum/akismet/webpack/runtime/define property getters","webpack://@flarum/akismet/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/akismet/webpack/runtime/make namespace object","webpack://@flarum/akismet/external root \"flarum.core.compat['common/extend']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/app']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/utils/PostControls']\"","webpack://@flarum/akismet/external root \"flarum.core.compat['forum/components/Post']\"","webpack://@flarum/akismet/./src/forum/index.ts"],"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['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/utils/PostControls'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/Post'];","import { extend, override } from 'flarum/common/extend';\nimport app from 'flarum/forum/app';\nimport type Post from 'flarum/common/models/Post';\nimport type ItemList from 'flarum/common/utils/ItemList';\n\nimport PostControls from 'flarum/forum/utils/PostControls';\nimport PostComponent from 'flarum/forum/components/Post';\nimport type Mithril from 'mithril';\n\napp.initializers.add('flarum-akismet', () => {\n extend(PostControls, 'destructiveControls', function (items: ItemList<Mithril.Children>, post: Post) {\n if (items.has('approve')) {\n const flags = post.flags();\n\n if (flags && flags.some((flag) => flag?.type() === 'akismet')) {\n const approveItem = items.get('approve');\n if (approveItem && typeof approveItem === 'object' && 'children' in approveItem) {\n approveItem.children = app.translator.trans('flarum-akismet.forum.post.not_spam_button');\n }\n }\n }\n });\n\n override(PostComponent.prototype, 'flagReason', function (original, flag) {\n if (flag.type() === 'akismet') {\n return app.translator.trans('flarum-akismet.forum.post.akismet_flagged_text');\n }\n\n return original(flag);\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","extend","PostControls","items","post","has","flags","some","flag","type","approveItem","children","override","PostComponent","original"],"sourceRoot":""}

View File

@@ -20,7 +20,7 @@
"flarum-tsconfig": "^1.0.2",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1"

View File

@@ -4,7 +4,7 @@ import type Post from 'flarum/common/models/Post';
import type ItemList from 'flarum/common/utils/ItemList';
import PostControls from 'flarum/forum/utils/PostControls';
import CommentPost from 'flarum/forum/components/CommentPost';
import PostComponent from 'flarum/forum/components/Post';
import type Mithril from 'mithril';
app.initializers.add('flarum-akismet', () => {
@@ -21,7 +21,7 @@ app.initializers.add('flarum-akismet', () => {
}
});
override(CommentPost.prototype, 'flagReason', function (original, flag) {
override(PostComponent.prototype, 'flagReason', function (original, flag) {
if (flag.type() === 'akismet') {
return app.translator.trans('flarum-akismet.forum.post.akismet_flagged_text');
}

View File

@@ -15,6 +15,7 @@
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"@flarum/core/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/flags/*": ["../../flags/js/dist-typings/*"]
}
}

View File

@@ -50,7 +50,7 @@ class Akismet
$client = new Client();
return $client->request('POST', "$this->apiUrl/$type", [
'headers' => [
'headers' => [
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
],
'form_params' => $this->params,

View File

@@ -19,8 +19,8 @@
}
],
"require": {
"flarum/core": "^1.6",
"flarum/flags": "^1.2"
"flarum/core": "^1.8",
"flarum/flags": "^1.7"
},
"autoload": {
"psr-4": {

View File

@@ -6,7 +6,7 @@
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"
},

View File

@@ -0,0 +1,15 @@
import 'flarum/common/models/Discussion';
import 'flarum/common/models/Post';
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
isApproved(): boolean;
}
}
declare module 'flarum/common/models/Post' {
export default interface Post {
isApproved(): boolean;
canApprove(): boolean;
}
}

View File

@@ -11,6 +11,7 @@ namespace Flarum\Approval\Listener;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Post\Event\Saving;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Contracts\Events\Dispatcher;
class ApproveContent
@@ -23,23 +24,42 @@ class ApproveContent
$events->listen(Saving::class, [$this, 'approvePost']);
}
/**
* @throws PermissionDeniedException
*/
public function approvePost(Saving $event)
{
$attributes = $event->data['attributes'];
$post = $event->post;
// Nothing to do if it is already approved.
if ($post->is_approved) {
return;
}
/*
* We approve a post in one of two cases:
* - The post was unapproved and the allowed action is approving it. We trigger an event.
* - The post was unapproved and the allowed actor is hiding or un-hiding it.
* We approve it silently if the action is unhiding.
*/
$approvingSilently = false;
if (isset($attributes['isApproved'])) {
$event->actor->assertCan('approve', $post);
$isApproved = (bool) $attributes['isApproved'];
} elseif (! empty($attributes['isHidden']) && $event->actor->can('approve', $post)) {
} elseif (isset($attributes['isHidden']) && $event->actor->can('approve', $post)) {
$isApproved = true;
$approvingSilently = $attributes['isHidden'];
}
if (! empty($isApproved)) {
$post->is_approved = true;
$post->raise(new PostWasApproved($post, $event->actor));
if (! $approvingSilently) {
$post->raise(new PostWasApproved($post, $event->actor));
}
}
}
}

View File

@@ -36,5 +36,10 @@ class UpdateDiscussionAfterPostApproval
$user->refreshCommentCount();
$user->save();
}
if ($post->user) {
$post->user->refreshCommentCount();
$post->user->save();
}
}
}

View File

@@ -19,7 +19,12 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"autoload": {
"psr-4": {
"Flarum\\BBCode\\": "src"
}
},
"extra": {
"branch-alias": {

View File

@@ -7,24 +7,14 @@
* LICENSE file that was distributed with this source code.
*/
use Flarum\Extend;
use s9e\TextFormatter\Configurator;
namespace Flarum\BBCode;
return (new Extend\Formatter)
->configure(function (Configurator $config) {
$config->BBCodes->addFromRepository('B');
$config->BBCodes->addFromRepository('I');
$config->BBCodes->addFromRepository('U');
$config->BBCodes->addFromRepository('S');
$config->BBCodes->addFromRepository('URL');
$config->BBCodes->addFromRepository('IMG');
$config->BBCodes->addFromRepository('EMAIL');
$config->BBCodes->addFromRepository('CODE');
$config->BBCodes->addFromRepository('QUOTE');
$config->BBCodes->addFromRepository('LIST');
$config->BBCodes->addFromRepository('DEL');
$config->BBCodes->addFromRepository('COLOR');
$config->BBCodes->addFromRepository('CENTER');
$config->BBCodes->addFromRepository('SIZE');
$config->BBCodes->addFromRepository('*');
});
use Flarum\Extend;
return [
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Formatter)
->render(Render::class)
->configure(Configure::class),
];

View File

@@ -0,0 +1,10 @@
flarum-bbcode:
##
# UNIQUE KEYS - The following keys are used in only one location each.
##
# Translations in this namespace are used by the forum user interface.
forum:
quote:
wrote: wrote

View File

@@ -0,0 +1,59 @@
<?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\BBCode;
use s9e\TextFormatter\Configurator;
class Configure
{
public function __invoke(Configurator $config)
{
$this->addTagsFromRepositories($config);
$this->adaptHighlightJs($config);
}
protected function addTagsFromRepositories(Configurator $config): void
{
$config->BBCodes->addFromRepository('B');
$config->BBCodes->addFromRepository('I');
$config->BBCodes->addFromRepository('U');
$config->BBCodes->addFromRepository('S');
$config->BBCodes->addFromRepository('URL');
$config->BBCodes->addFromRepository('IMG');
$config->BBCodes->addFromRepository('EMAIL');
$config->BBCodes->addFromRepository('CODE');
$config->BBCodes->addFromRepository('QUOTE', 'default', [
'authorStr' => '<xsl:value-of select="@author"/> <xsl:value-of select="$L_WROTE"/>'
]);
$config->BBCodes->addFromRepository('LIST');
$config->BBCodes->addFromRepository('DEL');
$config->BBCodes->addFromRepository('COLOR');
$config->BBCodes->addFromRepository('CENTER');
$config->BBCodes->addFromRepository('SIZE');
$config->BBCodes->addFromRepository('*');
}
/**
* Fix for highlight JS not working after changing post content.
*
* @link https://github.com/flarum/framework/issues/3794
*/
protected function adaptHighlightJs(Configurator $config): void
{
$codeTag = $config->tags->get('CODE');
$script = '
<script>
if(window.hljsLoader && !document.currentScript.parentNode.hasAttribute(\'data-s9e-livepreview-onupdate\')) {
window.hljsLoader.highlightBlocks(document.currentScript.parentNode);
}
</script>';
$codeTag->template = str_replace('</pre>', $script.'</pre>', $codeTag->template);
}
}

View File

@@ -0,0 +1,33 @@
<?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\BBCode;
use s9e\TextFormatter\Renderer;
use Symfony\Contracts\Translation\TranslatorInterface;
class Render
{
/**
* @var TranslatorInterface
*/
protected $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
public function __invoke(Renderer $renderer, $context, string $xml): string
{
$renderer->setParameter('L_WROTE', $this->translator->trans('flarum-bbcode.forum.quote.wrote'));
return $xml;
}
}

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"autoload": {
"psr-4": {

View File

@@ -9,7 +9,7 @@
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"
},

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"extra": {
"branch-alias": {

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,7 @@
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"
},
"scripts": {

View File

@@ -80,7 +80,7 @@ export default function addComposerAutocomplete() {
dropdown.setIndex($(this).parent().index() - 1);
}}
>
<img alt={emoji} class="emoji" draggable="false" loading="lazy" src={`${cdn}72x72/${code}.png`} />
<img alt={emoji} className="emoji" draggable="false" loading="lazy" src={`${cdn}72x72/${code}.png`} />
{name}
</button>
);

View File

@@ -0,0 +1,7 @@
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import getEmojiIconCode from './helpers/getEmojiIconCode';
export default {
'emoji/fragments/AutocompleteDropdown': AutocompleteDropdown,
'emoji/helpers/getEmojiIconCode': getEmojiIconCode,
};

View File

@@ -11,3 +11,9 @@ app.initializers.add('flarum-emoji', () => {
// render emoji as image in Posts content and title.
renderEmoji();
});
// Expose compat API
import emojiCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, emojiCompat);

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8.6"
},
"autoload": {
"psr-4": {

View File

@@ -1,3 +1,7 @@
import 'flarum/common/models/Post';
import 'flarum/forum/ForumApplication';
import 'flarum/forum/components/Post';
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';

View File

@@ -7,6 +7,7 @@ declare const _default: {
'flags/components/FlagPostModal': typeof FlagPostModal;
'flags/components/FlagsPage': typeof FlagsPage;
'flags/components/FlagsDropdown': typeof FlagsDropdown;
'flags/states/FlagListState': typeof FlagListState;
};
export default _default;
import addFlagsToPosts from "./addFlagsToPosts";
@@ -17,3 +18,4 @@ import FlagList from "./components/FlagList";
import FlagPostModal from "./components/FlagPostModal";
import FlagsPage from "./components/FlagsPage";
import FlagsDropdown from "./components/FlagsDropdown";
import FlagListState from "./states/FlagListState";

View File

@@ -1,7 +1,7 @@
export default class FlagsDropdown {
export default class FlagsDropdown extends NotificationsDropdown<import("flarum/common/components/Dropdown").IDropdownAttrs> {
static initAttrs(attrs: any): void;
getMenu(): JSX.Element;
goToRoute(): void;
constructor();
getUnreadCount(): any;
getNewCount(): unknown;
}
import NotificationsDropdown from "flarum/forum/components/NotificationsDropdown";

View File

@@ -1,2 +1,2 @@
declare const _default: (import("flarum/common/extenders/Model").default | import("flarum/common/extenders/Routes").default | import("flarum/common/extenders/Store").default)[];
declare const _default: (import("flarum/common/extenders/Routes").default | import("flarum/common/extenders/Store").default | import("flarum/common/extenders/Model").default)[];
export default _default;

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@
"@types/mithril": "^2.0.8",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",

View File

@@ -1,3 +1,7 @@
import 'flarum/common/models/Post';
import 'flarum/forum/ForumApplication';
import 'flarum/forum/components/Post';
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';

View File

@@ -75,7 +75,7 @@ export default function () {
return items;
};
extend(Post.prototype, 'content', function (vdom) {
extend(Post.prototype, 'viewItems', function (items) {
const post = this.attrs.post;
const flags = post.flags();
@@ -83,7 +83,8 @@ export default function () {
if (post.isHidden()) this.revealContent = true;
vdom.unshift(
items.add(
'flagged',
<div className="Post-flagged">
<div className="Post-flagged-flags">
{flags.map((flag) => (
@@ -91,7 +92,8 @@ export default function () {
))}
</div>
<div className="Post-flagged-actions">{this.flagActionItems().toArray()}</div>
</div>
</div>,
110
);
});
@@ -108,7 +110,7 @@ export default function () {
user,
reason,
}),
detail ? <span className="Post-flagged-detail">{detail}</span> : '',
!!detail && <span className="Post-flagged-detail">{detail}</span>,
];
}
};

View File

@@ -6,6 +6,7 @@ import FlagList from './components/FlagList';
import FlagPostModal from './components/FlagPostModal';
import FlagsPage from './components/FlagsPage';
import FlagsDropdown from './components/FlagsDropdown';
import FlagListState from './states/FlagListState';
export default {
'flags/addFlagsToPosts': addFlagsToPosts,
@@ -16,4 +17,5 @@ export default {
'flags/components/FlagPostModal': FlagPostModal,
'flags/components/FlagsPage': FlagsPage,
'flags/components/FlagsDropdown': FlagsDropdown,
'flags/states/FlagListState': FlagListState,
};

View File

@@ -55,7 +55,7 @@ export default class FlagList extends Component {
) : !this.state.loading ? (
<div className="NotificationList-empty">{app.translator.trans('flarum-flags.forum.flagged_posts.empty_text')}</div>
) : (
LoadingIndicator.component({ className: 'LoadingIndicator--block' })
<LoadingIndicator className="LoadingIndicator--block" />
)}
</ul>
</div>

View File

@@ -67,15 +67,13 @@ export default class FlagPostModal extends Modal {
<input type="radio" name="reason" checked={this.reason() === 'off_topic'} value="off_topic" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_off_topic_label')}</strong>
{app.translator.trans('flarum-flags.forum.flag_post.reason_off_topic_text')}
{this.reason() === 'off_topic' ? (
{this.reason() === 'off_topic' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
70
@@ -95,15 +93,13 @@ export default class FlagPostModal extends Modal {
{app.translator.trans('flarum-flags.forum.flag_post.reason_inappropriate_text', {
a: guidelinesUrl ? <a href={guidelinesUrl} target="_blank" /> : undefined,
})}
{this.reason() === 'inappropriate' ? (
{this.reason() === 'inappropriate' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
60
@@ -115,15 +111,13 @@ export default class FlagPostModal extends Modal {
<input type="radio" name="reason" checked={this.reason() === 'spam'} value="spam" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_spam_label')}</strong>
{app.translator.trans('flarum-flags.forum.flag_post.reason_spam_text')}
{this.reason() === 'spam' ? (
{this.reason() === 'spam' && (
<textarea
className="FormControl"
placeholder={app.translator.trans('flarum-flags.forum.flag_post.reason_details_placeholder')}
value={this.reasonDetail()}
oninput={withAttr('value', this.reasonDetail)}
></textarea>
) : (
''
)}
</label>,
50
@@ -134,10 +128,8 @@ export default class FlagPostModal extends Modal {
<label className="checkbox">
<input type="radio" name="reason" checked={this.reason() === 'other'} value="other" onclick={withAttr('value', this.reason)} />
<strong>{app.translator.trans('flarum-flags.forum.flag_post.reason_other_label')}</strong>
{this.reason() === 'other' ? (
{this.reason() === 'other' && (
<textarea className="FormControl" value={this.reasonDetail()} oninput={withAttr('value', this.reasonDetail)}></textarea>
) : (
''
)}
</label>,
10

View File

@@ -1,5 +1,5 @@
import app from 'flarum/forum/app';
import NotificationsDropdown from 'flarum/components/NotificationsDropdown';
import NotificationsDropdown from 'flarum/forum/components/NotificationsDropdown';
import FlagList from './FlagList';
@@ -14,7 +14,7 @@ export default class FlagsDropdown extends NotificationsDropdown {
getMenu() {
return (
<div className={'Dropdown-menu ' + this.attrs.menuClassName} onclick={this.menuClick.bind(this)}>
{this.showing ? FlagList.component({ state: this.attrs.state }) : ''}
{this.showing && <FlagList state={this.attrs.state} />}
</div>
);
}

View File

@@ -40,6 +40,7 @@ class AddCanFlagAttribute
// If $actor is the post author, check to see if the setting is enabled
return (bool) $this->settings->get('flarum-flags.can_flag_own');
}
// $actor is not the post author
return true;
}

View File

@@ -31,10 +31,10 @@ class FlagSerializer extends AbstractSerializer
}
return [
'type' => $flag->type,
'reason' => $flag->reason,
'type' => $flag->type,
'reason' => $flag->reason,
'reasonDetail' => $flag->reason_detail,
'createdAt' => $this->formatDate($flag->created_at),
'createdAt' => $this->formatDate($flag->created_at),
];
}

View File

@@ -7,7 +7,7 @@
],
"license": "MIT",
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"extra": {
"branch-alias": {

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"autoload": {
"psr-4": {

View File

@@ -13,12 +13,15 @@ use Flarum\Api\Controller;
use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Extend;
use Flarum\Likes\Api\LoadLikesRelationship;
use Flarum\Likes\Event\PostWasLiked;
use Flarum\Likes\Event\PostWasUnliked;
use Flarum\Likes\Notification\PostLikedBlueprint;
use Flarum\Likes\Query\LikedByFilter;
use Flarum\Likes\Query\LikedFilter;
use Flarum\Post\Filter\PostFilterer;
use Flarum\Post\Post;
use Flarum\User\Filter\UserFilterer;
use Flarum\User\User;
return [
@@ -41,19 +44,32 @@ return [
->hasMany('likes', BasicUserSerializer::class)
->attribute('canLike', function (PostSerializer $serializer, $model) {
return (bool) $serializer->getActor()->can('like', $model);
})
->attribute('likesCount', function (PostSerializer $serializer, $model) {
return $model->getAttribute('likes_count') ?: 0;
}),
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->addInclude('posts.likes'),
->addInclude('posts.likes')
->loadWhere('posts.likes', [LoadLikesRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadLikesRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\ListPostsController::class))
->addInclude('likes'),
->addInclude('likes')
->loadWhere('likes', [LoadLikesRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadLikesRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\ShowPostController::class))
->addInclude('likes'),
->addInclude('likes')
->loadWhere('likes', [LoadLikesRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadLikesRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\CreatePostController::class))
->addInclude('likes'),
->addInclude('likes')
->loadWhere('likes', [LoadLikesRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadLikesRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\UpdatePostController::class))
->addInclude('likes'),
->addInclude('likes')
->loadWhere('likes', [LoadLikesRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadLikesRelationship::class, 'countRelation']),
(new Extend\Event())
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
@@ -63,6 +79,9 @@ return [
(new Extend\Filter(PostFilterer::class))
->addFilter(LikedByFilter::class),
(new Extend\Filter(UserFilterer::class))
->addFilter(LikedFilter::class),
(new Extend\Settings())
->default('flarum-likes.like_own_post', true),

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"
},

View File

@@ -0,0 +1,11 @@
import 'flarum/common/models/Post';
import User from 'flarum/common/models/User';
declare module 'flarum/common/models/Post' {
export default interface Post {
likes(): User[];
likesCount(): number;
canLike(): boolean;
}
}

View File

@@ -15,32 +15,31 @@ export default function () {
items.add(
'like',
Button.component(
{
className: 'Button Button--link',
onclick: () => {
isLiked = !isLiked;
<Button
className="Button Button--link"
onclick={() => {
isLiked = !isLiked;
post.save({ isLiked });
post.save({ 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.
const data = post.data.relationships.likes.data;
data.some((like, i) => {
if (like.id === app.session.user.id()) {
data.splice(i, 1);
return true;
}
});
if (isLiked) {
data.unshift({ type: 'users', id: app.session.user.id() });
// 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.
const data = post.data.relationships.likes.data;
data.some((like, i) => {
if (like.id === app.session.user.id()) {
data.splice(i, 1);
return true;
}
},
},
app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link')
)
});
if (isLiked) {
data.unshift({ type: 'users', id: app.session.user.id() });
}
}}
>
{app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link')}
</Button>
);
});
}

View File

@@ -5,6 +5,7 @@ import Link from 'flarum/common/components/Link';
import punctuateSeries from 'flarum/common/helpers/punctuateSeries';
import username from 'flarum/common/helpers/username';
import icon from 'flarum/common/helpers/icon';
import Button from 'flarum/common/components/Button';
import PostLikesModal from './components/PostLikesModal';
@@ -15,7 +16,7 @@ export default function () {
if (likes && likes.length) {
const limit = 4;
const overLimit = likes.length > limit;
const overLimit = post.likesCount() > 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.
@@ -34,26 +35,31 @@ export default function () {
// 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;
const count = post.likesCount() - names.length;
const label = app.translator.trans('flarum-likes.forum.post.others_link', { count });
names.push(
<a
href="#"
onclick={(e) => {
e.preventDefault();
app.modal.show(PostLikesModal, { post });
}}
>
{app.translator.trans('flarum-likes.forum.post.others_link', { count })}
</a>
);
if (app.forum.attribute('canSearchUsers')) {
names.push(
<Button
className="Button Button--ua-reset Button--text"
onclick={(e) => {
e.preventDefault();
app.modal.show(PostLikesModal, { post });
}}
>
{label}
</Button>
);
} else {
names.push(<span>{label}</span>);
}
}
items.add(
'liked',
<div className="Post-likedBy">
{icon('far fa-thumbs-up')}
{app.translator.trans('flarum-likes.forum.post.liked_by' + (likes[0] === app.session.user ? '_self' : '') + '_text', {
{app.translator.trans(`flarum-likes.forum.post.liked_by${likes[0] === app.session.user ? '_self' : ''}_text`, {
count: names.length,
users: punctuateSeries(names),
})}

View File

@@ -0,0 +1,11 @@
import LikesUserPage from './components/LikesUserPage';
import PostLikedNotification from './components/PostLikedNotification';
import PostLikesModal from './components/PostLikesModal';
import PostLikesModalState from './states/PostLikesModalState';
export default {
'likes/components/LikesUserPage': LikesUserPage,
'likes/components/PostLikedNotification': PostLikedNotification,
'likes/components/PostLikesModal': PostLikesModal,
'likes/states/PostLikesModalState': PostLikesModalState,
};

View File

@@ -1,31 +0,0 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Link from 'flarum/common/components/Link';
import avatar from 'flarum/common/helpers/avatar';
import username from 'flarum/common/helpers/username';
export default class PostLikesModal extends Modal {
className() {
return 'PostLikesModal Modal--small';
}
title() {
return app.translator.trans('flarum-likes.forum.post_likes.title');
}
content() {
return (
<div className="Modal-body">
<ul className="PostLikesModal-list">
{this.attrs.post.likes().map((user) => (
<li>
<Link href={app.route.user(user)}>
{avatar(user)} {username(user)}
</Link>
</li>
))}
</ul>
</div>
);
}
}

View File

@@ -0,0 +1,72 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import Link from 'flarum/common/components/Link';
import avatar from 'flarum/common/helpers/avatar';
import username from 'flarum/common/helpers/username';
import type { IInternalModalAttrs } from 'flarum/common/components/Modal';
import type Post from 'flarum/common/models/Post';
import type Mithril from 'mithril';
import PostLikesModalState from '../states/PostLikesModalState';
import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
export interface IPostLikesModalAttrs extends IInternalModalAttrs {
post: Post;
}
export default class PostLikesModal<CustomAttrs extends IPostLikesModalAttrs = IPostLikesModalAttrs> extends Modal<CustomAttrs, PostLikesModalState> {
oninit(vnode: Mithril.VnodeDOM<CustomAttrs, this>) {
super.oninit(vnode);
this.state = new PostLikesModalState({
filter: {
liked: this.attrs.post.id()!,
},
});
this.state.refresh();
}
className() {
return 'PostLikesModal Modal--small';
}
title() {
return app.translator.trans('flarum-likes.forum.post_likes.title');
}
content() {
return (
<>
<div className="Modal-body">
{this.state.isInitialLoading() ? (
<LoadingIndicator />
) : (
<ul className="PostLikesModal-list">
{this.state.getPages().map((page) =>
page.items.map((user) => (
<li>
<Link href={app.route.user(user)}>
{avatar(user)} {username(user)}
</Link>
</li>
))
)}
</ul>
)}
</div>
{this.state.hasNext() ? (
<div className="Modal-footer">
<div className="Form Form--centered">
<div className="Form-group">
<Button className="Button Button--block" onclick={() => this.state.loadNext()} loading={this.state.isLoadingNext()}>
{app.translator.trans('flarum-likes.forum.post_likes.load_more_button')}
</Button>
</div>
</div>
</div>
) : null}
</>
);
}
}

View File

@@ -9,5 +9,6 @@ export default [
new Extend.Model(Post) //
.hasMany<User>('likes')
.attribute<number>('likesCount')
.attribute<boolean>('canLike'),
];

View File

@@ -24,3 +24,9 @@ app.initializers.add('flarum-likes', () => {
});
});
});
// Expose compat API
import likesCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, likesCompat);

View File

@@ -0,0 +1,26 @@
import PaginatedListState, { PaginatedListParams } from 'flarum/common/states/PaginatedListState';
import User from 'flarum/common/models/User';
export interface PostLikesModalListParams extends PaginatedListParams {
filter: {
liked: string;
};
page?: {
offset?: number;
limit: number;
};
}
export default class PostLikesModalState<P extends PostLikesModalListParams = PostLikesModalListParams> extends PaginatedListState<User, P> {
constructor(params: P, page: number = 1) {
const limit = 10;
params.page = { ...(params.page || {}), limit };
super(params, page, limit);
}
get type(): string {
return 'users';
}
}

View File

@@ -35,6 +35,7 @@ flarum-likes:
# These translations are used by the Users Who Like This modal dialog.
post_likes:
title: Users Who Like This
load_more_button: => core.ref.load_more
# These translations are used in the Settings page.
settings:

View File

@@ -0,0 +1,60 @@
<?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\Discussion\Discussion;
use Flarum\Http\RequestUtil;
use Flarum\Post\Post;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Expression;
use Psr\Http\Message\ServerRequestInterface;
class LoadLikesRelationship
{
public static $maxLikes = 4;
public static function mutateRelation(BelongsToMany $query, ServerRequestInterface $request): BelongsToMany
{
$actor = RequestUtil::getActor($request);
$grammar = $query->getQuery()->getGrammar();
return $query
// So that we can tell if the current user has liked the post.
->orderBy(new Expression($grammar->wrap('user_id').' = '.$actor->id), 'desc')
// Limiting a relationship results is only possible because
// the Post model uses the \Staudenmeir\EloquentEagerLimit\HasEagerLimit
// trait.
->limit(self::$maxLikes);
}
/**
* Called using the @see ApiController::prepareDataForSerialization extender.
*/
public static function countRelation($controller, $data): void
{
$loadable = null;
if ($data instanceof Discussion) {
$loadable = $data->newCollection($data->posts)->filter(function ($post) {
return $post instanceof Post;
});
} elseif ($data instanceof Collection) {
$loadable = $data;
} elseif ($data instanceof Post) {
$loadable = $data->newCollection([$data]);
}
if ($loadable) {
$loadable->loadCount('likes');
}
}
}

View File

@@ -11,17 +11,20 @@ namespace Flarum\Likes\Query;
use Flarum\Filter\FilterInterface;
use Flarum\Filter\FilterState;
use Flarum\Filter\ValidateFilterTrait;
class LikedByFilter implements FilterInterface
{
use ValidateFilterTrait;
public function getFilterKey(): string
{
return 'likedBy';
}
public function filter(FilterState $filterState, string $filterValue, bool $negate)
public function filter(FilterState $filterState, $filterValue, bool $negate)
{
$likedId = trim($filterValue, '"');
$likedId = $this->asInt($filterValue);
$filterState
->getQuery()

View File

@@ -0,0 +1,34 @@
<?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\Query;
use Flarum\Filter\FilterInterface;
use Flarum\Filter\FilterState;
class LikedFilter implements FilterInterface
{
public function getFilterKey(): string
{
return 'liked';
}
public function filter(FilterState $filterState, string $filterValue, bool $negate)
{
$likedId = trim($filterValue, '"');
$filterState
->getQuery()
->whereIn('id', function ($query) use ($likedId) {
$query->select('user_id')
->from('post_likes')
->where('post_id', $likedId);
}, 'and', $negate);
}
}

View File

@@ -0,0 +1,210 @@
<?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\discussions;
use Carbon\Carbon;
use Flarum\Group\Group;
use Flarum\Likes\Api\LoadLikesRelationship;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Illuminate\Support\Arr;
class ListPostsTest extends TestCase
{
use RetrievesAuthorizedUsers;
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();
$this->extension('flarum-likes');
$this->prepareDatabase([
'discussions' => [
['id' => 100, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 101, 'comment_count' => 1],
],
'posts' => [
['id' => 101, 'discussion_id' => 100, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>text</p></t>'],
],
'users' => [
$this->normalUser(),
['id' => 102, 'username' => 'user102', 'email' => '102@machine.local', 'is_email_confirmed' => 1],
['id' => 103, 'username' => 'user103', 'email' => '103@machine.local', 'is_email_confirmed' => 1],
['id' => 104, 'username' => 'user104', 'email' => '104@machine.local', 'is_email_confirmed' => 1],
['id' => 105, 'username' => 'user105', 'email' => '105@machine.local', 'is_email_confirmed' => 1],
['id' => 106, 'username' => 'user106', 'email' => '106@machine.local', 'is_email_confirmed' => 1],
['id' => 107, 'username' => 'user107', 'email' => '107@machine.local', 'is_email_confirmed' => 1],
['id' => 108, 'username' => 'user108', 'email' => '108@machine.local', 'is_email_confirmed' => 1],
['id' => 109, 'username' => 'user109', 'email' => '109@machine.local', 'is_email_confirmed' => 1],
['id' => 110, 'username' => 'user110', 'email' => '110@machine.local', 'is_email_confirmed' => 1],
['id' => 111, 'username' => 'user111', 'email' => '111@machine.local', 'is_email_confirmed' => 1],
['id' => 112, 'username' => 'user112', 'email' => '112@machine.local', 'is_email_confirmed' => 1],
],
'post_likes' => [
['user_id' => 102, 'post_id' => 101],
['user_id' => 104, 'post_id' => 101],
['user_id' => 105, 'post_id' => 101],
['user_id' => 106, 'post_id' => 101],
['user_id' => 107, 'post_id' => 101],
['user_id' => 108, 'post_id' => 101],
['user_id' => 109, 'post_id' => 101],
['user_id' => 110, 'post_id' => 101],
['user_id' => 2, 'post_id' => 101],
['user_id' => 111, 'post_id' => 101],
['user_id' => 112, 'post_id' => 101],
],
'group_permission' => [
['group_id' => Group::GUEST_ID, 'permission' => 'searchUsers'],
],
]);
}
/**
* @test
*/
public function liked_filter_works()
{
$response = $this->send(
$this->request('GET', '/api/users')
->withQueryParams([
'filter' => ['liked' => 101],
])
);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing([
102, 104, 105, 106, 107, 108, 109, 110, 2, 111, 112
], $ids, 'IDs do not match');
}
/**
* @test
*/
public function liked_filter_works_negated()
{
$response = $this->send(
$this->request('GET', '/api/users')
->withQueryParams([
'filter' => ['-liked' => 101],
])
);
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getBody()->getContents(), true)['data'];
// Order-independent comparison
$ids = Arr::pluck($data, 'id');
$this->assertEqualsCanonicalizing([1, 103], $ids, 'IDs do not match');
}
/** @test */
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_post_endpoint()
{
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts/101', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => 'likes',
])
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
$likes = $data['relationships']['likes']['data'];
// Only displays a limited amount of likes
$this->assertCount(LoadLikesRelationship::$maxLikes, $likes);
// Displays the correct count of likes
$this->assertEquals(11, $data['attributes']['likesCount']);
// Of the limited amount of likes, the actor always appears
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
}
/** @test */
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_list_posts_endpoint()
{
// List posts endpoint
$response = $this->send(
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
])->withQueryParams([
'filter' => ['discussion' => 100],
'include' => 'likes',
])
);
$data = json_decode($response->getBody()->getContents(), true)['data'];
$this->assertEquals(200, $response->getStatusCode());
$likes = $data[0]['relationships']['likes']['data'];
// Only displays a limited amount of likes
$this->assertCount(LoadLikesRelationship::$maxLikes, $likes);
// Displays the correct count of likes
$this->assertEquals(11, $data[0]['attributes']['likesCount']);
// Of the limited amount of likes, the actor always appears
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
}
/**
* @dataProvider likesIncludeProvider
* @test
*/
public function likes_relation_returns_limited_results_and_shows_only_visible_posts_in_show_discussion_endpoint(string $include)
{
// Show discussion endpoint
$response = $this->send(
$this->request('GET', '/api/discussions/100', [
'authenticatedAs' => 2,
])->withQueryParams([
'include' => $include,
])
);
$included = json_decode($response->getBody()->getContents(), true)['included'];
$likes = collect($included)
->where('type', 'posts')
->where('id', 101)
->first()['relationships']['likes']['data'];
// Only displays a limited amount of likes
$this->assertCount(LoadLikesRelationship::$maxLikes, $likes);
// Displays the correct count of likes
$this->assertEquals(11, collect($included)
->where('type', 'posts')
->where('id', 101)
->first()['attributes']['likesCount']);
// Of the limited amount of likes, the actor always appears
$this->assertEquals([2, 102, 104, 105], Arr::pluck($likes, 'id'));
}
public function likesIncludeProvider(): array
{
return [
['posts,posts.likes'],
['posts.likes'],
[''],
];
}
}

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"autoload": {
"psr-4": {

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

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

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",

View File

@@ -0,0 +1,8 @@
import 'flarum/common/models/Discussion';
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
isLocked(): boolean;
canLock(): boolean;
}
}

View File

@@ -6,14 +6,7 @@ import Badge from 'flarum/common/components/Badge';
export default function addLockBadge() {
extend(Discussion.prototype, 'badges', function (badges) {
if (this.isLocked()) {
badges.add(
'locked',
Badge.component({
type: 'locked',
label: app.translator.trans('flarum-lock.forum.badge.locked_tooltip'),
icon: 'fas fa-lock',
})
);
badges.add('locked', <Badge type="locked" label={app.translator.trans('flarum-lock.forum.badge.locked_tooltip')} icon="fas fa-lock" />);
}
});
}

View File

@@ -9,15 +9,9 @@ export default function addLockControl() {
if (discussion.canLock()) {
items.add(
'lock',
Button.component(
{
icon: 'fas fa-lock',
onclick: this.lockAction.bind(discussion),
},
app.translator.trans(
discussion.isLocked() ? 'flarum-lock.forum.discussion_controls.unlock_button' : 'flarum-lock.forum.discussion_controls.lock_button'
)
)
<Button icon="fas fa-lock" onclick={this.lockAction.bind(discussion)}>
{app.translator.trans(`flarum-lock.forum.discussion_controls.${discussion.isLocked() ? 'unlock' : 'lock'}_button`)}
</Button>
);
}
});

View File

@@ -0,0 +1,7 @@
import DiscussionLockedNotification from './components/DiscussionLockedNotification';
import DiscussionLockedPost from './components/DiscussionLockedPost';
export default {
'lock/components/DiscussionLockedNotification': DiscussionLockedNotification,
'lock/components/DiscussionLockedPost': DiscussionLockedPost,
};

View File

@@ -22,3 +22,9 @@ app.initializers.add('flarum-lock', () => {
});
});
});
// Expose compat API
import lockCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, lockCompat);

View File

@@ -32,7 +32,7 @@ class LockedFilterGambit extends AbstractRegexGambit implements FilterInterface
return 'locked';
}
public function filter(FilterState $filterState, string $filterValue, bool $negate)
public function filter(FilterState $filterState, $filterValue, bool $negate)
{
$this->constrain($filterState->getQuery(), $negate);
}

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6"
"flarum/core": "^1.8"
},
"extra": {
"branch-alias": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
"prettier": "@flarum/prettier-config",
"dependencies": {
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"
},
"scripts": {
@@ -20,7 +20,7 @@
"flarum-tsconfig": "^1.0.2",
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1"
}
}

View File

@@ -0,0 +1,5 @@
import commonCompat from '../common/compat';
export default {
...commonCompat,
};

View File

@@ -2,3 +2,9 @@ import app from 'flarum/admin/app';
import { initialize } from '../common/index';
app.initializers.add('flarum-markdown', initialize);
// Expose compat API
import markdownCompat from './compat';
import { compat } from '@flarum/core/admin';
Object.assign(compat, markdownCompat);

View File

@@ -0,0 +1,7 @@
import MarkdownButton from './components/MarkdownButton';
import MarkdownToolbar from './components/MarkdownToolbar';
export default {
'markdown/components/MarkdownButton': MarkdownButton,
'markdown/components/MarkdownToolbar': MarkdownToolbar,
};

View File

@@ -2,6 +2,6 @@ import Component from 'flarum/common/Component';
export default class MarkdownToolbar extends Component {
view(vnode) {
return <div class="MarkdownToolbar">{vnode.children}</div>;
return <div className="MarkdownToolbar">{vnode.children}</div>;
}
}

View File

@@ -0,0 +1,5 @@
import commonCompat from '../common/compat';
export default {
...commonCompat,
};

View File

@@ -2,3 +2,9 @@ import app from 'flarum/forum/app';
import { initialize } from '../common/index';
app.initializers.add('flarum-markdown', initialize);
// Expose compat API
import markdownCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, markdownCompat);

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.6.3"
"flarum/core": "^1.8"
},
"autoload": {
"psr-4": {
@@ -33,6 +33,9 @@
"flarum-extension": {
"title": "Mentions",
"category": "feature",
"optional-dependencies": [
"flarum/tags"
],
"icon": {
"name": "fas fa-at",
"backgroundColor": "#539EC1",
@@ -74,6 +77,7 @@
},
"require-dev": {
"flarum/core": "*@dev",
"flarum/tags": "*@dev",
"flarum/testing": "^1.0.0"
},
"repositories": [

View File

@@ -18,6 +18,7 @@ use Flarum\Api\Serializer\PostSerializer;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Extend;
use Flarum\Group\Group;
use Flarum\Mentions\Api\LoadMentionedByRelationship;
use Flarum\Post\Event\Deleted;
use Flarum\Post\Event\Hidden;
use Flarum\Post\Event\Posted;
@@ -25,6 +26,8 @@ use Flarum\Post\Event\Restored;
use Flarum\Post\Event\Revised;
use Flarum\Post\Filter\PostFilterer;
use Flarum\Post\Post;
use Flarum\Tags\Api\Serializer\TagSerializer;
use Flarum\Tags\Tag;
use Flarum\User\User;
return [
@@ -37,18 +40,19 @@ return [
(new Extend\Formatter)
->configure(ConfigureMentions::class)
->parse(Formatter\EagerLoadMentionedModels::class)
->render(Formatter\FormatPostMentions::class)
->render(Formatter\FormatUserMentions::class)
->render(Formatter\FormatGroupMentions::class)
->unparse(Formatter\UnparsePostMentions::class)
->unparse(Formatter\UnparseUserMentions::class)
->parse(Formatter\CheckPermissions::class),
->unparse(Formatter\UnparseUserMentions::class),
(new Extend\Model(Post::class))
->belongsToMany('mentionedBy', Post::class, 'post_mentions_post', 'mentions_post_id', 'post_id')
->belongsToMany('mentionsPosts', Post::class, 'post_mentions_post', 'post_id', 'mentions_post_id')
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id')
->belongsToMany('mentionsGroups', Group::class, 'post_mentions_group', 'post_id', 'mentions_group_id'),
->belongsToMany('mentionsGroups', Group::class, 'post_mentions_group', 'post_id', 'mentions_group_id')
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id'),
new Extend\Locales(__DIR__.'/locale'),
@@ -64,41 +68,41 @@ return [
->hasMany('mentionedBy', BasicPostSerializer::class)
->hasMany('mentionsPosts', BasicPostSerializer::class)
->hasMany('mentionsUsers', BasicUserSerializer::class)
->hasMany('mentionsGroups', GroupSerializer::class),
->hasMany('mentionsGroups', GroupSerializer::class)
->attribute('mentionedByCount', function (BasicPostSerializer $serializer, Post $post) {
// Only if it was eager loaded.
return $post->getAttribute('mentioned_by_count') ?? 0;
}),
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->addInclude(['posts.mentionedBy', 'posts.mentionedBy.user', 'posts.mentionedBy.discussion'])
->load([
'posts.mentionsUsers', 'posts.mentionsPosts', 'posts.mentionsPosts.user', 'posts.mentionedBy',
'posts.mentionedBy.mentionsPosts', 'posts.mentionedBy.mentionsPosts.user', 'posts.mentionedBy.mentionsUsers',
'posts.mentionsGroups'
]),
'posts.mentionsUsers', 'posts.mentionsPosts', 'posts.mentionsPosts.user',
'posts.mentionsPosts.discussion', 'posts.mentionsGroups'
])
->loadWhere('posts.mentionedBy', [LoadMentionedByRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadMentionedByRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\ListDiscussionsController::class))
->load([
'firstPost.mentionsUsers', 'firstPost.mentionsPosts', 'firstPost.mentionsPosts.user', 'firstPost.mentionsGroups',
'lastPost.mentionsUsers', 'lastPost.mentionsPosts', 'lastPost.mentionsPosts.user', 'lastPost.mentionsGroups'
'firstPost.mentionsUsers', 'firstPost.mentionsPosts',
'firstPost.mentionsPosts.user', 'firstPost.mentionsPosts.discussion', 'firstPost.mentionsGroups',
'lastPost.mentionsUsers', 'lastPost.mentionsPosts',
'lastPost.mentionsPosts.user', 'lastPost.mentionsPosts.discussion', 'lastPost.mentionsGroups',
]),
(new Extend\ApiController(Controller\ShowPostController::class))
->addInclude(['mentionedBy', 'mentionedBy.user', 'mentionedBy.discussion']),
->addInclude(['mentionedBy', 'mentionedBy.user', 'mentionedBy.discussion'])
// We wouldn't normally need to eager load on a single model,
// but we do so here for visibility scoping.
->loadWhere('mentionedBy', [LoadMentionedByRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadMentionedByRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\ListPostsController::class))
->addInclude(['mentionedBy', 'mentionedBy.user', 'mentionedBy.discussion'])
->load([
'mentionsUsers', 'mentionsPosts', 'mentionsPosts.user', 'mentionedBy',
'mentionedBy.mentionsPosts', 'mentionedBy.mentionsPosts.user', 'mentionedBy.mentionsUsers',
'mentionsGroups'
]),
(new Extend\ApiController(Controller\CreatePostController::class))
->addOptionalInclude('mentionsGroups'),
(new Extend\ApiController(Controller\UpdatePostController::class))
->addOptionalInclude('mentionsGroups'),
(new Extend\ApiController(Controller\AbstractSerializeController::class))
->prepareDataForSerialization(FilterVisiblePosts::class),
->load(['mentionsUsers', 'mentionsPosts', 'mentionsPosts.user', 'mentionsPosts.discussion', 'mentionsGroups'])
->loadWhere('mentionedBy', [LoadMentionedByRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadMentionedByRelationship::class, 'countRelation']),
(new Extend\Settings)
->serializeToForum('allowUsernameMentionFormat', 'flarum-mentions.allow_username_format', 'boolval'),
@@ -112,10 +116,33 @@ return [
->listen(Deleted::class, Listener\UpdateMentionsMetadataWhenInvisible::class),
(new Extend\Filter(PostFilterer::class))
->addFilter(Filter\MentionedFilter::class),
->addFilter(Filter\MentionedFilter::class)
->addFilter(Filter\MentionedPostFilter::class),
(new Extend\ApiSerializer(CurrentUserSerializer::class))
->attribute('canMentionGroups', function (CurrentUserSerializer $serializer, User $user, array $attributes): bool {
->attribute('canMentionGroups', function (CurrentUserSerializer $serializer, User $user): bool {
return $user->can('mentionGroups');
})
}),
// Tag mentions
(new Extend\Conditional())
->whenExtensionEnabled('flarum-tags', [
(new Extend\Formatter)
->render(Formatter\FormatTagMentions::class)
->unparse(Formatter\UnparseTagMentions::class),
(new Extend\ApiSerializer(BasicPostSerializer::class))
->hasMany('mentionsTags', TagSerializer::class),
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->load(['posts.mentionsTags']),
(new Extend\ApiController(Controller\ListDiscussionsController::class))
->load([
'firstPost.mentionsTags', 'lastPost.mentionsTags',
]),
(new Extend\ApiController(Controller\ListPostsController::class))
->load(['mentionsTags']),
]),
];

File diff suppressed because one or more lines are too long

1
extensions/mentions/js/dist/forum.js.LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
"devDependencies": {
"prettier": "^2.5.1",
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.1",
"@flarum/prettier-config": "^1.0.0"
},

View File

@@ -0,0 +1,25 @@
import 'flarum/forum/ForumApplication';
import 'flarum/common/models/User';
import 'flarum/common/models/Post';
import MentionFormats from '../forum/mentionables/formats/MentionFormats';
import type BasePost from 'flarum/common/models/Post';
declare module 'flarum/forum/ForumApplication' {
export default interface ForumApplication {
mentionFormats: MentionFormats;
}
}
declare module 'flarum/common/models/User' {
export default interface User {
canMentionGroups(): boolean;
}
}
declare module 'flarum/common/models/Post' {
export default interface Post {
mentionedBy(): BasePost[] | undefined | null;
mentionedByCount(): number;
}
}

View File

@@ -2,40 +2,10 @@ import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import TextEditor from 'flarum/common/components/TextEditor';
import TextEditorButton from 'flarum/common/components/TextEditorButton';
import ReplyComposer from 'flarum/forum/components/ReplyComposer';
import EditPostComposer from 'flarum/forum/components/EditPostComposer';
import avatar from 'flarum/common/helpers/avatar';
import usernameHelper from 'flarum/common/helpers/username';
import highlight from 'flarum/common/helpers/highlight';
import KeyboardNavigatable from 'flarum/common/utils/KeyboardNavigatable';
import { truncate } from 'flarum/common/utils/string';
import { throttle } from 'flarum/common/utils/throttleDebounce';
import Badge from 'flarum/common/components/Badge';
import Group from 'flarum/common/models/Group';
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import getMentionText from './utils/getMentionText';
const throttledSearch = throttle(
250, // 250ms timeout
function (typed, searched, returnedUsers, returnedUserIds, dropdown, buildSuggestions) {
const typedLower = typed.toLowerCase();
if (!searched.includes(typedLower)) {
app.store.find('users', { filter: { q: typed }, page: { limit: 5 } }).then((results) => {
results.forEach((u) => {
if (!returnedUserIds.has(u.id())) {
returnedUserIds.add(u.id());
returnedUsers.push(u);
}
});
buildSuggestions();
});
searched.push(typedLower);
}
}
);
import MentionableModels from './mentionables/MentionableModels';
export default function addComposerAutocomplete() {
const $container = $('<div class="ComposerBody-mentionsDropdownContainer"></div>');
@@ -57,47 +27,42 @@ export default function addComposerAutocomplete() {
});
extend(TextEditor.prototype, 'buildEditorParams', function (params) {
const searched = [];
let relMentionStart;
let absMentionStart;
let typed;
let matchTyped;
// We store users returned from an API here to preserve order in which they are returned
// This prevents the user list jumping around while users are returned.
// We also use a hashset for user IDs to provide O(1) lookup for the users already in the list.
const returnedUsers = Array.from(app.store.all('users'));
const returnedUserIds = new Set(returnedUsers.map((u) => u.id()));
let mentionables = new MentionableModels({
onmouseenter: function () {
dropdown.setIndex($(this).parent().index());
},
onclick: (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(absMentionStart - 1, replacement + ' ');
// Store groups, but exclude the two virtual groups - 'Guest' and 'Member'.
const returnedGroups = Array.from(
app.store.all('groups').filter((group) => {
return group.id() != Group.GUEST_ID && group.id() != Group.MEMBER_ID;
})
);
dropdown.hide();
},
});
const applySuggestion = (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(absMentionStart - 1, replacement + ' ');
dropdown.hide();
};
params.inputListeners.push(() => {
const suggestionsInputListener = () => {
const selection = this.attrs.composer.editor.getSelectionRange();
const cursor = selection[0];
if (selection[1] - cursor > 0) return;
// Search backwards from the cursor for an '@' symbol. If we find one,
// we will want to show the autocomplete dropdown!
// Search backwards from the cursor for a mention triggering symbol. If we find one,
// we will want to show the correct autocomplete dropdown!
// Check classes implementing the IMentionableModel interface to see triggering symbols.
const lastChunk = this.attrs.composer.editor.getLastNChars(30);
absMentionStart = 0;
let activeFormat = null;
for (let i = lastChunk.length - 1; i >= 0; i--) {
const character = lastChunk.substr(i, 1);
if (character === '@' && (i == 0 || /\s/.test(lastChunk.substr(i - 1, 1)))) {
activeFormat = app.mentionFormats.get(character);
if (activeFormat && (i === 0 || /\s/.test(lastChunk.substr(i - 1, 1)))) {
relMentionStart = i + 1;
absMentionStart = cursor - lastChunk.length + i + 1;
mentionables.init(activeFormat.makeMentionables());
break;
}
}
@@ -106,132 +71,17 @@ export default function addComposerAutocomplete() {
dropdown.active = false;
if (absMentionStart) {
typed = lastChunk.substring(relMentionStart).toLowerCase();
matchTyped = typed.match(/^["|“]((?:(?!"#).)+)$/);
typed = (matchTyped && matchTyped[1]) || typed;
const typed = lastChunk.substring(relMentionStart).toLowerCase();
matchTyped = activeFormat.queryFromTyped(typed);
const makeSuggestion = function (user, replacement, content, className = '') {
const username = usernameHelper(user);
if (!matchTyped) return;
if (typed) {
username.children = [highlight(username.text, typed)];
delete username.text;
}
return (
<button
className={'PostPreview ' + className}
onclick={() => applySuggestion(replacement)}
onmouseenter={function () {
dropdown.setIndex($(this).parent().index());
}}
>
<span className="PostPreview-content">
{avatar(user)}
{username} {content}
</span>
</button>
);
};
const makeGroupSuggestion = function (group, replacement, content, className = '') {
let groupName = group.namePlural().toLowerCase();
if (typed) {
groupName = highlight(groupName, typed);
}
return (
<button
className={'PostPreview ' + className}
onclick={() => applySuggestion(replacement)}
onmouseenter={function () {
dropdown.setIndex($(this).parent().index());
}}
>
<span className="PostPreview-content">
<Badge class={`Avatar Badge Badge--group--${group.id()} Badge-icon `} color={group.color()} type="group" icon={group.icon()} />
<span className="username">{groupName}</span>
</span>
</button>
);
};
const userMatches = function (user) {
const names = [user.username(), user.displayName()];
return names.some((name) => name.toLowerCase().substr(0, typed.length) === typed);
};
const groupMatches = function (group) {
const names = [group.nameSingular(), group.namePlural()];
return names.some((name) => name.toLowerCase().substr(0, typed.length) === typed);
};
mentionables.typed = matchTyped;
const buildSuggestions = () => {
const suggestions = [];
// If the user has started to type a username, then suggest users
// matching that username.
if (typed) {
returnedUsers.forEach((user) => {
if (!userMatches(user)) return;
suggestions.push(makeSuggestion(user, getMentionText(user), '', 'MentionsDropdown-user'));
});
// ... or groups.
if (app.session?.user?.canMentionGroups()) {
returnedGroups.forEach((group) => {
if (!groupMatches(group)) return;
suggestions.push(makeGroupSuggestion(group, getMentionText(undefined, undefined, group), '', 'MentionsDropdown-group'));
});
}
}
// If the user is replying to a discussion, or if they are editing a
// post, then we can suggest other posts in the discussion to mention.
// We will add the 5 most recent comments in the discussion which
// match any username characters that have been typed.
if (this.attrs.composer.bodyMatches(ReplyComposer) || this.attrs.composer.bodyMatches(EditPostComposer)) {
const composerAttrs = this.attrs.composer.body.attrs;
const composerPost = composerAttrs.post;
const discussion = (composerPost && composerPost.discussion()) || composerAttrs.discussion;
if (discussion) {
discussion
.posts()
// Filter to only comment posts, and replies before this message
.filter((post) => post && post.contentType() === 'comment' && (!composerPost || post.number() < composerPost.number()))
// Sort by new to old
.sort((a, b) => b.createdAt() - a.createdAt())
// Filter to where the user matches what is being typed
.filter((post) => {
const user = post.user();
return user && userMatches(user);
})
// Get the first 5
.splice(0, 5)
// Make the suggestions
.forEach((post) => {
const user = post.user();
suggestions.push(
makeSuggestion(
user,
getMentionText(user, post.id()),
[
app.translator.trans('flarum-mentions.forum.composer.reply_to_post_text', { number: post.number() }),
' — ',
truncate(post.contentPlain(), 200),
],
'MentionsDropdown-post'
)
);
});
}
}
// If the user has started to type a mention,
// then suggest models matching.
const suggestions = mentionables.buildSuggestions();
if (suggestions.length) {
dropdown.items = suggestions;
@@ -271,13 +121,11 @@ export default function addComposerAutocomplete() {
dropdown.setIndex(0);
dropdown.$().scrollTop(0);
// Don't send API calls searching for users until at least 2 characters have been typed.
// This focuses the mention results on users and posts in the discussion.
if (typed.length > 1 && app.forum.attribute('canSearchUsers')) {
throttledSearch(typed, searched, returnedUsers, returnedUserIds, dropdown, buildSuggestions);
}
mentionables.search()?.then(buildSuggestions);
}
});
};
params.inputListeners.push(suggestionsInputListener);
});
extend(TextEditor.prototype, 'toolbarItems', function (items) {

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