编辑帖子会触发通知

Hello,

I have been updated some featured/pinned topics and they seem to be sending out updates every time that I update them. Is there a way to disable this? “Watch first Post” shouldn’t trigger if the post is just slightly edited as far as I can tell?

Thanks!

What you’re describing is not really possible.

What do you mean by “I have been updated”? What exactly did you do, step by step? Describe it in detail? Your question is unanswerable until you provide this information.

Edits don’t alert anyone in Discourse… ever, that I can think of. You will be notified if someone else edits your post by default, using the typical Discourse notifications.

1 个赞

Edits notify the original author. I get notifications when @codinghorror fixes my posts with alarming frequency. (I don’t think it’s what this person is describing, but it is edits giving notifications)

Edit: oops

As I said above, already…

1 个赞

Sorry fort he lack of clarity.
For some reason, editing a post that I created would notify other users of the edit. It appears that it occurred in topics that used the tagging of a group and that group would be notified (even if the tag was not a new one).

  1. Create a post with multiple tags of groups of members
  2. Let it propagate and send notifications. Wait whatever number of minutes is needed for it to send out to any current watch lists/etc.
  3. Come back to the post and edit it.
  4. Add something useless, like the word unicorn and note that the right hand side of the edit window alerts that you will notify the groups in the post despite not having added or edited anything to do with those tags.
  5. Save
  6. Check the logs and note that all members in those groups are now notified of the edit (though the notifications appear as a New Topic notification.
3 个赞

Interesting so this is specific to group mentions? Perhaps you can try to repro this when you have time @jomaxro

It appears to be on my end at least.

I have not been able to repro this. I tested it on try, with 3 users. In one post I mentioned all of them individually, in the other I mentioned a group all 3 were in. They all received the initial mention notification, they did not receive further notifications on edit.




I’m unsure about the type of notification here. Are you referring to a notification that appears on your user profile, i.e., as an extra entry in the list that appears when you click on your avatar up right?

Or is it a small blue dot next to the topic title in the topic list?

1 个赞

我在我们其中一个网站上观察到了这种行为。

编辑提及某个群组的帖子时,会出现以下警告:

同时可以确认,该群组中的成员在编辑保存后会收到新的通知。

2 个赞

@tshenry,我们能复现这个问题吗?

1 个赞

@Grayden_Shand,我猜该帖子在编辑之前就已经提到了该群组?我知道,如果你通过编辑在帖子中添加一个的提及,该用户或群组会收到通知。

我测试了两种情况:

  1. 如果你对已经提及某个群组的帖子进行“忍者编辑”(即悄悄修改),编辑时会显示警告,但在完成忍者编辑后不会发送通知。
  2. 如果你在编辑宽限期之外进行编辑,编辑时会显示警告,但不会向该群组发送新的通知。

你能提供一些额外的复现步骤吗?


顺便提一下,我觉得如果能有一个开关来控制提及是否在帖子级别触发通知,将会很有帮助。这样可以在编辑场景中提供更多控制,同时也方便你只是想在帖子中包含一个魔法用户卡片或个人资料链接供其他用户使用。

2 个赞

是的,群组提及在编辑前就已经存在于帖子中。此外,进行编辑的用户与拥有该主题的用户并非同一人。

我将在今天的开发环境中尝试复现该问题,如果成功将向您反馈。

1 个赞

已经找到了原因……

通知是发送给在帖子最初创建之后才加入群组的用户的。

因此,对于收到通知的用户来说,这是他们首次收到提及通知,但并非任何人首次收到该通知。

而那些一开始就在群组中的人(他们已收到最初的提及通知),在帖子被编辑时不会收到额外的通知。

复现步骤(需要两个用户)

  1. 创建一个新群组
  2. 创建一个提及该群组的新帖子或话题
  3. 创建一个新用户
  4. 将该用户添加到群组中
  5. 编辑帖子——此时新用户将收到通知。
  6. 再次编辑帖子——新用户不会因后续的编辑而收到额外通知。

我不确定此处正确的行为应该是什么……我倾向于在编辑时完全不发送提及通知,但我不确定这在实现上会有多复杂。

另外,还有一点需要注意:无论是否真的有人会被通知,当你进行编辑时,“你即将通知群组中的 X 人”这条消息都会显示出来。

是否可以将此警告消息与之前未收到该帖子通知的人数关联起来(以便准确计算将被通知的人数)?

4 个赞

啊哈,谢谢!我也确实看到了同样的行为。

通过编辑帖子发送提及通知是一个重要的功能,我知道我和其他人都会不时使用它,所以我们希望保留这一功能,但它在群组中的工作方式感觉不太对劲。

我目前的看法是,每个帖子只应通知群组一次。在首次提及群组之后被添加到群组的用户,不应因后续的帖子编辑而收到群组提及通知。如果自上次保存帖子以来没有新的群组提及,那么关于通知群组的 JIT 教育横幅不应在编辑帖子时显示。

如果在编辑中提及了一个之前未被提及的群组,则应该通知他们。这与用户提及的工作方式相同。如果有新提及的群组,我们也应看到相关的教育横幅。

我认为我们可以基于 group_mentions 表中是否存在记录来添加一些条件逻辑。我们在保存帖子时创建一条记录。

你怎么看 @codinghorror

2 个赞

我理解你的意思,但我们真的应该把这个问题视为需要修复的缺陷吗?

如果我们完全抑制编辑时所有的 @group 通知,那么编辑一个新的 @group 时将不会触发提及通知。这与过去通知的工作方式相比是一个巨大的变化,可能会让人感到非常意外。

如果我们开始采用更复杂的策略,仅在编辑时通知新的 @group,那么我们将被迫维护复杂的代码,需要遍历差异并处理大量的额外记录工作。

我确实想不出有什么简单的解决方案。

4 个赞

所以,想象一下一个帖子中有三个不同的群组提及。编辑后,又添加了第四个提及。

在保存编辑时,我们可以使用如下查询来获取该帖子当前的群组提及列表:

-- [params]
-- text :post_id

select gm.group_id, g.name
from group_mentions gm
join groups g on (gm.group_id = g.id)
where post_id = :post_id

然后,通过将查询结果与帖子中实际提及的群组列表进行比对,我们就可以找出新增的提及。

这看起来计算量不算太大,但也许我漏掉了什么显而易见的地方。这也像是可以在后台任务中完成的那种事情。

至于关于通知群组的那个 JIT 横幅,也许可以通过一个 API 端点(/post/<id>/mentions.json)来暴露此逻辑,以便异步获取这些数据。

直接创建新帖子并以此通知大家,岂不是更简单?我有点担心,为了支持这样一个相对边缘的个案,在这里堆砌起一座巨大的复杂度高塔。

1 个赞

我不想让事情变得太复杂。

我查看了其中的一些代码(感谢 @tshenry 提供的链接),看起来并不需要那么复杂。

群组提及目前是在 这里(第 78-80 行)触发的。expand_group_mentions() 函数 是一个生成器,负责输出应接收群组提及通知的用户(同时遵守如 SiteSetting.max_users_notified_per_group_mention 之类的策略)。

这似乎是一个放置此逻辑的自然位置。

create_notification 函数中,我们抑制了任何已经收到相同类型通知的用户的通知。这就是为什么编辑包含群组提及的帖子会触发新群组成员收到通知的原因——实际上会为群组中的所有用户生成通知,但随后会抑制那些已经收到该通知的人。

我建议采用类似的方法,通过更新 expand_group_mentions() 函数,过滤掉在 group_mentions 表中已有记录的群组。

类似这样(请原谅我对 Ruby 语法的不熟悉):

  def expand_group_mentions(groups, post)
    return unless post.user && groups

    Group.mentionable(post.user, include_public: false).where(id: groups.map(&:id)).each do |group|
      next if group.user_count >= SiteSetting.max_users_notified_per_group_mention

      # 添加对已提及群组的检查
      next if GroupMentions.where(group_id: group.id, post_id: post.id).length > 0

      yield group, group.users
    end

  end

不过,这对 JIT 警告没有任何作用。

我尽力帮忙解决这个问题,如果我只是在添乱,请告诉我……:slight_smile:

2 个赞

我正准备发布一个新的支持问题,但找到了这个主题。

看起来它与此相关。

如果我发布了一条消息,随后意识到本应通知某些人却忘了,最好的做法是什么?

  1. 编辑帖子并专门 @ 提及某个群组或多个人?

  2. 创建新消息来 @ 通知他们?这样我就需要重复大量信息,或者添加原帖的链接。

如果可行的话,选项 1 是我更偏好的(更简洁)方式?

能否有人确认一下:如果在编辑时专门 @ 提及个人或群组,而他们此前未被通知,系统是否会向他们发送通知?如果不是,这似乎是一个有用的功能,只要实现起来不太困难?

附:如果我忘了,有时会利用可配置的编辑时间窗口,在通知发出前编辑帖子。但等到你发帖时,你始终无法确定是否能在时限内完成。只有在编辑发布后,你才能确认它是否显示为编辑。

我将用这次编辑来测试是否会收到通知 @Rhidian @codinghorror

看来不会 :confused:

2 个赞