3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
22 namespace Friendica\Protocol\Diaspora\Factory;
24 use Friendica\Capabilities\ICanCreateFromTableRow;
25 use Friendica\Database\DBA;
26 use GuzzleHttp\Psr7\Uri;
28 class DiasporaContact extends \Friendica\BaseFactory implements ICanCreateFromTableRow
30 public function createFromTableRow(array $row): \Friendica\Protocol\Diaspora\Entity\DiasporaContact
32 return new \Friendica\Protocol\Diaspora\Entity\DiasporaContact(
34 new \DateTime($row['created'], new \DateTimeZone('UTC')),
37 $row['alias'] ? new Uri($row['alias']) : null,
42 $row['photo'] ? new Uri($row['photo']) : null,
43 $row['photo-medium'] ? new Uri($row['photo-medium']) : null,
44 $row['photo-small'] ? new Uri($row['photo-small']) : null,
45 $row['batch'] ? new Uri($row['batch']) : null,
46 $row['notify'] ? new Uri($row['notify']) : null,
47 $row['poll'] ? new Uri($row['poll']) : null,
51 $row['baseurl'] ? new Uri($row['baseurl']) : null,
53 $row['updated'] !== DBA::NULL_DATETIME ? new \DateTime($row['updated'], new \DateTimeZone('UTC')) : null,
54 $row['interacting_count'],
55 $row['interacted_count'],
62 * @param array $data Data returned by \Friendica\Network\Probe::uri()
63 * @param int $uriId The URI ID of the Diaspora contact URL + GUID
64 * @param \DateTime $created
65 * @param int $interacting_count
66 * @param int $interacted_count
67 * @param int $post_count
68 * @return \Friendica\Protocol\Diaspora\Entity\DiasporaContact
70 public function createfromProbeData(array $data, int $uriId, \DateTime $created, int $interacting_count = 0, int $interacted_count = 0, int $post_count = 0): \Friendica\Protocol\Diaspora\Entity\DiasporaContact
72 $alias = $data['alias'] != $data['url'] ? $data['alias'] : null;
74 return new \Friendica\Protocol\Diaspora\Entity\DiasporaContact(
75 new Uri($data['url']),
79 $alias ? new Uri($alias) : null,
82 $data['given-name'] ?? '',
83 $data['family-name'] ?? '',
84 $data['photo'] ? new Uri($data['photo']) : null,
85 !empty($data['photo_medium']) ? new Uri($data['photo_medium']) : null,
86 !empty($data['photo_small']) ? new Uri($data['photo_small']) : null,
87 $data['batch'] ? new Uri($data['batch']) : null,
88 $data['notify'] ? new Uri($data['notify']) : null,
89 $data['poll'] ? new Uri($data['poll']) : null,
93 $data['baseurl'] ? new Uri($data['baseurl']) : null,