# 如何激活大量导入的mbox存档中的用户

**URL:** <https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903>\
**Category:** Support\
**Created:** [2023年三月13日 04:00 UTC](https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903 "2023-03-13T04:00:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)\
**Post date:** [2023年三月13日 04:00 UTC](https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903/1 "2023-03-13T04:00:30Z")

</div>

我成功地导入了一个现有邮件列表长达 20 年的 mbox 存档，这得益于此列表上的良好说明。在此期间，有超过 6.5K 的唯一用户。他们已被创建为暂存用户，尚未激活。

我的问题是，对于该列表的现有用户，他们如何激活他们的帐户？据我所知，他们无法登录，因此无法激活。我是否必须手动激活数百个单独的用户？该怎么办？

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2023年三月13日 09:27 UTC](https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903/2 "2023-03-13T09:27:27Z")

</div>

> [@Andro](#):
>
> As far as I can see, they cannot log in

你好 Andrew 👋

我对分阶段账户不太熟悉。幸运的是，这里有一个很好的解释：

> [@sam](#):
>
> ### Staged
> 
> A special placeholder account which is created automatically by the system for email integration
> 
> - No email digests are ever sent
> - Automatically watches all messages it participates in and receives notifications of replies
> - May reply via email to notifications
> - Username and Name are automatically picked
> - Account may still register with the same email and “take over” the staged account.
> - Forgot password will do nothing …when you attempt to send a password reset to a staged account
> 
> **Storage** : `staged` field in `users` table

如果你想“取消分阶段”成千上万的用户，我认为你可以遵循以下步骤（应根据你的情况稍作调整）：

> [@Staged users remain staged even after activation and must be manually unstaged](https://meta.discourse.org/t/staged-users-remain-staged-even-after-activation-and-must-be-manually-unstaged/70714/4?u=canapin):
>
> Just in case other people needs to manually unstage a user: Step 0: SSH to your VM ssh my.discourse.domain.com Step 1: Enter the discourse container cd /var/discourse sudo ./launcher enter app Step 2: Enter the Rails console rails c Step 3, Option 1: Unstage the user by email address User.find\_by\_email("email@address.com").update(staged: false) Step 3, Option 2: Unstage the user by username User.where(username: "username").update\_all(staged: false) Step 4: Finito, get out Press ^D a few ti…

这可能也让你感兴趣：

> [@Is it possible to bulk activate pending users with the rails console?](https://meta.discourse.org/t/is-it-possible-to-bulk-activate-pending-users-with-the-rails-console/139787/2?u=canapin):
>
> Probably, but I don’t think this is good practice because you might end up spamming out emails to unverified addresses. myInactiveUsers = User.where(active: false) myInactiveUsers.each do |myInactiveUser| myInactiveUser.active = true myInactiveUser.save! end The above script should work, but I’m not sure if there would be additional unintended side-effects (functionally), use at your own risk! This is just [Active Record Basics — Ruby on Rails Guides](https://guides.rubyonrails.org/active_record_basics.html) And knowing the basic objects that Di…

⚠ Rails 命令始终具有潜在危险，仅在你了解你在做什么时才执行，并且 **始终** 在执行前备份你的站点。

---

<div class="post-metadata">

**Author:** ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)\
**Post date:** [2023年三月13日 09:50 UTC](https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903/3 "2023-03-13T09:50:44Z")

</div>

在我看来，这就像必须为数百名用户单独操作一样。这不是我想要的答案。我宁愿通过 Web 界面浏览过去几年的帖子并手动激活。

那么，其他人如何处理大型 mbox 存档导入呢？

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2023年三月13日 22:26 UTC](https://meta.discourse.org/t/how-to-activate-users-after-a-large-import-of-mbox-archives/257903/4 "2023-03-13T22:26:25Z")

</div>

您的用户需要在新的 Discourse 站点上使用与邮件列表相同的电子邮件地址注册。他们的临时用户将在注册过程中转换为常规用户。

20 年是很长的时间，所以我猜想您的用户在这期间可能使用过很多不同的电子邮件地址。我建议他们使用他们当前的电子邮件地址注册，然后您可以手动[合并](https://meta.discourse.org/t/discourse-2-5-0-beta3-release-notes/148766#merge-users-via-the-ui-3)其他临时用户到该账户。
