X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Factions%2Fpeopletagsalmon.php;h=46f4b0bdd848417af8c3db1eb2775bf6e1d1fbe9;hb=a39f51c0441b22951412b2c00d88c34f39cb39c9;hp=c5e972e2333704304481533a6c667520141a0551;hpb=31c1177970124cee31823cab3a11542c23b4126d;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/actions/peopletagsalmon.php b/plugins/OStatus/actions/peopletagsalmon.php index c5e972e233..46f4b0bdd8 100644 --- a/plugins/OStatus/actions/peopletagsalmon.php +++ b/plugins/OStatus/actions/peopletagsalmon.php @@ -21,34 +21,37 @@ * @package OStatusPlugin */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } class PeopletagsalmonAction extends SalmonAction { var $peopletag = null; - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); $id = $this->trimmed('id'); if (!$id) { - $this->clientError(_('No ID.')); + // TRANS: Client error displayed trying to perform an action without providing an ID. + $this->clientError(_m('No ID.')); } - $this->peopletag = Profile_list::staticGet('id', $id); + $this->peopletag = Profile_list::getKV('id', $id); - if (empty($this->peopletag)) { - $this->clientError(_('No such peopletag.')); + if (!$this->peopletag instanceof Profile_list) { + // TRANS: Client error displayed when referring to a non-existing list. + $this->clientError(_m('No such list.')); } - $oprofile = Ostatus_profile::staticGet('peopletag_id', $id); + $this->target = $this->peopletag; + + $remote_list = Ostatus_profile::getKV('peopletag_id', $id); - if (!empty($oprofile)) { - $this->clientError(_m("Can't accept remote posts for a remote peopletag.")); + if ($remote_list instanceof Ostatus_profile) { + // TRANS: Client error displayed when trying to send a message to a remote list. + $this->clientError(_m('Cannot accept remote posts for a remote list.')); } return true; @@ -81,21 +84,15 @@ class PeopletagsalmonAction extends SalmonAction * currently we're doing the main logic in joingroup action * and so have to repeat it here. */ - function handleSubscribe() { - $oprofile = $this->ensureProfile(); - if (!$oprofile) { - $this->clientError(_m("Can't read profile to set up profiletag subscription.")); + if ($this->oprofile->isGroup()) { + // TRANS: Client error displayed when trying to subscribe a group to a list. + $this->clientError(_m('Groups cannot subscribe to lists.')); } - if ($oprofile->isGroup()) { - $this->clientError(_m("Groups can't subscribe to peopletags.")); - } - - common_log(LOG_INFO, "Remote profile {$oprofile->uri} subscribing to local peopletag ".$this->peopletag->getBestName()); - $profile = $oprofile->localProfile(); - if ($this->peopletag->hasSubscriber($profile)) { + common_log(LOG_INFO, sprintf('Remote profile %s subscribing to local peopletag %s', $this->oprofile->getUri(), $this->peopletag->getBestName())); + if ($this->peopletag->hasSubscriber($this->actor)) { // Already a member; we'll take it silently to aid in resolving // inconsistencies on the other side. return true; @@ -105,37 +102,36 @@ class PeopletagsalmonAction extends SalmonAction // his own updates? try { - Profile_tag_subscription::add($this->peopletag, $profile); + Profile_tag_subscription::add($this->peopletag, $this->actor); } catch (Exception $e) { - $this->serverError(sprintf(_m('Could not subscribe remote user %1$s to peopletag %2$s.'), - $oprofile->uri, $this->peopletag->getBestName())); + // TRANS: Server error displayed when subscribing a remote user to a list fails. + // TRANS: %1$s is a profile URI, %2$s is a list name. + $this->serverError(sprintf(_m('Could not subscribe remote user %1$s to list %2$s.'), + $this->oprofile->getUri(), $this->peopletag->getBestName())); } } /** - * A remote user unsubscribed from our peopletag. + * A remote user unsubscribed from our list. + * + * @return void + * @throws Exception through clientError and serverError */ - function handleUnsubscribe() { - $oprofile = $this->ensureProfile(); - if (!$oprofile) { - $this->clientError(_m("Can't read profile to cancel peopletag membership.")); - } - if ($oprofile->isGroup()) { - $this->clientError(_m("Groups can't subscribe to peopletags.")); + if ($this->oprofile->isGroup()) { + // TRANS: Client error displayed when trying to unsubscribe a group from a list. + $this->clientError(_m('Groups cannot subscribe to lists.')); } - common_log(LOG_INFO, "Remote profile {$oprofile->uri} unsubscribing from local peopletag ".$this->peopletag->getBestName()); - $profile = $oprofile->localProfile(); - + common_log(LOG_INFO, sprintf('Remote profile %s unsubscribing from local peopletag %s', $this->oprofile->getUri(), $this->peopletag->getBestName())); try { - Profile_tag_subscription::remove($this->peopletag->tagger, $this->peopletag->tag, $profile->id); - + Profile_tag_subscription::remove($this->peopletag->tagger, $this->peopletag->tag, $this->actor->id); } catch (Exception $e) { - $this->serverError(sprintf(_m('Could not remove remote user %1$s from peopletag %2$s.'), - $oprofile->uri, $this->peopletag->getBestName())); - return; + // TRANS: Client error displayed when trying to unsubscribe a remote user from a list fails. + // TRANS: %1$s is a profile URL, %2$s is a list name. + $this->serverError(sprintf(_m('Could not unsubscribe remote user %1$s from list %2$s.'), + $this->oprofile->getUri(), $this->peopletag->getBestName())); } } }