# Allow specifiy user different from guardian.user in chat services such as Chat::CreateMessage

**URL:** https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249
**Category:** Feature
**Tags:** chat
**Created:** [November 12, 2023, 12:16pm UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249 "2023-11-12T12:16:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [November 12, 2023, 12:16pm UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249/1 "2023-11-12T12:16:54Z")

</div>

Now that `PostCreator` can specify `user` as post’s creator and `guardian` to verify posting permissions, I would like Discourse Chat to have similar behavior, which would allow plugins to help send messages from a user (whether it is in the chat channel or not) with the guardian of the system user.

> <https://github.com/discourse/discourse/blob/main/plugins/chat/app/services/chat/create_message.rb#L129>

> <https://github.com/discourse/discourse/blob/cdbe0f74e8659661281decdc9b54ce5e6aa53075/lib/post_creator.rb#L86>

Usage: In Discourse Automation and Chat bridge, you need to send chat messages from plugin. But currently this script will most likely fail to be sent because the user you specify (e.g. DiscoBot) may not be in the channel.

> [@Chat message failed to send because of channel membership](https://meta.discourse.org/t/chat-message-failed-to-send-because-of-channel-membership/283510):
>
> Some time ago, we encountered a problem with Discourse-Automation where we could not send chat messages regularly. We use it to send weekly news in the chat channel. I noticed in the /logs that chat messages failed to send due to permission issues. I think the sender configured in discourse automation should simply ignore the channel’s permission settings, since this is set by the administrator. In fact, I am using DiscoBot as the messaging user. Since DiscoBot was not active in the category bo…

> <https://github.com/discourse/discourse/blob/cdbe0f74e8659661281decdc9b54ce5e6aa53075/plugins/chat/plugin.rb#L454>

I know the team is very busy, so I can do this by myself. I hope the Discourse team thinks this can be added to the core, then I will take the time to modify the code here and submit a pull request.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [November 13, 2023, 2:52pm UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249/2 "2023-11-13T14:52:34Z")

</div>

[Discourse Chatbot](https://meta.discourse.org/t/discourse-chatbot-now-smarter-than-chatgpt/256652) solved a similar challenge with current code without needing any specific changes in core, have you taken a look at my solution?

> <https://github.com/merefield/discourse-chatbot/blob/f782223d5f6306e865a1604548fd11d4833b5c7c/lib/discourse_chatbot/reply_creator.rb#L7>

> <https://github.com/merefield/discourse-chatbot/blob/f782223d5f6306e865a1604548fd11d4833b5c7c/lib/discourse_chatbot/message/message_reply_creator.rb#L12>

---

<div class="post-metadata">

### Author: ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)
#### Post date: [November 14, 2023, 2:36am UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249/3 "2023-11-14T02:36:15Z")

</div>

thank you so much for your suggestion! let me see it

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [December 4, 2023, 7:53pm UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249/4 "2023-12-04T19:53:45Z")

</div>

Yes as @merefield said, a chat service accepts a guardian, and you can set the guardian as you want.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [December 8, 2023, 7:54pm UTC](https://meta.discourse.org/t/allow-specifiy-user-different-from-guardian-user-in-chat-services-such-as-chat-createmessage/285249/5 "2023-12-08T19:54:16Z")

</div>

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