Add user's groups as a class to messages in chat

AI-generated summary

A discussion was started about adding user groups as a class to messages in chat. hiddenseal suggested that user groups be added to chat messages as classes, similar to how they are added to regular posts, to allow for color coding and distinguishing between certain groups. hiddenseal provided examples of how the HTML for chat messages could be modified to include user groups as classes. joffreyjaffeux then pushed a change to implement this feature, which was reviewed and confirmed to be working correctly by hiddenseal.

Currently, the HTML containing username or full name of a poster on any regular post is augmented with the information about groups of a user as classes.

<span class="first full-name staff admin group--GROUPNAME"><a href="/u/USER" data-user-card="USER" class="">Full Name</a></span>

I believe the code responsible for this behavior is here

Wouldn’t it be good if a similar thing was made for chat messages? It may be beneficial to color code certain groups so that some (e.g. from staff) messages are distinguished from others…

I.e. if

<span class="chat-message-info__username__name">Full Name</span>

was

<span class="chat-message-info__username__name staff admin group--GROUPNAME">Full Name</span>

It seems like the chat messages don’t have a similar .js file pushing attributes and the classes only come from this file.

4 Likes

I just pushed a change which should do it:

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

Let me know how it goes for you :+1:

4 Likes

looks good, thank you!

1 Like

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.