Curl מדווח על יצירת משתמש, אך זה לא באמת עבד

סיכום מבוסס בינה מלאכותית

MikeNolan encountered an issue where a curl command to create a user in Discourse reported success but no activation email was sent and no invite was logged. The command included parameters like staged=true, active=true, and approved=true, but the response indicated the user remained inactive. pfaffman suggested removing staged=true, noting that user creation and activation may require separate steps, and asked for clarification on whether this was a one-time import or ongoing process — suggesting an import script or DiscourseConnect might be more appropriate. MikeNolan resolved the issue by correcting header formatting (replacing = with : in headers) and confirmed that staged=true was unnecessary and nonfunctional. He explained his goal: importing 20 years of Mailman archives with ~700 users (many inactive or with changed emails), for which he built custom PHP tools to generate user IDs. He noted concerns about importing 100,000 posts and referenced a meta.discourse.org post highlighting gaps in the mbox import script.

I’ve been working on a process to import users, and am getting close. I’m getting a response from curl saying it sent an invite, but no email was sent and as far as I can tell no invite was logged in the database.

Here’s the curl command:

curl -X POST -H “Content-Type: multipart/form-data;” -H “api-key=secret” -H “api-username=system” -F “username=1002-nolan” -F “email=mnolan@tssi.com” -F “password=secret” -F “name=Mike Nolan” -F “staged=true” -F “active=true” -F “approved=true” “https://mysite/users.json/”

Here’s the response:

“success”:true,“active”:false,“message”:“\u003cp\u003eYou’re almost done! We sent an activation mail to \u003cb\u003emnolan@tssi.com\u003c/b\u003e. Please follow the instructions in the mail to activate your account.\u003c/p\u003e\u003cp\u003eIf it doesn’t arrive, check your spam folder.\u003c/p\u003e”}

Also, I thought setting active=true would avoid sending a confirmation email.

I don’t think you want staged=true. That’s what I’d try next.

At some point, you had to create the user in one step and activate in another.

You might take a step back and say more about what you’re trying to do. Do you want to import a bunch of users once (so an import script would be better) or do this continually (so DiscourseConnnect might be better).

Problem solved, I had to make sure the headers were properly formatted with a colon rather than an equals sign.

I tried looking at the mbox import script, but it seems to be missing a bunch of stuff, as noted in this post:

Anyway, I wanted to play with creating the user IDs (mailman doesn’t use them) because what I’m doing is importing 20 years worth of archives and a lot of those users are no longer around or using different email addresses. I’ve got around 700 users from the old system in the database now, adding 100,000 posts might present some other issues.

I dropped the staged=true field, it didn’t appear to be working anyway.

It took me an evening to write some PHP tools that parsed all those Mailman pipermail archives and built a set of user IDs, which wasn’t too bad.