# インポートされた投稿のリンクにoneboxプレビューを生成する

**URL:** https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879
**Category:** Migration
**Tags:** onebox
**Created:** [2023 年 3 月 12 日午後 6:41 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879 "2023-03-12T18:41:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![shyguy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shyguy/32/295079_2.png) [@shyguy](https://meta.discourse.org/u/shyguy)
#### Post date: [2023 年 3 月 12 日午後 6:41 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/1 "2023-03-12T18:41:44Z")

</div>

インポートされた投稿のリンクでは、ワンボックスプレビューは生成されないということで合っていますか？  
例えば、phpBB移行のYouTubeリンクでは表示されていません。

これを実現するためのポインタはありますか？よろしくお願いします。

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [2023 年 3 月 12 日午後 6:54 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/2 "2023-03-12T18:54:33Z")

</div>

テストとして1つの投稿のHTMLを再構築した場合、それはワンボックス化されますか？

 ![Screenshot 2023-03-12 at 18.54.09](https://global.discourse-cdn.com/meta/original/4X/e/e/e/eee409bf43f3d327f4b496fcc7cd652922b08d86.png)

---

<div class="post-metadata">

### Author: ![shyguy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shyguy/32/295079_2.png) [@shyguy](https://meta.discourse.org/u/shyguy)
#### Post date: [2023 年 3 月 12 日午後 7:07 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/3 "2023-03-12T19:07:37Z")

</div>

はい、その通りです！

一括で実行するにはどうすればよいですか？

---

<div class="post-metadata">

### Author: ![shyguy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shyguy/32/295079_2.png) [@shyguy](https://meta.discourse.org/u/shyguy)
#### Post date: [2023 年 3 月 12 日午後 7:17 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/4 "2023-03-12T19:17:28Z")

</div>

**警告のため、このスレッド全体をお読みください！**

これを試してみます…

```bash
docker exec discourse-app rake posts:rebake

```

編集：はい、これは機能します  
ヒントをくれた @Richie さん、ありがとう

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [2023 年 3 月 12 日午後 7:24 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/5 "2023-03-12T19:24:41Z")

</div>

実行する前に…

> [@How to avoid potential issues when rebaking all posts?](https://meta.discourse.org/t/how-to-avoid-potential-issues-when-rebaking-all-posts/249271):
>
> Hi! Rebaking all posts is sometimes a recommended action for various reasons. After my own experience of a rebake experience that raised issues and seen/foresee other potential others, I’d like to know how they can be avoided. If I rebake my 2M posts, it will trigger too many requests to Youtube and [my IP will be blacklisted](https://meta.discourse.org/t/onebox-assistant-crawl-for-those-previews-reliably/107405/128), preventing Discourse from generating previews. If oneboxes (with titles, thumbnails, excerpts copied in Discourse database - cooked field) original URLs went to be …

---

<div class="post-metadata">

### Author: ![Richie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richie/32/115110_2.png) [@Richie](https://meta.discourse.org/u/Richie)
#### Post date: [2023 年 3 月 12 日午後 7:26 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/6 "2023-03-12T19:26:02Z")

</div>

注意してください。oneboxの詳細を取得するために、何十万もの投稿を再ベイクする際に、YouTubeやAmazonなどのサーバーをブラックリストに登録したことで問題が発生しています 😕

---

<div class="post-metadata">

### Author: ![shyguy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shyguy/32/295079_2.png) [@shyguy](https://meta.discourse.org/u/shyguy)
#### Post date: [2023 年 3 月 12 日午後 7:36 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/8 "2023-03-12T19:36:17Z")

</div>

おっと。もうやってしまいました。大丈夫だといいのですが？

```sql
phpbb=# select count(*) from phpbb_posts where (post_text like '%youtu%' or post_text like '%instagr%' or post_text like '%facebook%');
 count
-------
  1226
(1 row)

```

大体こんな感じです。大丈夫だと思いますか？これは私の自宅IPからですよ（笑）。リンクを読んで、次回はもっと注意する方法があるか確認します。

---

<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 年 4 月 11 日午後 7:36 UTC](https://meta.discourse.org/t/generate-onebox-previews-for-links-in-imported-posts/257879/9 "2023-04-11T19:36:54Z")

</div>

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