]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Loose_Ostatusprofile::updateAvatar was identical to Ostatus_profile
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Jan 2015 01:39:08 +0000 (02:39 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 18 Jan 2015 01:39:08 +0000 (02:39 +0100)
plugins/OStatus/scripts/update_ostatus_profiles.php

index a5c8ad5437030743ac258a4b96cfd1db1667730d..dc8232e0d75c8d8375e5621b20fb1911d1595a2a 100644 (file)
@@ -43,71 +43,6 @@ require_once INSTALLDIR . '/scripts/commandline.inc';
  */
 class LooseOstatusProfile extends Ostatus_profile
 {
-    /**
-     * Download and update given avatar image
-     *
-     * @param string $url
-     * @throws Exception in various failure cases
-     */
-    public function updateAvatar($url)
-    {
-        if (!common_valid_http_url($url)) {
-            // TRANS: Server exception. %s is a URL.
-            throw new ServerException(sprintf(_m('Invalid avatar URL %s.'), $url));
-        }
-
-        if ($this->isGroup()) {
-            $self = $this->localGroup();
-        } else {
-            $self = $this->localProfile();
-        }
-        if (!$self) {
-            throw new ServerException(sprintf(
-                // TRANS: Server exception. %s is a URI.
-                _m('Tried to update avatar for unsaved remote profile %s.'),
-                $this->uri));
-        }
-
-        // @fixme this should be better encapsulated
-        // ripped from oauthstore.php (for old OMB client)
-        $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
-        try {
-            if (!copy($url, $temp_filename)) {
-                // TRANS: Server exception. %s is a URL.
-                throw new ServerException(sprintf(_m('Unable to fetch avatar from %s.'), $url));
-            }
-
-            if ($this->isGroup()) {
-                $id = $this->group_id;
-            } else {
-                $id = $this->profile_id;
-            }
-            // @fixme should we be using different ids?
-            $imagefile = new ImageFile($id, $temp_filename);
-            $filename = Avatar::filename($id,
-                                         image_type_to_extension($imagefile->type),
-                                         null,
-                                         common_timestamp());
-            rename($temp_filename, Avatar::path($filename));
-        } catch (Exception $e) {
-            unlink($temp_filename);
-            throw $e;
-        }
-        // @fixme hardcoded chmod is lame, but seems to be necessary to
-        // keep from accidentally saving images from command-line (queues)
-        // that can't be read from web server, which causes hard-to-notice
-        // problems later on:
-        //
-        // http://status.net/open-source/issues/2663
-        chmod(Avatar::path($filename), 0644);
-
-        $self->setOriginal($filename);
-
-        $orig = clone($this);
-        $this->avatar = $url;
-        $this->update($orig);
-    }
-
     /**
      * Look up and if necessary create an Ostatus_profile for the remote entity
      * with the given profile page URL. This should never return null -- you