]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OStatus/actions/groupsalmon.php
Merge branch 'master' into testing
[quix0rs-gnu-social.git] / plugins / OStatus / actions / groupsalmon.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 /**
21  * @package OStatusPlugin
22  * @author James Walker <james@status.net>
23  */
24
25 if (!defined('STATUSNET')) {
26     exit(1);
27 }
28
29 class GroupsalmonAction extends SalmonAction
30 {
31     var $group = null;
32
33     function prepare($args)
34     {
35         parent::prepare($args);
36
37         $id = $this->trimmed('id');
38
39         if (!$id) {
40             $this->clientError(_('No ID.'));
41         }
42
43         $this->group = User_group::staticGet('id', $id);
44
45         if (empty($this->group)) {
46             $this->clientError(_('No such group.'));
47         }
48
49         return true;
50     }
51
52     /**
53      * We've gotten a post event on the Salmon backchannel, probably a reply.
54      */
55
56     function handlePost()
57     {
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:
64             break;
65         default:
66             throw new ClientException("Can't handle that kind of post.");
67         }
68
69         // Notice must be to the attention of this group
70
71         $context = $this->act->context;
72
73         if (empty($context->attention)) {
74             throw new ClientException("Not to the attention of anyone.");
75         } else {
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.");
79             }
80         }
81
82         $profile = $this->ensureProfile();
83         // @fixme save the post
84     }
85
86     /**
87      * We've gotten a follow/subscribe notification from a remote user.
88      * Save a subscription relationship for them.
89      */
90
91     function handleFollow()
92     {
93         $this->handleJoin(); // ???
94     }
95
96     function handleUnfollow()
97     {
98     }
99
100     /**
101      * A remote user joined our group.
102      */
103
104     function handleJoin()
105     {
106     }
107
108 }