# Curl报告用户已创建，但实际上并未生效

**URL:** https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119
**Category:** Support
**Created:** [2023年三月23日 07:04 UTC](https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119 "2023-03-23T07:04:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MikeNolan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikenolan/32/297597_2.png) [@MikeNolan](https://meta.discourse.org/u/MikeNolan)
#### Post date: [2023年三月23日 07:04 UTC](https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119/1 "2023-03-23T07:04:22Z")

</div>

我一直在尝试一个导入用户的流程，并且快完成了。我收到了 curl 的响应，说它发送了一个邀请，但没有收到电子邮件，据我所知，数据库中也没有记录邀请。

这是 curl 命令：

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](mailto:email=mnolan@tssi.com)” -F “password=secret” -F “name=Mike Nolan” -F “staged=true” -F “active=true” -F “approved=true” “[https://mysite/users.json/](https://mysite/users.json/)”

这是响应：

“success”:true,“active”:false,“message”:“

You’re almost done! We sent an activation mail to **[mnolan@tssi.com](mailto:mnolan@tssi.com)**. Please follow the instructions in the mail to activate your account.

If it doesn’t arrive, check your spam folder.

”}

另外，我以为设置 active=true 可以避免发送确认邮件。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2023年三月23日 17:08 UTC](https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119/2 "2023-03-23T17:08:21Z")

</div>

我不认为你想要 `staged=true`。我会尝试那个。

在某个时候，你不得不分一步创建用户，再分一步激活。

你或许可以退一步，多说一些你想要做什么。你是一次性导入很多用户（那么导入脚本会更好），还是持续进行（那么 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 可能会更好）。

---

<div class="post-metadata">

### Author: ![MikeNolan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikenolan/32/297597_2.png) [@MikeNolan](https://meta.discourse.org/u/MikeNolan)
#### Post date: [2023年三月23日 17:41 UTC](https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119/3 "2023-03-23T17:41:05Z")

</div>

问题已解决，我必须确保标头正确格式化，使用冒号而不是等号。

我尝试查看 mbox 导入脚本，但正如这篇帖子中所述，它似乎缺少很多东西：

> [@Migrate a mailing list to Discourse (mbox, Listserv, Google Groups, etc)](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/232):
>
> That’s a valid point, Jay. I’m not finding the import\_mbox.sh file and when I try executing the mbox.rb script directly, I get a bunch of Ruby errors: root@lists-import:/var/www/discourse/script/import\_scripts# ruby mbox.rb mbox fatal: detected dubious ownership in repository at ‘/var/www/discourse’ To add an exception for this directory, call: git config --global --add safe.directory /var/www/discourse /var/www/discourse/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader…

无论如何，我想尝试创建用户 ID（mailman 不使用它们），因为我正在导入 20 年的存档，而许多用户已不再存在或使用了不同的电子邮件地址。我现在数据库中有大约 700 个来自旧系统的用户，添加 100,000 篇帖子可能会带来其他问题。

我删除了 staged=true 字段，它似乎不起作用。

我花了一个晚上编写了一些 PHP 工具来解析所有这些 Mailman pipermail 存档并构建了一组用户 ID，这还不错。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年四月22日 17:42 UTC](https://meta.discourse.org/t/curl-reports-user-created-but-it-didnt-really-work/259119/4 "2023-04-22T17:42:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
