# プライベートメッセージ：バニラからインポートした際に送信済みから受信トレイに入れる方法

**URL:** https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332
**Category:** Support
**Created:** [2021 年 1 月 26 日午後 4:13 UTC](https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332 "2021-01-26T16:13:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Cyan\_Suntay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyan_suntay/32/206851_2.png) [@Cyan\_Suntay](https://meta.discourse.org/u/Cyan_Suntay)
#### Post date: [2021 年 1 月 26 日午後 4:13 UTC](https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332/1 "2021-01-26T16:13:41Z")

</div>

200万件のプライベートメッセージをインポートしましたが、Vanillaからインポートした際、送信済みから受信トレイへどう移動させればよいでしょうか。

---

<div class="post-metadata">

### Author: ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)
#### Post date: [2021 年 1 月 26 日午後 4:23 UTC](https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332/2 "2021-01-26T16:23:13Z")

</div>

通常、受信トレイには、以下のいずれかの条件に該当するプライベートメッセージのみが表示されます。

1. 他者から送信されたプライベートメッセージを受信した場合。
2. 自分が送信したプライベートメッセージに対して誰かが返信した場合。

他の掲示板からインポートする際、上記の条件2に該当するプライベートメッセージが、トピックに返信があっても受信トレイに正しく表示されないことに気づきました。これは、受信トレイのクエリにトピックの `participant_count` フィールドに関する条件があることが原因のようです。インポーターはこのフィールドを正しく更新しないため、デフォルトで `1` に設定されます。`participant_count` が `1` の場合、そのトピックは受信トレイビューに表示されるためにクエリで返されません。

これを修正するには、インポーターを調整してプライベートメッセージの参加者数を含めるか、インポート後に参加者数を更新する必要があります。後者は、rails コンソールで以下のコマンドを実行することで達成できます。

`Topic.private_messages.map(&:update_statistics)`

詳細はこちらをご覧ください。

> [@Imported private discussion doesn't appear in the author inbox](https://meta.discourse.org/t/imported-private-discussion-doesnt-appear-in-the-author-inbox/163252):
>
> Hi, I’m trying to import private messages from a vBulletin5 database. It works, but in the author profile the discussion only appears in “sent”, not in “inbox”. On the other participant profile, the discussion correctly appears in “inbox” as well as in “sent”. Author profile: Appears in “sent” But not in “inbox” Other participant profile: Appears in both: How can I make the discussion appears in the inbox of the author? My current messy code if ne…

---

<div class="post-metadata">

### Author: ![Cyan\_Suntay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyan_suntay/32/206851_2.png) [@Cyan\_Suntay](https://meta.discourse.org/u/Cyan_Suntay)
#### Post date: [2021 年 1 月 30 日午前 2:31 UTC](https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332/3 "2021-01-30T02:31:04Z")

</div>

Ghan さん、ありがとうございます！会話内の両方のユーザーが表示されるようになりました。

---

<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: [2021 年 3 月 1 日午前 2:31 UTC](https://meta.discourse.org/t/private-messages-how-to-put-to-inbox-from-sent-when-imported-from-vanilla/177332/4 "2021-03-01T02:31:58Z")

</div>

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