X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FShare%2FSharePlugin.php;h=84174a0440895d597e657d99f014b04bf66e573b;hb=20592f184d759c3e6f68165ea7b94a330853eaef;hp=69761a5f3d45df4b3e8bf0ec4e6fe752f3e2479c;hpb=a647a4f6b3531d3f8e6003d32403b5f30599e952;p=quix0rs-gnu-social.git diff --git a/plugins/Share/SharePlugin.php b/plugins/Share/SharePlugin.php index 69761a5f3d..84174a0440 100644 --- a/plugins/Share/SharePlugin.php +++ b/plugins/Share/SharePlugin.php @@ -116,13 +116,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin // 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..."? @@ -161,7 +155,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null) { // TODO: How to handle repeats of deleted notices? - $target = Notice::getById($stored->repeat_of); + $target = Notice::getByID($stored->repeat_of); // TRANS: A repeat activity's title. %1$s is repeater's nickname // and %2$s is the repeated user's nickname. $act->title = sprintf(_('%1$s repeated a notice by %2$s'), @@ -170,14 +164,15 @@ class SharePlugin extends ActivityVerbHandlerPlugin $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; } @@ -204,7 +199,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin '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').' '); @@ -236,8 +231,9 @@ class SharePlugin extends ActivityVerbHandlerPlugin 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()) { @@ -256,7 +252,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin } } - public function showNoticeListItem(NoticeListItem $nli) + protected function showNoticeListItem(NoticeListItem $nli) { // pass } @@ -278,10 +274,16 @@ class SharePlugin extends ActivityVerbHandlerPlugin */ public function onNoticeSimpleStatusArray($notice, array &$status, Profile $scoped=null, array $args=array()) { - if ($scoped instanceof Profile) { - $status['repeated'] = $scoped->hasRepeated($notice); - } else { - $status['repeated'] = false; + $status['repeated'] = $scoped instanceof Profile + ? $scoped->hasRepeated($notice) + : false; + + if ($status['repeated'] === true) { + // Qvitter API wants the "repeated_id" value set too. + $repeated = Notice::pkeyGet(array('profile_id' => $scoped->getID(), + 'repeat_of' => $notice->getID(), + 'verb' => ActivityVerb::SHARE)); + $status['repeated_id'] = $repeated->getID(); } }