mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 06:52:41 +08:00
DEV: Extend the reviewables:populate rake task in chat (#30597)
Related to 5a55c9062a
The chat plugin now makes use of the plugin API that was added in the linked commit for extending the reviewables:populate rake task.
This commit is contained in:
parent
9c7b0ddb2f
commit
2d424676fc
|
@ -24,11 +24,21 @@ module DiscourseDev
|
||||||
::Chat::UserChatChannelMembership.where(chat_channel: channel).order("RANDOM()").first
|
::Chat::UserChatChannelMembership.where(chat_channel: channel).order("RANDOM()").first
|
||||||
user = membership.user
|
user = membership.user
|
||||||
|
|
||||||
{ guardian: user.guardian, message: Faker::Lorem.paragraph, chat_channel_id: channel.id }
|
{
|
||||||
|
guardian: user.guardian,
|
||||||
|
params: {
|
||||||
|
message: Faker::Lorem.paragraph,
|
||||||
|
chat_channel_id: channel.id,
|
||||||
|
},
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def create!
|
def create!
|
||||||
Chat::CreateMessage.call(data)
|
message = nil
|
||||||
|
Chat::CreateMessage.call(data) do
|
||||||
|
on_success { |message_instance:| message = message_instance }
|
||||||
|
end
|
||||||
|
message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
21
plugins/chat/lib/discourse_dev/reviewable_message.rb
Normal file
21
plugins/chat/lib/discourse_dev/reviewable_message.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module DiscourseDev
|
||||||
|
class ReviewableMessage < Reviewable
|
||||||
|
def populate!
|
||||||
|
channel = CategoryChannel.new.create!
|
||||||
|
message = Message.new(channel_id: channel.id, count: 1).create!
|
||||||
|
user = @users.sample
|
||||||
|
|
||||||
|
::Chat::FlagMessage.call(
|
||||||
|
guardian: user.guardian,
|
||||||
|
params: {
|
||||||
|
channel_id: channel.id,
|
||||||
|
message_id: message.id,
|
||||||
|
flag_type_id:
|
||||||
|
ReviewableScore.types.slice(:off_topic, :inappropriate, :spam, :illegal).values.sample,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -512,6 +512,8 @@ after_initialize do
|
||||||
# When we eventually allow secure_uploads in chat, this will need to be
|
# When we eventually allow secure_uploads in chat, this will need to be
|
||||||
# removed. Depending on the channel, uploads may end up being secure.
|
# removed. Depending on the channel, uploads may end up being secure.
|
||||||
UploadSecurity.register_custom_public_type("chat-composer")
|
UploadSecurity.register_custom_public_type("chat-composer")
|
||||||
|
|
||||||
|
DiscoursePluginRegistry.discourse_dev_populate_reviewable_types.add DiscourseDev::ReviewableMessage
|
||||||
end
|
end
|
||||||
|
|
||||||
if Rails.env == "test"
|
if Rails.env == "test"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user