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


(Jay Pfaffman) #1

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

<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.

<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:

<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?

(Michael - DiscourseHosting.com) #2

No, that shouldn’t be the case.

You can use script/discourse remap to replace, that is a lot faster.

(Jeff Atwood) #3

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.

(Régis Hanol) #4

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

(Jay Pfaffman) #5

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.

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

Yes, hence:

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.

(Gerhard Schlager) #6

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?

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

(Jay Pfaffman) #7

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.

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