framework/extensions/mentions/extend.php

149 lines
6.8 KiB
PHP
Raw Normal View History

2015-05-14 20:31:03 +08:00
<?php
2015-09-04 11:01:19 +08:00
/*
* This file is part of Flarum.
*
2019-11-30 07:02:17 +08:00
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
2015-09-04 11:01:19 +08:00
*/
2021-05-05 02:57:29 +08:00
namespace Flarum\Mentions;
2020-12-09 00:15:52 +08:00
use Flarum\Api\Controller;
use Flarum\Api\Serializer\BasicPostSerializer;
use Flarum\Api\Serializer\BasicUserSerializer;
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\Api\Serializer\GroupSerializer;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Extend;
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
use Flarum\Group\Group;
use Flarum\Mentions\Api\LoadMentionedByRelationship;
use Flarum\Post\Event\Deleted;
use Flarum\Post\Event\Hidden;
use Flarum\Post\Event\Posted;
use Flarum\Post\Event\Restored;
use Flarum\Post\Event\Revised;
use Flarum\Post\Filter\PostSearcher;
2020-04-24 21:55:50 +08:00
use Flarum\Post\Post;
use Flarum\Search\Database\DatabaseSearchDriver;
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 19:58:11 +08:00
use Flarum\Tags\Api\Serializer\TagSerializer;
2020-04-24 21:55:50 +08:00
use Flarum\User\User;
2015-05-14 20:31:03 +08:00
return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),
(new Extend\Formatter)
2021-03-02 12:26:35 +08:00
->configure(ConfigureMentions::class)
->parse(Formatter\EagerLoadMentionedModels::class)
2021-03-02 12:26:35 +08:00
->render(Formatter\FormatPostMentions::class)
->render(Formatter\FormatUserMentions::class)
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
->render(Formatter\FormatGroupMentions::class)
->unparse(Formatter\UnparsePostMentions::class)
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 19:58:11 +08:00
->unparse(Formatter\UnparseUserMentions::class),
2020-04-24 21:55:50 +08:00
(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')
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id')
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 19:58:11 +08:00
->belongsToMany('mentionsGroups', Group::class, 'post_mentions_group', 'post_id', 'mentions_group_id')
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id'),
2020-04-24 21:55:50 +08:00
new Extend\Locales(__DIR__.'/locale'),
(new Extend\View)
->namespace('flarum-mentions', __DIR__.'/views'),
(new Extend\Notification())
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
->type(Notification\PostMentionedBlueprint::class, PostSerializer::class, ['alert'])
->type(Notification\UserMentionedBlueprint::class, PostSerializer::class, ['alert'])
->type(Notification\GroupMentionedBlueprint::class, PostSerializer::class, ['alert']),
2020-12-09 00:15:52 +08:00
(new Extend\ApiSerializer(BasicPostSerializer::class))
->hasMany('mentionedBy', BasicPostSerializer::class)
->hasMany('mentionsPosts', BasicPostSerializer::class)
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
->hasMany('mentionsUsers', BasicUserSerializer::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;
}),
2020-12-09 00:15:52 +08:00
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->addInclude(['posts.mentionedBy', 'posts.mentionedBy.user', 'posts.mentionedBy.discussion'])
->load([
'posts.mentionsUsers', 'posts.mentionsPosts', 'posts.mentionsPosts.user',
'posts.mentionsPosts.discussion', 'posts.mentionsGroups'
])
->loadWhere('posts.mentionedBy', LoadMentionedByRelationship::mutateRelation(...))
->prepareDataForSerialization(LoadMentionedByRelationship::countRelation(...)),
(new Extend\ApiController(Controller\ListDiscussionsController::class))
->load([
'firstPost.mentionsUsers', 'firstPost.mentionsPosts',
'firstPost.mentionsPosts.user', 'firstPost.mentionsPosts.discussion', 'firstPost.mentionsGroups',
'lastPost.mentionsUsers', 'lastPost.mentionsPosts',
'lastPost.mentionsPosts.user', 'lastPost.mentionsPosts.discussion', 'lastPost.mentionsGroups',
]),
2020-12-09 00:15:52 +08:00
(new Extend\ApiController(Controller\ShowPostController::class))
->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::mutateRelation(...))
->prepareDataForSerialization(LoadMentionedByRelationship::countRelation(...)),
2020-12-09 00:15:52 +08:00
(new Extend\ApiController(Controller\ListPostsController::class))
->addInclude(['mentionedBy', 'mentionedBy.user', 'mentionedBy.discussion'])
->load(['mentionsUsers', 'mentionsPosts', 'mentionsPosts.user', 'mentionsPosts.discussion', 'mentionsGroups'])
->loadWhere('mentionedBy', LoadMentionedByRelationship::mutateRelation(...))
->prepareDataForSerialization(LoadMentionedByRelationship::countRelation(...)),
(new Extend\Settings)
->serializeToForum('allowUsernameMentionFormat', 'flarum-mentions.allow_username_format', 'boolval'),
2020-12-09 00:15:52 +08:00
(new Extend\Event())
->listen(Posted::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(Restored::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(Revised::class, Listener\UpdateMentionsMetadataWhenVisible::class)
->listen(PostWasApproved::class, Listener\UpdateMentionsMetadataWhenVisible::class)
2020-12-09 00:15:52 +08:00
->listen(Hidden::class, Listener\UpdateMentionsMetadataWhenInvisible::class)
2021-05-05 02:57:29 +08:00
->listen(Deleted::class, Listener\UpdateMentionsMetadataWhenInvisible::class),
(new Extend\SearchDriver(DatabaseSearchDriver::class))
->addFilter(PostSearcher::class, Filter\MentionedFilter::class)
->addFilter(PostSearcher::class, Filter\MentionedPostFilter::class),
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
(new Extend\ApiSerializer(CurrentUserSerializer::class))
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 19:58:11 +08:00
->attribute('canMentionGroups', function (CurrentUserSerializer $serializer, User $user): bool {
[mentions] feat: group mentions (#3658) * wip: group mentions * Apply fixes from StyleCI * chore: format * group mention autocomplete * chore: format * remove console.log * implement notifications * prevent guest and member groups from being mentioned * Update extensions/mentions/less/forum.less Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * rename displayname to groupname * Update extensions/mentions/src/Formatter/FormatGroupMentions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove redundant unparse * simplify migrations * add group deleted translation * Apply fixes from StyleCI * handle everything falsy * Include icon in group mention preview * remove box-shadow from autocomplete group results * Add color to preview * chore: format * Remove box shadow from group autocomplete results * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration * prevent former group icon from beingdisplayed * add group searcher with permissions * Apply fixes from StyleCI * Search groups based on canSearchGroups permission * Don't include virtual groups in results * Add search groups translation * Revert "remove unneeded migration" This reverts commit 9347665baa1820ed0875c6b2dd22b14fbc2768e7. * Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php" This reverts commit 8406d51df276d8f14917bfdc45a86e6b847784b7. * add searchGroups permission to tests * Apply fixes from StyleCI * Add default searchGroups permission * Apply fixes from StyleCI * Update extensions/mentions/js/src/forum/addComposerAutocomplete.js Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove unneeded migration, correct table table * correct table name in down migration * Remove group searcher * Apply fixes from StyleCI * Remove group searching from composer autocomplete * Add mentionGroups permission * Apply fixes from StyleCI * prevent post preview from rendering a group mention when user does not have permission * remove test changes * wip: expose ServerRequestInterface to textformatter parse() * Apply fixes from StyleCI * Set post content properly * php 7.x compatibility * begin adding groupmention tests * Apply fixes from StyleCI * test virtual groups don't mention * Apply fixes from StyleCI * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update extensions/mentions/extend.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * requested changes * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/tests/integration/api/groups/ListTest.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Search/SearchServiceProvider.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * remove default permission migration * try using datetime column instead of timestamp * Apply fixes from StyleCI * chore: remove commented code * add tests * Apply fixes from StyleCI * Pass actor to parser instead of ServerRequest * Allow for to be null * Update framework/core/src/Extend/Formatter.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * pass actor instead of request * Apply fixes from StyleCI * actor instead of request * remove serverrequest * Apply fixes from StyleCI * remove dupe actor * Update extensions/mentions/src/Formatter/CheckPermissions.php Co-authored-by: Sami Mazouz <sychocouldy@gmail.com> * fix type in comment * group does not have the relation, post does * test: invalid, deleted, fresh data mentions Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * Apply fixes from StyleCI * fix: group mentions don't work when editing posts Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2022-11-06 03:29:01 +08:00
return $user->can('mentionGroups');
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 19:58:11 +08:00
}),
// Tag mentions
(new Extend\Conditional())
->whenExtensionEnabled('flarum-tags', fn () => [
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 19:58:11 +08:00
(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']),
]),
];