Check if a user with the same email address exists on the opposite server
If no such user exists, create a staged user
Change the staged user’s notification settings so they don’t get email notifications
Create or update the post under the appropriate real or staged user
Probably a timed routine to go through topics and make sure nothing was missed, and possibly reorder so both sides agree
From Understanding user statuses, roles, and permissions, I think that staged users would basically do what we want – if someone did create an account with that email address later, they could “claim” it and interact with all their posts just as if they’d been there all along.
But, is there a way to create a staged user from the API? I don’t see that in Discourse API Docs.
and possibly also Like and Solved events, but not in the first cut ↩︎
I definitely thought about this before writing out this list ↩︎
using email addresses as key because account systems may not have same usernames ↩︎
I saw a post about this being possible somewhere around here… ↩︎
Well, kind of. As the OP in that topic says, in reply to that…
… and there, the answer is to basically inject an email and let the email handling code take care of it. But, that doesn’t work for this case, because I need to intervene and turn off email notifications for the user before creating the post.
It happens that we have SSO-overrides-username turned on for one side of the proposed bridge, so I think just creating something like ‘othersite-user’ could be a workaround… but that won’t necessarily work without that SSO setting.
With this approach it’s going to look as though users have created topics and replies via email. Staged users can only create posts via email. You’ll get an invalid access error if you attempt to create a non-email post for a staged user via the API.
Something about the staged user approach doesn’t feel quite right to me. It might be worth polling your users to see if they have any concerns. If you could get permission from your users, you could just create active non-staged users on the mirror site, then post their topics and comments via the API.
Passing staged: true creates a staged user. I’m assuming a user created in this way will be able to post via email. My local dev site isn’t configured to send emails to Discourse, so I can’t test that at the moment.
I’ve been wanting to use discourse as a generic form processor to handle contact forms. I hate contact forms, but some users would rather use a contact form them than send an email. Even if I think those people make bad decisions, I’d like to make it easier for them to contact me so they can give me money.
It would be really handy to be able to create a message that creates a staged user without having to resort to some other system to process the form and send an email.
I assume I’ll need to create a plugin to do this, but that’s my plan.
This is one of the only things I have left to figure out to get rid of wordpress.
So maybe what I’ll do in the plugin is create the post as if it were an email. That might not be too hard on a plugin. And that would likely make it possible via am api.