{"action":"created","comment":{"url":"https://api.github.com/repos/discourse/discourse/pulls/comments/209441323","pull_request_review_id":145461120,"id":209441323,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTQ0MTMyMw==","diff_hunk":"@@ -71,16 +71,28 @@ def self.import(user, url, title, contents)\n     else\n       absolutize_urls(url, contents)\n       post = embed.post\n+\n       # Update the topic if it changed\n-      if post && post.topic && content_sha1 != embed.content_sha1\n-        post_revision_args = {\n-          raw: absolutize_urls(url, contents),\n-          user_id: user.id,\n-          title: title,\n-        }\n-\n-        post.revise(user, post_revision_args, skip_validations: true, bypass_rate_limiter: true)\n-        embed.update_column(:content_sha1, content_sha1)\n+      if post&.topic\n+        revision = {}\n+\n+        if post.user != user\n+          PostOwnerChanger.new(\n+            post_ids: [post.id],\n+            topic_id: post.topic_id,\n+            new_owner: user,\n+            acting_user: Discourse.system_user\n+          ).change_owner!\n+\n+          # make sure the post returned has the right author\n+          post.reload\n+        end\n+\n+        revision[:raw] = absolutize_urls(url, contents) if content_sha1 != embed.content_sha1\n+        revision[:title] = title if title != post.topic.title\n+\n+        post.revise(user, revision, skip_validations: true, bypass_rate_limiter: true) unless revision.empty?\n+        embed.update_column(:content_sha1, content_sha1) if revision[:raw]","path":"app/models/topic_embed.rb","position":34,"original_position":34,"commit_id":"b23c8bca3ebb750b35243c346ff007c4ba485d1d","original_commit_id":"6436c1bf3e8572e17d6502867a920c16980c9e72","user":{"login":"xrav3nz","id":6376558,"node_id":"MDQ6VXNlcjYzNzY1NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6376558?v=4","gravatar_id":"","url":"https://api.github.com/users/xrav3nz","html_url":"https://github.com/xrav3nz","followers_url":"https://api.github.com/users/xrav3nz/followers","following_url":"https://api.github.com/users/xrav3nz/following{/other_user}","gists_url":"https://api.github.com/users/xrav3nz/gists{/gist_id}","starred_url":"https://api.github.com/users/xrav3nz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrav3nz/subscriptions","organizations_url":"https://api.github.com/users/xrav3nz/orgs","repos_url":"https://api.github.com/users/xrav3nz/repos","events_url":"https://api.github.com/users/xrav3nz/events{/privacy}","received_events_url":"https://api.github.com/users/xrav3nz/received_events","type":"User","site_admin":false},"body":"(also, open suggestions to style refactors; my changes feel a bit awkward to me in terms of flow and readability, but couldn't think of better ways 😢 )","created_at":"2018-08-12T01:48:39Z","updated_at":"2018-08-12T01:48:39Z","html_url":"https://github.com/discourse/discourse/pull/6261#discussion_r209441323","pull_request_url":"https://api.github.com/repos/discourse/discourse/pulls/6261","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/discourse/discourse/pulls/comments/209441323"},"html":{"href":"https://github.com/discourse/discourse/pull/6261#discussion_r209441323"},"pull_request":{"href":"https://api.github.com/repos/discourse/discourse/pulls/6261"}},"in_reply_to_id":209440862},"pull_request":{"url":"https://api.github.com/repos/discourse/discourse/pulls/6261","id":207799275,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3Nzk5Mjc1","html_url":"https://github.com/discourse/discourse/pull/6261","diff_url":"https://github.com/discourse/discourse/pull/6261.diff","patch_url":"https://github.com/discourse/discourse/pull/6261.patch","issue_url":"https://api.github.com/repos/discourse/discourse/issues/6261","number":6261,"state":"open","locked":false,"title":"FIX: update TopicEmbed's title and user correctly","user":{"login":"xrav3nz","id":6376558,"node_id":"MDQ6VXNlcjYzNzY1NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6376558?v=4","gravatar_id":"","url":"https://api.github.com/users/xrav3nz","html_url":"https://github.com/xrav3nz","followers_url":"https://api.github.com/users/xrav3nz/followers","following_url":"https://api.github.com/users/xrav3nz/following{/other_user}","gists_url":"https://api.github.com/users/xrav3nz/gists{/gist_id}","starred_url":"https://api.github.com/users/xrav3nz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrav3nz/subscriptions","organizations_url":"https://api.github.com/users/xrav3nz/orgs","repos_url":"https://api.github.com/users/xrav3nz/repos","events_url":"https://api.github.com/users/xrav3nz/events{/privacy}","received_events_url":"https://api.github.com/users/xrav3nz/received_events","type":"User","site_admin":false},"body":"#5771 tried to add support for updating title and author of imported `TopicEmbed`s, but I made two mistakes:\r\n\r\n1. Title and author won't be updated unless the content also changed\r\n2. Changing the (topic's) user should be done with `PostOwnerChanger` instead of `PostRevisor`.\r\n\r\nThis PR resolves ⬆️.","created_at":"2018-08-12T01:00:17Z","updated_at":"2018-08-12T01:48:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c29fc423c9b27dc378c0fa7ff32ad1c867e1336","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/discourse/discourse/pulls/6261/commits","review_comments_url":"https://api.github.com/repos/discourse/discourse/pulls/6261/comments","review_comment_url":"https://api.github.com/repos/discourse/discourse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/discourse/discourse/issues/6261/comments","statuses_url":"https://api.github.com/repos/discourse/discourse/statuses/b23c8bca3ebb750b35243c346ff007c4ba485d1d","head":{"label":"xrav3nz:fix/topic-embed-import-updates","ref":"fix/topic-embed-import-updates","sha":"b23c8bca3ebb750b35243c346ff007c4ba485d1d","user":{"login":"xrav3nz","id":6376558,"node_id":"MDQ6VXNlcjYzNzY1NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6376558?v=4","gravatar_id":"","url":"https://api.github.com/users/xrav3nz","html_url":"https://github.com/xrav3nz","followers_url":"https://api.github.com/users/xrav3nz/followers","following_url":"https://api.github.com/users/xrav3nz/following{/other_user}","gists_url":"https://api.github.com/users/xrav3nz/gists{/gist_id}","starred_url":"https://api.github.com/users/xrav3nz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrav3nz/subscriptions","organizations_url":"https://api.github.com/users/xrav3nz/orgs","repos_url":"https://api.github.com/users/xrav3nz/repos","events_url":"https://api.github.com/users/xrav3nz/events{/privacy}","received_events_url":"https://api.github.com/users/xrav3nz/received_events","type":"User","site_admin":false},"repo":{"id":99668064,"node_id":"MDEwOlJlcG9zaXRvcnk5OTY2ODA2NA==","name":"discourse","full_name":"xrav3nz/discourse","owner":{"login":"xrav3nz","id":6376558,"node_id":"MDQ6VXNlcjYzNzY1NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6376558?v=4","gravatar_id":"","url":"https://api.github.com/users/xrav3nz","html_url":"https://github.com/xrav3nz","followers_url":"https://api.github.com/users/xrav3nz/followers","following_url":"https://api.github.com/users/xrav3nz/following{/other_user}","gists_url":"https://api.github.com/users/xrav3nz/gists{/gist_id}","starred_url":"https://api.github.com/users/xrav3nz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xrav3nz/subscriptions","organizations_url":"https://api.github.com/users/xrav3nz/orgs","repos_url":"https://api.github.com/users/xrav3nz/repos","events_url":"https://api.github.com/users/xrav3nz/events{/privacy}","received_events_url":"https://api.github.com/users/xrav3nz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xrav3nz/discourse","description":"A platform for community discussion. Free, open, simple.","fork":true,"url":"https://api.github.com/repos/xrav3nz/discourse","forks_url":"https://api.github.com/repos/xrav3nz/discourse/forks","keys_url":"https://api.github.com/repos/xrav3nz/discourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xrav3nz/discourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xrav3nz/discourse/teams","hooks_url":"https://api.github.com/repos/xrav3nz/discourse/hooks","issue_events_url":"https://api.github.com/repos/xrav3nz/discourse/issues/events{/number}","events_url":"https://api.github.com/repos/xrav3nz/discourse/events","assignees_url":"https://api.github.com/repos/xrav3nz/discourse/assignees{/user}","branches_url":"https://api.github.com/repos/xrav3nz/discourse/branches{/branch}","tags_url":"https://api.github.com/repos/xrav3nz/discourse/tags","blobs_url":"https://api.github.com/repos/xrav3nz/discourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xrav3nz/discourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xrav3nz/discourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/xrav3nz/discourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xrav3nz/discourse/statuses/{sha}","languages_url":"https://api.github.com/repos/xrav3nz/discourse/languages","stargazers_url":"https://api.github.com/repos/xrav3nz/discourse/stargazers","contributors_url":"https://api.github.com/repos/xrav3nz/discourse/contributors","subscribers_url":"https://api.github.com/repos/xrav3nz/discourse/subscribers","subscription_url":"https://api.github.com/repos/xrav3nz/discourse/subscription","commits_url":"https://api.github.com/repos/xrav3nz/discourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/xrav3nz/discourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/xrav3nz/discourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/xrav3nz/discourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/xrav3nz/discourse/contents/{+path}","compare_url":"https://api.github.com/repos/xrav3nz/discourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xrav3nz/discourse/merges","archive_url":"https://api.github.com/repos/xrav3nz/discourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xrav3nz/discourse/downloads","issues_url":"https://api.github.com/repos/xrav3nz/discourse/issues{/number}","pulls_url":"https://api.github.com/repos/xrav3nz/discourse/pulls{/number}","milestones_url":"https://api.github.com/repos/xrav3nz/discourse/milestones{/number}","notifications_url":"https://api.github.com/repos/xrav3nz/discourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xrav3nz/discourse/labels{/name}","releases_url":"https://api.github.com/repos/xrav3nz/discourse/releases{/id}","deployments_url":"https://api.github.com/repos/xrav3nz/discourse/deployments","created_at":"2017-08-08T08:13:56Z","updated_at":"2018-07-25T17:07:19Z","pushed_at":"2018-08-12T01:19:25Z","git_url":"git://github.com/xrav3nz/discourse.git","ssh_url":"git@github.com:xrav3nz/discourse.git","clone_url":"https://github.com/xrav3nz/discourse.git","svn_url":"https://github.com/xrav3nz/discourse","homepage":"https://www.discourse.org","size":225880,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"discourse:master","ref":"master","sha":"a960a57c72d5e39eb77f30ba2c41f1ffedd49f43","user":{"login":"discourse","id":3220138,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=","avatar_url":"https://avatars2.githubusercontent.com/u/3220138?v=4","gravatar_id":"","url":"https://api.github.com/users/discourse","html_url":"https://github.com/discourse","followers_url":"https://api.github.com/users/discourse/followers","following_url":"https://api.github.com/users/discourse/following{/other_user}","gists_url":"https://api.github.com/users/discourse/gists{/gist_id}","starred_url":"https://api.github.com/users/discourse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discourse/subscriptions","organizations_url":"https://api.github.com/users/discourse/orgs","repos_url":"https://api.github.com/users/discourse/repos","events_url":"https://api.github.com/users/discourse/events{/privacy}","received_events_url":"https://api.github.com/users/discourse/received_events","type":"Organization","site_admin":false},"repo":{"id":7569578,"node_id":"MDEwOlJlcG9zaXRvcnk3NTY5NTc4","name":"discourse","full_name":"discourse/discourse","owner":{"login":"discourse","id":3220138,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMjAxMzg=","avatar_url":"https://avatars2.githubusercontent.com/u/3220138?v=4","gravatar_id":"","url":"https://api.github.com/users/discourse","html_url":"https://github.com/discourse","followers_url":"https://api.github.com/users/discourse/followers","following_url":"https://api.github.com/users/discourse/following{/other_user}","gists_url":"https://api.github.com/users/discourse/gists{/gist_id}","starred_url":"https://api.github.com/users/discourse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/discourse/subscriptions","organizations_url":"https://api.github.com/users/discourse/orgs","repos_url":"https://api.github.com/users/discourse/repos","events_url":"https://api.github.com/users/discourse/events{/privacy}","received_events_url":"https://api.github.com/users/discourse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/discourse/discourse","description":"A platform for community discussion. Free, open, simple.","fork":false,"url":"https://api.github.com/repos/discourse/discourse","forks_url":"https://api.github.com/repos/discourse/discourse/forks","keys_url":"https://api.github.com/repos/discourse/discourse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/discourse/discourse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/discourse/discourse/teams","hooks_url":"https://api.github.com/repos/discourse/discourse/hooks","issue_events_url":"https://api.github.com/repos/discourse/discourse/issues/events{/number}","events_url":"https://api.github.com/repos/discourse/discourse/events","assignees_url":"https://api.github.com/repos/discourse/discourse/assignees{/user}","branches_url":"https://api.github.com/repos/discourse/discourse/branches{/branch}","tags_url":"https://api.github.com/repos/discourse/discourse/tags","blobs_url":"https://api.github.com/repos/discourse/discourse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/discourse/discourse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/discourse/discourse/git/refs{/sha}","trees_url":"https://api.github.com/repos/discourse/discourse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/discourse/discourse/statuses/{sha}","languages_url":"https://api.github.com/repos/discourse/discourse/languages","stargazers_url":"https://api.github.com/repos/discourse/discourse/stargazers","contributors_url":"https://api.github.com/repos/discourse/discourse/contributors","subscribers_url":"https://api.github.com/repos/discourse/discourse/subscribers","subscription_url":"https://api.github.com/repos/discourse/discourse/subscription","commits_url":"https://api.github.com/repos/discourse/discourse/commits{/sha}","git_commits_url":"https://api.github.com/repos/discourse/discourse/git/commits{/sha}","comments_url":"https://api.github.com/repos/discourse/discourse/comments{/number}","issue_comment_url":"https://api.github.com/repos/discourse/discourse/issues/comments{/number}","contents_url":"https://api.github.com/repos/discourse/discourse/contents/{+path}","compare_url":"https://api.github.com/repos/discourse/discourse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/discourse/discourse/merges","archive_url":"https://api.github.com/repos/discourse/discourse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/discourse/discourse/downloads","issues_url":"https://api.github.com/repos/discourse/discourse/issues{/number}","pulls_url":"https://api.github.com/repos/discourse/discourse/pulls{/number}","milestones_url":"https://api.github.com/repos/discourse/discourse/milestones{/number}","notifications_url":"https://api.github.com/repos/discourse/discourse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/discourse/discourse/labels{/name}","releases_url":"https://api.github.com/repos/discourse/discourse/releases{/id}","deployments_url":"https://api.github.com/repos/discourse/discourse/deployments","created_at":"2013-01-12T00:25:55Z","updated_at":"2018-08-12T01:20:23Z","pushed_at":"2018-08-12T01:19:28Z","git_url":"git://github.com/discourse/discourse.git","ssh_url":"git@github.com:discourse/discourse.git","clone_url":"https://github.com/discourse/discourse.git","svn_url":"https://github.com/discourse/discourse","homepage":"https://www.discourse.org","size":226996,"stargazers_count":25762,"watchers_count":25762,"language":"Ruby","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6156,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":6156,"open_issues":8,"watchers":25762,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/discourse/discourse/pulls/6261"},"html":{"href":"https://github.com/discourse/discourse/pull/6261"},"issue":{"href":"https://api.github.com/repos/discourse/discourse/issues/6261"},"comments":{"href":"https://api.github.com/repos/discourse/discourse/issues/6261/comments"},"review_comments":{"href":"https://api.github.com/repos/discourse/discourse/pulls/6261/comments"},"review_comment":{"href":"https://api.github.com/repos/discourse/discourse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/discourse/discourse/pulls/6261/commits"},"statuses":{"href":"https://api.github.com/repos/discourse/discourse/statuses/b23c8bca3ebb750b35243c346ff007c4ba485d1d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"xrav3nz"}}