]> git.mxchange.org Git - friendica.git/blob - src/Model/APContact/Endpoint.php
Use central function to fetch the global directory
[friendica.git] / src / Model / APContact / Endpoint.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Model\APContact;
23
24 use Friendica\Database\DBA;
25
26 class Endpoint
27 {
28         // Mobilizon Endpoints
29         const DISCUSSIONS = 10;
30         const EVENTS      = 11;
31         const MEMBERS     = 12;
32         const POSTS       = 13;
33         const RESOURCES   = 14;
34         const TODOS       = 15;
35
36         // Peertube Endpoints
37         const PLAYLISTS = 20;
38
39         // Mastodon Endpoints
40         const DEVICES = 30;
41
42         const ENDPOINT_NAMES = [
43                 self::PLAYLISTS   => 'pt:playlists',
44                 self::DISCUSSIONS => 'mobilizon:discussions',
45                 self::EVENTS      => 'mobilizon:events',
46                 self::MEMBERS     => 'mobilizon:members',
47                 self::POSTS       => 'mobilizon:posts',
48                 self::RESOURCES   => 'mobilizon:resources',
49                 self::TODOS       => 'mobilizon:todos',
50                 self::DEVICES     => 'toot:devices',
51         ];
52
53         /**
54          * Update an apcontact endpoint
55          *
56          * @param int    $owner_uri_id
57          * @param int    $type
58          * @param string $url
59          * @return bool
60          */
61         public static function update(int $owner_uri_id, int $type, string $url)
62         {
63                 if (empty($url) || empty($owner_uri_id)) {
64                         return false;
65                 }
66
67                 $fields = ['owner-uri-id' => $owner_uri_id, 'type' => $type];
68
69                 return DBA::update('endpoint', $fields, ['url' => $url], true);
70         }
71 }