# Discobot, avatars, uploads include hard-code hostname in cooked

**URL:** https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736
**Category:** Migration
**Created:** [April 19, 2018, 5:46pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736 "2018-04-19T17:46:42Z")
**Posts on this page:** 7
**Page:** 1

<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: [April 19, 2018, 5:46pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/1 "2018-04-19T17:46:42Z")

</div>

On a fresh import, I see that Discobot creates cooked posts that contain

```html
<p>If you’d like to learn more, select <img src=\"//importer.ltcmp.net/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png\" width=\"16\" height=\"16\"> below and <img src=\"//importer.ltcmp.net/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png\" width=\"16\" height=\"16\"> <strong>bookmark this personal message</strong>. If you do, there may be a <img src=\"//importer.ltcmp.net/images/emoji/twitter/gift.png?v=5\" title=\":gift:\" class=\"emoji\" alt=\":gift:\"> in your future!</p>

```

It would seem to me hard-coding the site URL isn’t necessary here, though there could well be something that I’m missing that makes including the site name in the URL desirable or necessary.

Also, I see that avatars get cooked like this, also with the host name similarly included.

```html
<img alt width=\"20\" height=\"20\" src=\"//importer.ltcmp.net/letter_avatar_proxy/v2/letter/c/e47774/40.png\" class=\"avatar\"> cmomoney:</div>\n" + try this again: https://www.dropbox.com/s/8b1lo2hndsu782t/save_game_logic_1_2.zip?dl=0\n" +
  "<blockquote>\n" +

```

Oh, and uploads are also cooked like this:

```html
<p><div class=\"lightbox-wrapper\"><a class=\"lightbox\" href=\"//importer.ltcmp.net/uploads/default/original/3X/9/5/9514790cc658fe7049620ed26dfebf7bbdd47fe0.jpg\" data-download-href=\"//importer.ltcmp.net/uploads/default/9514790cc658fe7049620ed26dfebf7bbdd47fe0\" title=\"YGYPYG.jpg\"><img src=\"//importer.ltcmp.net/uploads/default/optimized/3X/9/5/9514790cc658fe7049620ed26dfebf7bbdd47fe0_1_690x387.jpg\" width=\"690\" height=\"387\"><div class=\"meta\">\n" +
   "<span class=\"filename\">YGYPYG.jpg</span><span class=\"informations\">1919x1079 435 KB</span><span class=\"expand\"></span>\n" +
   "</div></a></div><br> Working on some game assets and decided to make some art with it as well.</p>",

```

Perhaps all of these need the hostname embedded to make multisite work?

I think that my immediate solution is to set `force_hostname` before I run the importer. Does that seem right? The other solution that I can think of would be to rebake posts that contain `importer_hostname` in `cooked`.

Also, the more I think about it, the more I think that discobot should be disabled by default on imports. @gerhard, @tgxworld, What do you think? If you agree, I’ll endeavor to submit a PR wtih that in `base.rb`. Or maybe turn it off before import and restore it after the import is done?

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [April 19, 2018, 5:54pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/2 "2018-04-19T17:54:35Z")

</div>

> [@pfaffman](#):
>
> Perhaps all of these need the hostname embedded to make multisite work?

No, that shouldn’t be the case.  
…  
You can use `script/discourse remap` to replace, that is a lot faster.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [April 19, 2018, 9:54pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/3 "2018-04-19T21:54:01Z")

</div>

> [@pfaffman](#):
>
> I think that my immediate solution is to set force\_hostname before I run the importer. Does that seem right?

I believe that setting has caused a lot of trauma recently (and as I understand it, is meant to be strictly local dev only) so I’m surprised you would reach for it again.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 19, 2018, 10:56pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/4 "2018-04-19T22:56:16Z")

</div>

I’m curious, are you importing in development or production mode?

---

<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: [April 19, 2018, 11:05pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/5 "2018-04-19T23:05:58Z")

</div>

> [@zogstrip](#):
>
> I’m curious, are you importing in development or production mode?

This is in production mode, on a variation of `phpbb3.template.yml`. In the past I’ve always used a development environment, so perhaps I have some fundamental misunderstanding of how it works in Development.

> [@codinghorror](#):
>
> I believe that setting has caused a lot of trauma recently (and as I understand it, is meant to be strictly local dev only) so I’m surprised you would reach for it again.

Sorry about that. I suspect that it was more traumatic for Josh and Team than I know.

Yes, hence:

> [@pfaffman](#):
>
> Or maybe turn it off before import and restore it after the import is done?

My notion was that if I set that then the above-mentioned URLs would have to correct hostname so they wouldn’t need to be remapped.

**But** `script/discourse remap` seems to be the solution that I’m searching for.

Speaking of trauma, I’ve got 2 imports (one for a hosted customer) that each took over a week to run that went off the rails, so I really want to make sure that I don’t goof it up again.

---

<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: [April 19, 2018, 11:34pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/6 "2018-04-19T23:34:29Z")

</div>

> [@pfaffman](#):
>
> This is in production mode

I’m always setting the `DISCOURSE_HOSTNAME` to the correct hostname when I’m running an import within a Docker container. Is that not an option?

> [@pfaffman](#):
>
> I think that discobot should be disabled by default on imports.

I’m not sure about that. Imported users might also need to learn how to use Discourse…

---

<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: [April 20, 2018, 2:32pm UTC](https://meta.discourse.org/t/discobot-avatars-uploads-include-hard-code-hostname-in-cooked/85736/7 "2018-04-20T14:32:07Z")

</div>

> [@gerhard](#):
>
> I’m always setting the DISCOURSE\_HOSTNAME to the correct hostname when I’m running an import within a Docker container. Is that not an option?

Doh! **That’s** what I should be doing. It somehow didn’t occur to me since it’s not the host name of the import machine. So that’s how to “force” the hostname.

> [@gerhard](#):
>
> I’m not sure about that. Imported users might also need to learn how to use Discourse

Hmm.When you say it like that, it makes me sound foolish. 😉 It’s just that with tens or hundreds of thousands of users, it makes for a big sidekiq queue. . .
