{"action":"created","comment":{"url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/comments/228760622","pull_request_review_id":169104403,"id":228760622,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODc2MDYyMg==","diff_hunk":"@@ -98,40 +93,23 @@ def user_params_update\n       )\n     end\n \n-    def validate_image_field(user_params)\n-      return if user_params['image'].nil?\n-      return if %r{^https?:\\/\\/}.match?(user_params['image'])\n-\n-      data_url_regexp = %r{\\Adata:(image/(?:png|jpeg|gif));base64,(.*)}m\n-      data_uri_parts = user_params['image'].match(data_url_regexp) || []\n-\n-      if data_uri_parts.length == 3\n-        @profile_picture_mime = data_uri_parts[1]\n-        @profile_picture_data = data_uri_parts[2]\n-        user_params['image'] = nil\n-        return\n-      end\n-      raise StandardError, 'Invalid image field!'\n-    end\n-\n-    def update_profile_picture\n-      return unless @profile_picture_mime && @profile_picture_data\n-\n-      update_picture_from_data_url(@profile_picture_mime, @profile_picture_data)\n+    # check if image is url or data\n+    def set_image_info\n+      # Get params\n+      @user_params = user_params_update\n+      @image_info = validate_image_field(@user_params, 'image')\n+    rescue StandardError => e\n+      render json: { message: e.message }, status: :unprocessable_entity\n     end\n \n-    def update_picture_from_data_url(mime, base64data)\n-      extension = MIME::Types[mime].first.preferred_extension\n-      image_file = StringIO.new(Base64.decode64(base64data))\n-      @user.profile_picture.attach(io: image_file, filename: \"avatar.#{extension}\")\n+    def update_image\n+      return unless update_image_field(@user.profile_picture, @image_info)\n       @user.image = url_for(@user.profile_picture)\n       @user.save\n     end\n \n-    def purge_stale_picture(user_params)\n-      return if user_params['image'].nil?\n-      return if user_params['image'] == \"\"\n-\n-      @user.profile_picture.purge\n+    def purge_image\n+      purge_stale_image(@user.profile_picture, @user_params, 'image')\n     end\n+","path":"app/controllers/users_controller.rb","position":98,"original_position":98,"commit_id":"bbc7fd46d0d9e0bf28ec541f0e917630c7f985f7","original_commit_id":"bbc7fd46d0d9e0bf28ec541f0e917630c7f985f7","user":{"login":"joaquinvillar","id":11573760,"node_id":"MDQ6VXNlcjExNTczNzYw","avatar_url":"https://avatars2.githubusercontent.com/u/11573760?v=4","gravatar_id":"","url":"https://api.github.com/users/joaquinvillar","html_url":"https://github.com/joaquinvillar","followers_url":"https://api.github.com/users/joaquinvillar/followers","following_url":"https://api.github.com/users/joaquinvillar/following{/other_user}","gists_url":"https://api.github.com/users/joaquinvillar/gists{/gist_id}","starred_url":"https://api.github.com/users/joaquinvillar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaquinvillar/subscriptions","organizations_url":"https://api.github.com/users/joaquinvillar/orgs","repos_url":"https://api.github.com/users/joaquinvillar/repos","events_url":"https://api.github.com/users/joaquinvillar/events{/privacy}","received_events_url":"https://api.github.com/users/joaquinvillar/received_events","type":"User","site_admin":false},"body":"nit: unnecessary line","created_at":"2018-10-28T19:04:51Z","updated_at":"2018-10-28T19:35:37Z","html_url":"https://github.com/wyeworks/pis-wyehome/pull/36#discussion_r228760622","pull_request_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/comments/228760622"},"html":{"href":"https://github.com/wyeworks/pis-wyehome/pull/36#discussion_r228760622"},"pull_request":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36","id":226326542,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2MzI2NTQy","html_url":"https://github.com/wyeworks/pis-wyehome/pull/36","diff_url":"https://github.com/wyeworks/pis-wyehome/pull/36.diff","patch_url":"https://github.com/wyeworks/pis-wyehome/pull/36.patch","issue_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/36","number":36,"state":"open","locked":false,"title":"Feature cambiar foto de grupo 160675744","user":{"login":"jpducassou","id":1499890,"node_id":"MDQ6VXNlcjE0OTk4OTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1499890?v=4","gravatar_id":"","url":"https://api.github.com/users/jpducassou","html_url":"https://github.com/jpducassou","followers_url":"https://api.github.com/users/jpducassou/followers","following_url":"https://api.github.com/users/jpducassou/following{/other_user}","gists_url":"https://api.github.com/users/jpducassou/gists{/gist_id}","starred_url":"https://api.github.com/users/jpducassou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpducassou/subscriptions","organizations_url":"https://api.github.com/users/jpducassou/orgs","repos_url":"https://api.github.com/users/jpducassou/repos","events_url":"https://api.github.com/users/jpducassou/events{/privacy}","received_events_url":"https://api.github.com/users/jpducassou/received_events","type":"User","site_admin":false},"body":"Added image upload support for group creation and update.\r\nExtracted most of the functionality from user profiles to a Rails concern mixin.\r\n","created_at":"2018-10-27T21:51:56Z","updated_at":"2018-10-28T19:35:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"603da3be3b848d03b2d0727f27f1c428cdc01848","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36/commits","review_comments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36/comments","review_comment_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/36/comments","statuses_url":"https://api.github.com/repos/wyeworks/pis-wyehome/statuses/bbc7fd46d0d9e0bf28ec541f0e917630c7f985f7","head":{"label":"wyeworks:feature-cambiar_foto_de_grupo-160675744","ref":"feature-cambiar_foto_de_grupo-160675744","sha":"bbc7fd46d0d9e0bf28ec541f0e917630c7f985f7","user":{"login":"wyeworks","id":135745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNTc0NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135745?v=4","gravatar_id":"","url":"https://api.github.com/users/wyeworks","html_url":"https://github.com/wyeworks","followers_url":"https://api.github.com/users/wyeworks/followers","following_url":"https://api.github.com/users/wyeworks/following{/other_user}","gists_url":"https://api.github.com/users/wyeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/wyeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyeworks/subscriptions","organizations_url":"https://api.github.com/users/wyeworks/orgs","repos_url":"https://api.github.com/users/wyeworks/repos","events_url":"https://api.github.com/users/wyeworks/events{/privacy}","received_events_url":"https://api.github.com/users/wyeworks/received_events","type":"Organization","site_admin":false},"repo":{"id":144744653,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ3NDQ2NTM=","name":"pis-wyehome","full_name":"wyeworks/pis-wyehome","private":false,"owner":{"login":"wyeworks","id":135745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNTc0NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135745?v=4","gravatar_id":"","url":"https://api.github.com/users/wyeworks","html_url":"https://github.com/wyeworks","followers_url":"https://api.github.com/users/wyeworks/followers","following_url":"https://api.github.com/users/wyeworks/following{/other_user}","gists_url":"https://api.github.com/users/wyeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/wyeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyeworks/subscriptions","organizations_url":"https://api.github.com/users/wyeworks/orgs","repos_url":"https://api.github.com/users/wyeworks/repos","events_url":"https://api.github.com/users/wyeworks/events{/privacy}","received_events_url":"https://api.github.com/users/wyeworks/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/wyeworks/pis-wyehome","description":null,"fork":false,"url":"https://api.github.com/repos/wyeworks/pis-wyehome","forks_url":"https://api.github.com/repos/wyeworks/pis-wyehome/forks","keys_url":"https://api.github.com/repos/wyeworks/pis-wyehome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wyeworks/pis-wyehome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wyeworks/pis-wyehome/teams","hooks_url":"https://api.github.com/repos/wyeworks/pis-wyehome/hooks","issue_events_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/events{/number}","events_url":"https://api.github.com/repos/wyeworks/pis-wyehome/events","assignees_url":"https://api.github.com/repos/wyeworks/pis-wyehome/assignees{/user}","branches_url":"https://api.github.com/repos/wyeworks/pis-wyehome/branches{/branch}","tags_url":"https://api.github.com/repos/wyeworks/pis-wyehome/tags","blobs_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/refs{/sha}","trees_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wyeworks/pis-wyehome/statuses/{sha}","languages_url":"https://api.github.com/repos/wyeworks/pis-wyehome/languages","stargazers_url":"https://api.github.com/repos/wyeworks/pis-wyehome/stargazers","contributors_url":"https://api.github.com/repos/wyeworks/pis-wyehome/contributors","subscribers_url":"https://api.github.com/repos/wyeworks/pis-wyehome/subscribers","subscription_url":"https://api.github.com/repos/wyeworks/pis-wyehome/subscription","commits_url":"https://api.github.com/repos/wyeworks/pis-wyehome/commits{/sha}","git_commits_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/commits{/sha}","comments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/comments{/number}","issue_comment_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/comments{/number}","contents_url":"https://api.github.com/repos/wyeworks/pis-wyehome/contents/{+path}","compare_url":"https://api.github.com/repos/wyeworks/pis-wyehome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wyeworks/pis-wyehome/merges","archive_url":"https://api.github.com/repos/wyeworks/pis-wyehome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wyeworks/pis-wyehome/downloads","issues_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues{/number}","pulls_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls{/number}","milestones_url":"https://api.github.com/repos/wyeworks/pis-wyehome/milestones{/number}","notifications_url":"https://api.github.com/repos/wyeworks/pis-wyehome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wyeworks/pis-wyehome/labels{/name}","releases_url":"https://api.github.com/repos/wyeworks/pis-wyehome/releases{/id}","deployments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/deployments","created_at":"2018-08-14T16:18:20Z","updated_at":"2018-10-19T14:00:38Z","pushed_at":"2018-10-28T16:53:47Z","git_url":"git://github.com/wyeworks/pis-wyehome.git","ssh_url":"git@github.com:wyeworks/pis-wyehome.git","clone_url":"https://github.com/wyeworks/pis-wyehome.git","svn_url":"https://github.com/wyeworks/pis-wyehome","homepage":null,"size":523,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":6,"default_branch":"master"}},"base":{"label":"wyeworks:development","ref":"development","sha":"789426864817e42fe5ac63febd2973a0a417e000","user":{"login":"wyeworks","id":135745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNTc0NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135745?v=4","gravatar_id":"","url":"https://api.github.com/users/wyeworks","html_url":"https://github.com/wyeworks","followers_url":"https://api.github.com/users/wyeworks/followers","following_url":"https://api.github.com/users/wyeworks/following{/other_user}","gists_url":"https://api.github.com/users/wyeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/wyeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyeworks/subscriptions","organizations_url":"https://api.github.com/users/wyeworks/orgs","repos_url":"https://api.github.com/users/wyeworks/repos","events_url":"https://api.github.com/users/wyeworks/events{/privacy}","received_events_url":"https://api.github.com/users/wyeworks/received_events","type":"Organization","site_admin":false},"repo":{"id":144744653,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQ3NDQ2NTM=","name":"pis-wyehome","full_name":"wyeworks/pis-wyehome","private":false,"owner":{"login":"wyeworks","id":135745,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNTc0NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/135745?v=4","gravatar_id":"","url":"https://api.github.com/users/wyeworks","html_url":"https://github.com/wyeworks","followers_url":"https://api.github.com/users/wyeworks/followers","following_url":"https://api.github.com/users/wyeworks/following{/other_user}","gists_url":"https://api.github.com/users/wyeworks/gists{/gist_id}","starred_url":"https://api.github.com/users/wyeworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wyeworks/subscriptions","organizations_url":"https://api.github.com/users/wyeworks/orgs","repos_url":"https://api.github.com/users/wyeworks/repos","events_url":"https://api.github.com/users/wyeworks/events{/privacy}","received_events_url":"https://api.github.com/users/wyeworks/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/wyeworks/pis-wyehome","description":null,"fork":false,"url":"https://api.github.com/repos/wyeworks/pis-wyehome","forks_url":"https://api.github.com/repos/wyeworks/pis-wyehome/forks","keys_url":"https://api.github.com/repos/wyeworks/pis-wyehome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wyeworks/pis-wyehome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wyeworks/pis-wyehome/teams","hooks_url":"https://api.github.com/repos/wyeworks/pis-wyehome/hooks","issue_events_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/events{/number}","events_url":"https://api.github.com/repos/wyeworks/pis-wyehome/events","assignees_url":"https://api.github.com/repos/wyeworks/pis-wyehome/assignees{/user}","branches_url":"https://api.github.com/repos/wyeworks/pis-wyehome/branches{/branch}","tags_url":"https://api.github.com/repos/wyeworks/pis-wyehome/tags","blobs_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/refs{/sha}","trees_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wyeworks/pis-wyehome/statuses/{sha}","languages_url":"https://api.github.com/repos/wyeworks/pis-wyehome/languages","stargazers_url":"https://api.github.com/repos/wyeworks/pis-wyehome/stargazers","contributors_url":"https://api.github.com/repos/wyeworks/pis-wyehome/contributors","subscribers_url":"https://api.github.com/repos/wyeworks/pis-wyehome/subscribers","subscription_url":"https://api.github.com/repos/wyeworks/pis-wyehome/subscription","commits_url":"https://api.github.com/repos/wyeworks/pis-wyehome/commits{/sha}","git_commits_url":"https://api.github.com/repos/wyeworks/pis-wyehome/git/commits{/sha}","comments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/comments{/number}","issue_comment_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/comments{/number}","contents_url":"https://api.github.com/repos/wyeworks/pis-wyehome/contents/{+path}","compare_url":"https://api.github.com/repos/wyeworks/pis-wyehome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wyeworks/pis-wyehome/merges","archive_url":"https://api.github.com/repos/wyeworks/pis-wyehome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wyeworks/pis-wyehome/downloads","issues_url":"https://api.github.com/repos/wyeworks/pis-wyehome/issues{/number}","pulls_url":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls{/number}","milestones_url":"https://api.github.com/repos/wyeworks/pis-wyehome/milestones{/number}","notifications_url":"https://api.github.com/repos/wyeworks/pis-wyehome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wyeworks/pis-wyehome/labels{/name}","releases_url":"https://api.github.com/repos/wyeworks/pis-wyehome/releases{/id}","deployments_url":"https://api.github.com/repos/wyeworks/pis-wyehome/deployments","created_at":"2018-08-14T16:18:20Z","updated_at":"2018-10-19T14:00:38Z","pushed_at":"2018-10-28T16:53:47Z","git_url":"git://github.com/wyeworks/pis-wyehome.git","ssh_url":"git@github.com:wyeworks/pis-wyehome.git","clone_url":"https://github.com/wyeworks/pis-wyehome.git","svn_url":"https://github.com/wyeworks/pis-wyehome","homepage":null,"size":523,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":1,"open_issues":4,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36"},"html":{"href":"https://github.com/wyeworks/pis-wyehome/pull/36"},"issue":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/36"},"comments":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/wyeworks/pis-wyehome/statuses/bbc7fd46d0d9e0bf28ec541f0e917630c7f985f7"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"joaquinvillar"}}