Luicid is trying to send a private message to an email address from a plugin using the PostCreator class, but is getting a Topic is empty error. merefield suggests that the target_recipients parameter should be a group name or username, according to the specs. However, Luicid points out that the frontend uses a payload with an email address for target_recipients and it works. RGJ explains that the issue is due to using target_recipients instead of target_emails, as target_recipients is a parameter for PostsController, not PostCreator. Luicid confirms that using target_emails resolves the issue.
Hello,
I’m building a plugin and I need to send something to a user’s email.
I use
creator = PostCreator.new(test_user, {
target_recipients: "someone@toto.com",
archetype: Archetype.private_message,
subtype: TopicSubtype.system_message,
title: "Hello test subject",
raw: "This is the message. Does it work ?"
})
test_user is admin
But every time I try to send using this, I get the error : Topic is empty
Note that target_recipients is a parameter to PostsController, not an argument for PostCreator.
That controller figures out if the recipients are users, groups or email addresses and then eventually passes it as target_emails to NewPostsManager and it ends up in TopicCreator.