]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into nightly
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 5 Nov 2015 15:07:05 +0000 (16:07 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 5 Nov 2015 15:07:05 +0000 (16:07 +0100)
Some merge requests that were aimed at master

1  2 
lib/noticelistitem.php
plugins/OStatus/classes/Ostatus_profile.php
plugins/Share/SharePlugin.php

diff --combined lib/noticelistitem.php
index 3a3890b75f56b8900882ea0db1df021926b9d50f,7701cd8a6c05769c7513aeacee61595645a46eb1..eff3aabe25eb608dcd4b97b5ba32b068556093b0
@@@ -166,7 -166,7 +166,7 @@@ class NoticeListItem extends Widge
      function showNoticeTitle()
      {
          if (Event::handle('StartShowNoticeTitle', array($this))) {
 -            $this->element('a', array('href' => $this->notice->getUrl(),
 +            $this->element('a', array('href' => $this->notice->getUrl(true),
                                        'class' => 'notice-title'),
                             $this->notice->getTitle());
              Event::handle('EndShowNoticeTitle', array($this));
      function showAuthor()
      {
          $attrs = array('href' => $this->profile->profileurl,
-                        'class' => 'h-card p-author',
+                        'class' => 'h-card',
                         'title' => $this->profile->getNickname());
+         if(empty($this->repeat)) { $attrs['class'] .= ' p-author'; }
  
          if (Event::handle('StartShowNoticeItemAuthor', array($this->profile, $this->out, &$attrs))) {
              $this->out->elementStart('a', $attrs);
                                              'href' => Conversation::getUrlFromNotice($this->notice)));
          $this->out->element('time', array('class' => 'dt-published',
                                            'datetime' => common_date_iso8601($this->notice->created),
 -                                          // TRANS: Timestamp title (tooltip text) for NoticeListItem
                                            'title' => common_exact_date($this->notice->created)),
                              common_date_string($this->notice->created));
          $this->out->elementEnd('a');
          }
          try {
              $this->out->element('a',
 -                        array('href' => $this->notice->getUrl(),
 +                        array('href' => $this->notice->getUrl(true),
                                'class' => $class),
                          // TRANS: Addition in notice list item for single-notice view.
                          _('permalink'));
index dbdbe885234eb4a200ac6e14fefd4a9bfeed6994,da7a4b424475087ac251c553fa9f8c443c33d20e..4d1c676844c51c5e9736dcc1b043a7525cbc2873
@@@ -345,7 -345,7 +345,7 @@@ class Ostatus_profile extends Managed_D
          $xml = $entry->getString();
          common_log(LOG_INFO, "Posting to Salmon endpoint $this->salmonuri: $xml");
  
 -        Salmon::post($this->salmonuri, $xml, $actor->getUser());
 +        Salmon::post($this->salmonuri, $xml, $actor);
      }
  
      /**
      public function notifyActivity($entry, Profile $actor)
      {
          if ($this->salmonuri) {
 -            return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor->getUser());
 +            return Salmon::post($this->salmonuri, $this->notifyPrepXml($entry), $actor, $this->localProfile());
          }
          common_debug(__CLASS__.' error: No salmonuri for Ostatus_profile uri: '.$this->uri);
  
          if ($this->salmonuri) {
              $data = array('salmonuri' => $this->salmonuri,
                            'entry' => $this->notifyPrepXml($entry),
 -                          'actor' => $actor->id);
 +                          'actor' => $actor->getID(),
 +                          'target' => $this->localProfile()->getID());
  
              $qm = QueueManager::get();
              return $qm->enqueue($data, 'salmon');
          if (Event::handle('StartHandleFeedEntryWithProfile', array($activity, $this->localProfile(), &$notice)) &&
              Event::handle('StartHandleFeedEntry', array($activity))) {
  
 -            switch ($activity->verb) {
 -            case ActivityVerb::POST:
 -                // @todo process all activity objects
 -                switch ($activity->objects[0]->type) {
 -                case ActivityObject::ARTICLE:
 -                case ActivityObject::BLOGENTRY:
 -                case ActivityObject::NOTE:
 -                case ActivityObject::STATUS:
 -                case ActivityObject::COMMENT:
 -                case null:
 -                    $notice = $this->processPost($activity, $source);
 -                    break;
 -                default:
 -                    // TRANS: Client exception.
 -                    throw new ClientException(_m('Cannot handle that kind of post.'));
 -                }
 -                break;
 -            default:
 -                common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
 -            }
 +            common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
  
              Event::handle('EndHandleFeedEntry', array($activity));
              Event::handle('EndHandleFeedEntryWithProfile', array($activity, $this, $notice));
       * @param Activity $activity
       * @param string $method 'push' or 'salmon'
       * @return mixed saved Notice or false
 -     * @todo FIXME: Break up this function, it's getting nasty long
       */
      public function processPost($activity, $method)
      {
 -        $notice = null;
 -
 -        $profile = ActivityUtils::checkAuthorship($activity, $this->localProfile());
 -
 -        // It's not always an ActivityObject::NOTE, but... let's just say it is.
 -
 -        $note = $activity->objects[0];
 -
 -        // The id URI will be used as a unique identifier for the notice,
 -        // protecting against duplicate saves. It isn't required to be a URL;
 -        // tag: URIs for instance are found in Google Buzz feeds.
 -        $sourceUri = $note->id;
 -        $dupe = Notice::getKV('uri', $sourceUri);
 -        if ($dupe instanceof Notice) {
 -            common_log(LOG_INFO, "OStatus: ignoring duplicate post: $sourceUri");
 -            return $dupe;
 -        }
 -
 -        // We'll also want to save a web link to the original notice, if provided.
 -        $sourceUrl = null;
 -        if ($note->link) {
 -            $sourceUrl = $note->link;
 -        } else if ($activity->link) {
 -            $sourceUrl = $activity->link;
 -        } else if (preg_match('!^https?://!', $note->id)) {
 -            $sourceUrl = $note->id;
 -        }
 -
 -        // Use summary as fallback for content
 +        $actor = ActivityUtils::checkAuthorship($activity, $this->localProfile());
  
 -        if (!empty($note->content)) {
 -            $sourceContent = $note->content;
 -        } else if (!empty($note->summary)) {
 -            $sourceContent = $note->summary;
 -        } else if (!empty($note->title)) {
 -            $sourceContent = $note->title;
 -        } else {
 -            // @todo FIXME: Fetch from $sourceUrl?
 -            // TRANS: Client exception. %s is a source URI.
 -            throw new ClientException(sprintf(_m('No content for notice %s.'),$sourceUri));
 -        }
 -
 -        // Get (safe!) HTML and text versions of the content
 -
 -        $rendered = common_purify($sourceContent);
 -        $content = common_strip_html($rendered);
 -
 -        $shortened = common_shorten_links($content);
 -
 -        // If it's too long, try using the summary, and make the
 -        // HTML an attachment.
 -
 -        $attachment = null;
 -
 -        if (Notice::contentTooLong($shortened)) {
 -            $attachment = $this->saveHTMLFile($note->title, $rendered);
 -            $summary = common_strip_html($note->summary);
 -            if (empty($summary)) {
 -                $summary = $content;
 -            }
 -            $shortSummary = common_shorten_links($summary);
 -            if (Notice::contentTooLong($shortSummary)) {
 -                $url = common_shorten_url($sourceUrl);
 -                $shortSummary = substr($shortSummary,
 -                                       0,
 -                                       Notice::maxContent() - (mb_strlen($url) + 2));
 -                $content = $shortSummary . ' ' . $url;
 -
 -                // We mark up the attachment link specially for the HTML output
 -                // so we can fold-out the full version inline.
 -
 -                // @todo FIXME i18n: This tooltip will be saved with the site's default language
 -                // TRANS: Shown when a notice is longer than supported and/or when attachments are present. At runtime
 -                // TRANS: this will usually be replaced with localised text from StatusNet core messages.
 -                $showMoreText = _m('Show more');
 -                $attachUrl = common_local_url('attachment',
 -                                              array('attachment' => $attachment->id));
 -                $rendered = common_render_text($shortSummary) .
 -                            '<a href="' . htmlspecialchars($attachUrl) .'"'.
 -                            ' class="attachment more"' .
 -                            ' title="'. htmlspecialchars($showMoreText) . '">' .
 -                            '&#8230;' .
 -                            '</a>';
 -            }
 -        }
 -
 -        $options = array('is_local' => Notice::REMOTE,
 -                        'url' => $sourceUrl,
 -                        'uri' => $sourceUri,
 -                        'rendered' => $rendered,
 -                        'replies' => array(),
 -                        'groups' => array(),
 -                        'peopletags' => array(),
 -                        'tags' => array(),
 -                        'urls' => array());
 -
 -        // Check for optional attributes...
 -
 -        if (!empty($activity->time)) {
 -            $options['created'] = common_sql_date($activity->time);
 -        }
 -
 -        if ($activity->context) {
 -            // TODO: context->attention
 -            list($options['groups'], $options['replies'])
 -                = self::filterAttention($profile, $activity->context->attention);
 -
 -            // Maintain direct reply associations
 -            // @todo FIXME: What about conversation ID?
 -            if (!empty($activity->context->replyToID)) {
 -                $orig = Notice::getKV('uri', $activity->context->replyToID);
 -                if ($orig instanceof Notice) {
 -                    $options['reply_to'] = $orig->id;
 -                }
 -            }
 -            if (!empty($activity->context->conversation)) {
 -                // we store the URI here, Notice class can look it up later
 -                $options['conversation'] = $activity->context->conversation;
 -            }
 -
 -            $location = $activity->context->location;
 -            if ($location) {
 -                $options['lat'] = $location->lat;
 -                $options['lon'] = $location->lon;
 -                if ($location->location_id) {
 -                    $options['location_ns'] = $location->location_ns;
 -                    $options['location_id'] = $location->location_id;
 -                }
 -            }
 -        }
 -
 -        if ($this->isPeopletag()) {
 -            $options['peopletags'][] = $this->localPeopletag();
 -        }
 -
 -        // Atom categories <-> hashtags
 -        foreach ($activity->categories as $cat) {
 -            if ($cat->term) {
 -                $term = common_canonical_tag($cat->term);
 -                if ($term) {
 -                    $options['tags'][] = $term;
 -                }
 -            }
 -        }
 -
 -        // Atom enclosures -> attachment URLs
 -        foreach ($activity->enclosures as $href) {
 -            // @todo FIXME: Save these locally or....?
 -            $options['urls'][] = $href;
 -        }
 +        $options = array('is_local' => Notice::REMOTE);
  
          try {
 -            $saved = Notice::saveNew($profile->id,
 -                                     $content,
 -                                     'ostatus',
 -                                     $options);
 -            if ($saved instanceof Notice) {
 -                Ostatus_source::saveNew($saved, $this, $method);
 -                if ($attachment instanceof File) {
 -                    File_to_post::processNew($attachment, $saved);
 -                }
 -            }
 +            $stored = Notice::saveActivity($activity, $actor, $options);
 +            Ostatus_source::saveNew($stored, $this, $method);
          } catch (Exception $e) {
              common_log(LOG_ERR, "OStatus save of remote message $sourceUri failed: " . $e->getMessage());
              throw $e;
          }
 -        common_log(LOG_INFO, "OStatus saved remote message $sourceUri as notice id $saved->id");
 -        return $saved;
 +        return $stored;
      }
  
      /**
              }
          }
  
+         $obj = ActivityUtils::getFeedAuthor($feedEl);
          // @todo FIXME: We should check whether this feed has elements
          // with different <author> or <dc:creator> elements, and... I dunno.
          // Do something about that.
  
-         $obj = ActivityObject::fromRssChannel($feedEl);
+         if(empty($obj)) { $obj = ActivityObject::fromRssChannel($feedEl); }
  
          return self::ensureActivityObjectProfile($obj, $hints);
      }
index cfa93de7fa11c463270fdc83fe198c414b40c145,c31686e4451b5556c2488ce24c7dbe41b4d812a0..1f6ddbaa3fb723dea736748bb2217ff7247f83b1
@@@ -116,7 -116,13 +116,7 @@@ class SharePlugin extends ActivityVerbH
              // TODO: Remember to check Deleted_notice!
              // TODO: If a post is shared that we can't retrieve - what to do?
              $other = Ostatus_profile::ensureActivityObjectProfile($shared->actor);
 -            $sharedNotice = $other->processActivity($shared, 'push');   // FIXME: push/salmon/what?
 -            if (!$sharedNotice instanceof Notice) {
 -                // And if we apparently can't get the shared notice, we'll abort the whole thing.
 -                // TRANS: Client exception thrown when saving an activity share fails.
 -                // TRANS: %s is a share ID.
 -                throw new ClientException(sprintf(_m('Failed to save activity %s.'), $sharedUri));
 -            }
 +            $sharedNotice = Notice::saveActivity($shared, $other->localProfile(), array('source'=>'share'));
          } catch (FeedSubException $e) {
              // Remote feed could not be found or verified, should we
              // transform this into an "RT @user Blah, blah, blah..."?
          $act->objects[] = $target->asActivity($scoped);
      }
  
 -    public function activityObjectFromNotice(Notice $notice)
 +    public function activityObjectFromNotice(Notice $stored)
      {
          // Repeat is a little bit special. As it's an activity, our
          // ActivityObject is instead turned into an Activity
          $object          = new Activity();
 +        $object->actor   = $stored->getProfile()->asActivityObject();
          $object->verb    = ActivityVerb::SHARE;
 -        $object->content = $notice->rendered;
 -        $this->extendActivity($stored, $act);
 +        $object->content = $stored->rendered;
 +        $this->extendActivity($stored, $object);
  
          return $object;
      }
                             'class' => 'h-card p-author',
                             'title' => $repeater->getFancyName());
  
-             $nli->out->elementStart('span', 'repeat h-entry');
+             $nli->out->elementStart('span', 'repeat');
  
              // TRANS: Addition in notice list item if notice was repeated. Followed by a span with a nickname.
              $nli->out->raw(_('Repeated by').' ');
      public function onEndShowNoticeOptionItems($nli)
      {
          // FIXME: Use bitmasks (but be aware that PUBLIC_SCOPE is 0!)
 -        if ($nli->notice->scope == Notice::PUBLIC_SCOPE ||
 -                $nli->notice->scope == Notice::SITE_SCOPE) {
 +        // Also: AHHH, $scope and $scoped are scarily similar looking.
 +        $scope = $nli->notice->getScope();
 +        if ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE) {
              $scoped = Profile::current();
              if ($scoped instanceof Profile &&
                      $scoped->getID() !== $nli->notice->getProfile()->getID()) {
          }
      }
  
 -    public function showNoticeListItem(NoticeListItem $nli)
 +    protected function showNoticeListItem(NoticeListItem $nli)
      {
          // pass
      }