X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FOStatus%2Factions%2Fusersalmon.php;h=41b688af56506f30b6900442700828e0c5066236;hb=4ab995dd1ef9b1b4d22f27223a7d28b12895ff93;hp=c7ec33eeecd61fd95e30acb5d71ee2923eb1b00a;hpb=36b331d469b6dcd1101783f21265f7be624bc58f;p=quix0rs-gnu-social.git diff --git a/plugins/OStatus/actions/usersalmon.php b/plugins/OStatus/actions/usersalmon.php index c7ec33eeec..41b688af56 100644 --- a/plugins/OStatus/actions/usersalmon.php +++ b/plugins/OStatus/actions/usersalmon.php @@ -67,7 +67,7 @@ class UsersalmonAction extends SalmonAction case ActivityObject::COMMENT: break; default: - throw new ClientException("Can't handle that kind of post."); + throw new ClientException(_m('Cannot handle that kind of post.')); } // Notice must either be a) in reply to a notice by this user @@ -185,6 +185,67 @@ class UsersalmonAction extends SalmonAction $fave->delete(); } + function handleTag() + { + if ($this->activity->target->type == ActivityObject::_LIST) { + if ($this->activity->objects[0]->type != ActivityObject::PERSON) { + throw new ClientException("Not a person object"); + return false; + } + // this is a peopletag + $tagged = User::staticGet('uri', $this->activity->objects[0]->id); + + if (empty($tagged)) { + throw new ClientException("Unidentified profile being tagged"); + } + + if ($tagged->id !== $this->user->id) { + throw new ClientException("This user is not the one being tagged"); + } + + // save the list + $tagger = $this->ensureProfile(); + $list = Ostatus_profile::ensureActivityObjectProfile($this->activity->target); + + $ptag = $list->localPeopletag(); + $result = Profile_tag::setTag($ptag->tagger, $tagged->id, $ptag->tag); + if (!$result) { + throw new ClientException("The tag could not be saved."); + } + } + } + + function handleUntag() + { + if ($this->activity->target->type == ActivityObject::_LIST) { + if ($this->activity->objects[0]->type != ActivityObject::PERSON) { + throw new ClientException("Not a person object"); + return false; + } + // this is a peopletag + $tagged = User::staticGet('uri', $this->activity->objects[0]->id); + + if (empty($tagged)) { + throw new ClientException("Unidentified profile being untagged"); + } + + if ($tagged->id !== $this->user->id) { + throw new ClientException("This user is not the one being untagged"); + } + + // save the list + $tagger = $this->ensureProfile(); + $list = Ostatus_profile::ensureActivityObjectProfile($this->activity->target); + + $ptag = $list->localPeopletag(); + $result = Profile_tag::unTag($ptag->tagger, $tagged->id, $ptag->tag); + + if (!$result) { + throw new ClientException("The tag could not be deleted."); + } + } + } + /** * @param ActivityObject $object * @return Notice @@ -194,7 +255,7 @@ class UsersalmonAction extends SalmonAction { if (!$object) { // TRANS: Client exception. - throw new ClientException(_m('Can\'t favorite/unfavorite without an object.')); + throw new ClientException(_m('Cannot favorite/unfavorite without an object.')); } switch ($object->type) { @@ -206,7 +267,7 @@ class UsersalmonAction extends SalmonAction break; default: // TRANS: Client exception. - throw new ClientException(_m('Can\'t handle that kind of object for liking/faving.')); + throw new ClientException(_m('Cannot handle that kind of object for liking/faving.')); } $notice = Notice::staticGet('uri', $object->id);