Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mentions] feat: group mentions #3658

Merged
merged 88 commits into from
Nov 5, 2022
Merged

[mentions] feat: group mentions #3658

merged 88 commits into from
Nov 5, 2022

Conversation

imorland
Copy link
Member

@imorland imorland commented Oct 21, 2022

**Addresses https://discuss.flarum.org/d/31473-mentioning-groups-within-posts **

Changes proposed in this pull request:
Allows mentioning of groups

Reviewers should focus on:

Screenshot
User notification settings:
image

Autocomplete:
image

Preview:
image

Post content:
image

Web notification:
image

Email notification:

[2022-10-21 17:54:02] flarum.INFO: Message-ID: <[email protected]>
Date: Fri, 21 Oct 2022 17:54:02 +0000
Subject: admin mentioned a group you're a member of in Example discussion
From: Flarum Dev Docker <noreply@localhost>
To: admin <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hey admin!

admin mentioned a group you're a member of in Example discussion.

http://dev.lan/d/1/33

---

@"Admins"#g1 

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@imorland imorland changed the title wip: feat: group mentions [mentions] feat: group mentions Oct 21, 2022
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks neat! a few comments:

  • Groups are loaded from the store for autocomplete, do we know if all groups are within the store at that point? part of the requirements suggests an API search endpoint.
  • I have yet to test locally, but I think we might be missing taking into consideration hidden groups.
  • To avoid abuse, I reckon we need a mention groups permission,but since it wasn't listed in the initial requirements, we can add it inanother PR outside of this.

@imorland
Copy link
Member Author

  • Groups are loaded from the store for autocomplete, do we know if all groups are within the store at that point? part of the requirements suggests an API search endpoint.

🤦‍♂️ whoops, yes I missed that. I feel the search endpoint should probably be in core, rather than mentions, what is your opinion?

  • I have yet to test locally, but I think we might be missing taking into consideration hidden groups.

As it stands, yes, hidden groups are not returned for users who do not have permission to view them.

  • To avoid abuse, I reckon we need a mention groups permission,but since it wasn't listed in the initial requirements, we can add it inanother PR outside of this.

I'm happy to include that in this PR, as it makes complete sense to do that at the same time. Again, probably for core directly, rather than in mentions?

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the search endpoint should probably be in core, rather than mentions, what is your opinion?

Yup. core makes sense.

I'm happy to include that in this PR, as it makes complete sense to do that at the same time. Again, probably for core directly, rather than in mentions?

mention groups permission is only relevant in the mentions extension, so it makes more sense in mentions than in core imo.

extensions/mentions/src/Formatter/CheckPermissions.php Outdated Show resolved Hide resolved
framework/core/src/Extend/Formatter.php Outdated Show resolved Hide resolved
framework/core/src/Post/CommentPost.php Outdated Show resolved Hide resolved
@imorland
Copy link
Member Author

imorland commented Nov 3, 2022

Note: PHPStan failure is fixed by #3665 by @SychO9

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more tests, one of them actually caught a bug where the editing of posts doesn't have the actor so group mentions don't work. pushed a fix at the same time.

I believe this is ready now.

@imorland
Copy link
Member Author

imorland commented Nov 5, 2022

Added a few more tests, one of them actually caught a bug where the editing of posts doesn't have the actor so group mentions don't work. pushed a fix at the same time.

Ah nice one, thank you!

@imorland imorland merged commit 827e905 into main Nov 5, 2022
@imorland imorland deleted the im/group-mentions branch November 5, 2022 19:29
@imorland imorland added this to the 1.6 milestone Nov 5, 2022
@imorland imorland self-assigned this Nov 5, 2022
@luceos luceos mentioned this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants