3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @package OStatusPlugin
22 * @author James Walker <james@status.net>
25 if (!defined('STATUSNET')) {
29 class GroupsalmonAction extends SalmonAction
33 function prepare($args)
35 parent::prepare($args);
37 $id = $this->trimmed('id');
40 $this->clientError(_('No ID.'));
43 $this->group = User_group::staticGet('id', $id);
45 if (empty($this->group)) {
46 $this->clientError(_('No such group.'));
53 * We've gotten a post event on the Salmon backchannel, probably a reply.
58 switch ($this->act->object->type) {
59 case ActivityObject::ARTICLE:
60 case ActivityObject::BLOGENTRY:
61 case ActivityObject::NOTE:
62 case ActivityObject::STATUS:
63 case ActivityObject::COMMENT:
66 throw new ClientException("Can't handle that kind of post.");
69 // Notice must be to the attention of this group
71 $context = $this->act->context;
73 if (empty($context->attention)) {
74 throw new ClientException("Not to the attention of anyone.");
76 $uri = common_local_url('groupbyid', array('id' => $this->group->id));
77 if (!in_array($context->attention, $uri)) {
78 throw new ClientException("Not to the attention of this group.");
82 $profile = $this->ensureProfile();
83 // @fixme save the post
87 * We've gotten a follow/subscribe notification from a remote user.
88 * Save a subscription relationship for them.
91 function handleFollow()
93 $this->handleJoin(); // ???
96 function handleUnfollow()
101 * A remote user joined our group.
104 function handleJoin()