Skip to content

fix(composer): move attribution line outside of blockquote so @mention triggers notification#172

Open
ClickAndGoScript wants to merge 1 commit into
NodeBB:masterfrom
ClickAndGoScript:patch-1
Open

fix(composer): move attribution line outside of blockquote so @mention triggers notification#172
ClickAndGoScript wants to merge 1 commit into
NodeBB:masterfrom
ClickAndGoScript:patch-1

Conversation

@ClickAndGoScript

Copy link
Copy Markdown

Summary

When using the Quote button, the @user [wrote](/post/123): attribution
line was rendered inside the blockquote block due to a leading > in
quoteKey. Because the @mention was inside a blockquote, the mention
parser did not recognize it, and the quoted user never received a
notification.

This fix removes the leading > so the attribution line appears above
the blockquote, restoring expected mention notification behavior.

Before:

@user wrote:

quoted content

(no notification sent to @user)

After:
@user wrote:

quoted content

(notification sent to @user)

Changes

  • static/lib/composer.js — removed > prefix from quoteKey in
    both the useTopicLink and default branches of composer.addQuote

Test plan

  • Quote another user's post — verify they receive a mention notification
  • Quote a post from a different topic (uses topic link) — same behavior
  • Partial text selection quote — same behavior

When quoting a post, the "@user wrote:" attribution line was prefixed
with `> `, placing it inside the blockquote block. This caused the
@mention to go unrecognized by the mention parser, so the quoted user
never received a notification.

Remove the leading `> ` from `quoteKey` so the attribution line renders
above the blockquote, allowing the @mention to trigger a notification.
@barisusakli

Copy link
Copy Markdown
Member

The reason why the @user wrote: was moved into the blockquote was to make the mention notifications look nicer. Looks like it stopped sending those completely when it was moved. If we move it back out then all mention notifications will start with the same @baris wrote: which is useless for the user who got the notification.

There are some utility classeson the notification.bodyLong parent to hide blockquotes pre and the first line break to show the relevant part of the content.

{{{ if ./bodyLong}}}
  <div class="text-secondary text-sm line-clamp-2 text-contain hidden-blockquote hidden-pre hidden-first-child-br">
      {./bodyLong}
  </div>
{{{ end }}}

If mentions plugins adds a class on the element than we can hide that in notification body as well with a class like hidden-mention maybe.

@barisusakli

Copy link
Copy Markdown
Member

Now that I think about it that won't work as it would just hide the @username part and you would end up with lots of notification bodies that start with wrote: whenever someone quotes your posts.

@ClickAndGoScript

Copy link
Copy Markdown
Author

Fair enough, I didn't realize the blockquote placement was intentional.

What about fixing this on the mentions plugin side instead? Right now
Mentions.notify strips blockquotes completely before matching
(Mentions.clean(post.content, true, true, true)), which is the right call
for mentions that just happen to appear inside quoted text. But it could do
a second pass over the raw content that only matches the attribution line:

^> @slug [...](/post/<pid>):

and before notifying, verify that the author of is actually the
mentioned user (posts.getPostField(pid, 'uid')). So even a hand-typed
attribution line only notifies if that user really wrote the linked post --
in which case they're genuinely being quoted anyway. Nested quotes
("> > @user wrote:") wouldn't match since the pattern only allows a single
level of ">".

My main question is whether this check is reliable enough to separate
"this user got quoted and should know about it" from "this mention just
happens to sit inside quoted content". The pid-author verification seems to
cover spoofing and quote-of-a-quote, but I might be missing a case.

If this sounds reasonable I'll close this PR and open one against
nodebb-plugin-mentions instead.

@julianlam

Copy link
Copy Markdown
Member

I think closing this PR is probably a good idea regardless because I don't see us moving back to the mention outside the blockquote.

My question is whether this is necessary at all. If you quote someone, the mention may not get captured, but if they're already posting in the thread they'd probably be notified anyway because they would already be watching the topic (per user setting of course.)

I just personally don't like adding even more logic to mentions.clean. It's confusing enough already!

@julianlam

Copy link
Copy Markdown
Member

One could further make the argument that if you are merely quoted, it's not a "mention", per se.

🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants