Chat message failed to send because of channel membership

AI-generated summary

Lhc_fl encountered an issue with Discourse-Automation, where chat messages failed to send due to permission issues. The problem occurred because the messaging user, DiscoBot, was automatically removed from the channel due to inactivity in the bound category. This removal caused the scheduled chat message to fail. Lhc_fl suggests that the sender configured in Discourse-Automation should ignore the channel’s permission settings, as they are set by the administrator. The error log indicates a “Model not found” error, which Lhc_fl believes may be a bug.

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 bound to the channel - of course - it was automatically removed from the channel, and the scheduled chat message we set therefore undeliverable.

I don’t know, but I feel like this is a Contribute > Bug

[discourse-automation] Chat message failed to send:
[1/25] [policy] 'no_silenced_user' ✅
[2/25] [contract] 'default' ✅
[3/25] [model] 'channel' ✅
[4/25] [policy] 'allowed_to_join_channel' ✅
[5/25] [policy] 'allowed_to_create_message_in_channel' ✅
[6/25] [step] 'enforce_system_membership' ✅
[7/25] [model] 'channel_membership' ❌
[8/25] [model] 'reply'
[9/25] [policy] 'ensure_reply_consistency'
[10/25] [model] 'thread'
[11/25] [policy] 'ensure_valid_thread_for_channel'
[12/25] [policy] 'ensure_thread_matches_parent'
[13/25] [model] 'uploads'
[14/25] [model] 'message'
[15/25] [transaction]
[16/25]   [step] 'save_message'
[17/25]   [step] 'delete_drafts'
[18/25]   [step] 'post_process_thread'
[19/25]   [step] 'create_webhook_event'
[20/25]   [step] 'update_channel_last_message'
[21/25]   [step] 'update_membership_last_read'
[22/25]   [step] 'process_direct_message_channel'
[23/25] [step] 'publish_new_thread'
[24/25] [step] 'publish_new_message_events'
[25/25] [step] 'publish_user_tracking_state'
/var/www/discourse/plugins/chat/app/services/service/base.rb:143:in `call': Model not found (ArgumentError)

        raise ArgumentError, "Model not found" if !optional && context[name].blank?
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	from /var/www/discourse/plugins/chat/app/services/service/base.rb:368:in `block in run!'
	from /var/www/discourse/plugins/chat/app/services/service/base.rb:368:in `each'
	from /var/www/discourse/plugins/chat/app/services/service/base.rb:368:in `run!'
	from /var/www/discourse/plugins/chat/app/services/service/base.rb:361:in `run'
	from <internal:kernel>:90:in `tap'
	from /var/www/discourse/plugins/chat/app/services/service/base.rb:229:in `call'
	from /var/www/discourse/plugins/chat/plugin.rb:451:in `block (3 levels) in activate!'
	from /var/www/discourse/plugins/discourse-automation/app/models/discourse_automation/automation.rb:131:in `trigger!'
	from /var/www/discourse/plugins/discourse-automation/app/controllers/discourse_automation/automatio...