Group Private Message - Message Bus Issue

Context
We have a system whereby we programmatically add users to groups, via the API, and automatically create private messages for individual groups, all via the API.

For example, we might have a group called: cooking-class-101

For which we’ll create a private message with cooking-class-101 & system as 2 participants in the private message.

This has worked really well for us as a way of automatically creating private group chats for groups of people.

The Problem
The issue we’re seeing is that for regular users who are part of the group, the message bus does not return any updates when new posts are added to the topic.

For example, we have a group private message with topic ID 123. We can see that the message bus is subscribed to the channel topic/123, yet if another user creates a post on the topic, nothing is returned by the message bus and therefore the latest post does not automatically show.

We have confirmed that the message bus is generally working as expected as it does correctly return data on the topic/presence/123 channel.

The counter to the above is that for admin users who are part of the group that has been added to the private message, the message bus does correctly return data on the topic/123 channel and the new post is therefore correctly shown on the topic in real time.

We’ve also confirmed that if a regular user who is a member of the group is separately invited to participate in the topic (so now we have cooking-class-101, system & regular-user participating), then they start to correctly receive responses from the message bus on the topic/123 channel and therefore see new posts in real time.

Research
Digging around in the Discourse code brings me to the following which looks as though for private message topics, it might not be notifying groups of new posts being published: https://github.com/discourse/discourse/blob/b7b81afe553a79f58f79f49a6c2ceff831aa4ec7/app/models/post.rb#L214-L219

I’m not entirely sure what topic.allowed_users in the link above is supposed to return on a private message topic with a group added to it, but my suspicion is that it doesn’t include the list of users who exist as part of the group.

I’ve tagged this as a bug, but this may well be intended behaviour?

2 Likes

Definitely feels like support to me vs a bug.

Start backwards, do everything in the UI.

Does it work?

Eg:

  • user1 is a member of group A
  • message sent to group A
  • user1 looks at the message
  • user2 posts on the message
  • Do you see the reply come in live?

If you do, then something about how you are consuming the API is not right.

3 Likes

Thanks for the response Sam.

We’ve tested this from within the Discourse UI and it exhibits the same erroneous behaviour - i.e. the reply does not come through in realtime, only a notification/notification alert come through.

A page refresh is then required to see the latest post.

In your example above, if user1 is an admin then everything works as expected however.

2 Likes

Well this certainly sounds like a bug then, we will test, may take a few days.

4 Likes

Brilliant - thanks! Let me know if you need any further information

1 Like

Hi Sam - just dropping a comment to see if there’s anywhere where I can keep tabs on any progress for this bug? Not completely clued up on the bug reporting/fixing process with Discourse - Thanks!

2 Likes

I am pretty sure kris fixed it, recommend you re test

3 Likes

Hey @danjw,

sorry, I forgot to let you know. Sam is right, it was fixed with PR below:

https://github.com/discourse/discourse/pull/12269

3 Likes