From 82a6c7803318fc43ccb0bbd32ba3d18f7cc9f76e Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 21 Oct 2021 22:57:13 +0200 Subject: [PATCH 01/15] Move FSuggest to depository --- src/BaseRepository.php | 251 ------------------ src/Collection/FSuggests.php | 29 -- src/Collection/Notifications.php | 36 --- .../Depository/FriendSuggest.php | 72 +++++ .../FriendSuggest/Entity/FriendSuggest.php | 83 ++++++ .../FriendSuggestPersistenceException.php | 11 + .../FriendSuggest/Factory/FriendSuggest.php | 49 ++++ src/DI.php | 12 +- src/Model/FSuggest.php | 41 --- src/Module/FriendSuggest.php | 19 +- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Repository/FSuggest.php | 93 ------- src/Worker/Notifier.php | 2 +- 13 files changed, 236 insertions(+), 464 deletions(-) delete mode 100644 src/BaseRepository.php delete mode 100644 src/Collection/FSuggests.php delete mode 100644 src/Collection/Notifications.php create mode 100644 src/Contact/FriendSuggest/Depository/FriendSuggest.php create mode 100644 src/Contact/FriendSuggest/Entity/FriendSuggest.php create mode 100644 src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php create mode 100644 src/Contact/FriendSuggest/Factory/FriendSuggest.php delete mode 100644 src/Model/FSuggest.php delete mode 100644 src/Repository/FSuggest.php diff --git a/src/BaseRepository.php b/src/BaseRepository.php deleted file mode 100644 index 1294be88ca..0000000000 --- a/src/BaseRepository.php +++ /dev/null @@ -1,251 +0,0 @@ -. - * - */ - -namespace Friendica; - -use Friendica\Database\Database; -use Friendica\Database\DBA; -use Friendica\Network\HTTPException; -use Psr\Log\LoggerInterface; - -/** - * Repositories are Factories linked to one or more database tables. - * - * @see BaseModel - * @see BaseCollection - */ -abstract class BaseRepository extends BaseFactory -{ - const LIMIT = 30; - - /** @var Database */ - protected $dba; - - /** @var string */ - protected static $table_name; - - /** @var BaseModel */ - protected static $model_class; - - /** @var BaseCollection */ - protected static $collection_class; - - public function __construct(Database $dba, LoggerInterface $logger) - { - parent::__construct($logger); - - $this->dba = $dba; - $this->logger = $logger; - } - - /** - * Fetches a single model record. The condition array is expected to contain a unique index (primary or otherwise). - * - * Chainable. - * - * @param array $condition - * @return BaseModel - * @throws HTTPException\NotFoundException - */ - public function selectFirst(array $condition) - { - $data = $this->dba->selectFirst(static::$table_name, [], $condition); - - if (!$data) { - throw new HTTPException\NotFoundException(static::class . ' record not found.'); - } - - return $this->create($data); - } - - /** - * Populates a Collection according to the condition. - * - * Chainable. - * - * @param array $condition - * @param array $params - * @return BaseCollection - * @throws \Exception - */ - public function select(array $condition = [], array $params = []) - { - $models = $this->selectModels($condition, $params); - - return new static::$collection_class($models); - } - - /** - * Populates the collection according to the condition. Retrieves a limited subset of models depending on the boundaries - * and the limit. The total count of rows matching the condition is stored in the collection. - * - * max_id and min_id are susceptible to the query order: - * - min_id alone only reliably works with ASC order - * - max_id alone only reliably works with DESC order - * If the wrong order is detected in either case, we inverse the query order and we reverse the model array after the query - * - * Chainable. - * - * @param array $condition - * @param array $params - * @param int? $min_id Retrieve models with an id no fewer than this, as close to it as possible - * @param int? $max_id Retrieve models with an id no greater than this, as close to it as possible - * @param int $limit - * @return BaseCollection - * @throws \Exception - */ - public function selectByBoundaries(array $condition = [], array $params = [], int $min_id = null, int $max_id = null, int $limit = self::LIMIT) - { - $totalCount = DBA::count(static::$table_name, $condition); - - $boundCondition = $condition; - - $reverseModels = false; - - if (isset($min_id)) { - $boundCondition = DBA::mergeConditions($boundCondition, ['`id` > ?', $min_id]); - if (!isset($max_id) && isset($params['order']['id']) && ($params['order']['id'] === true || $params['order']['id'] === 'DESC')) { - $reverseModels = true; - $params['order']['id'] = 'ASC'; - } - } - - if (isset($max_id)) { - $boundCondition = DBA::mergeConditions($boundCondition, ['`id` < ?', $max_id]); - if (!isset($min_id) && (!isset($params['order']['id']) || $params['order']['id'] === false || $params['order']['id'] === 'ASC')) { - $reverseModels = true; - $params['order']['id'] = 'DESC'; - } - } - - $params['limit'] = $limit; - - $models = $this->selectModels($boundCondition, $params); - - if ($reverseModels) { - $models = array_reverse($models); - } - - return new static::$collection_class($models, $totalCount); - } - - /** - * This method updates the database row from the model. - * - * @param BaseModel $model - * @return bool - * @throws \Exception - */ - public function update(BaseModel $model) - { - if ($this->dba->update(static::$table_name, $model->toArray(), ['id' => $model->id], $model->getOriginalData())) { - $model->resetOriginalData(); - return true; - } - - return false; - } - - /** - * This method creates a new database row and returns a model if it was successful. - * - * @param array $fields - * @return BaseModel|bool - * @throws \Exception - */ - public function insert(array $fields) - { - $return = $this->dba->insert(static::$table_name, $fields); - - if (!$return) { - throw new HTTPException\InternalServerErrorException('Unable to insert new row in table "' . static::$table_name . '"'); - } - - $fields['id'] = $this->dba->lastInsertId(); - $return = $this->create($fields); - - return $return; - } - - /** - * Deletes the model record from the database. - * - * @param BaseModel $model - * @return bool - * @throws \Exception - */ - public function delete(BaseModel &$model) - { - if ($success = $this->dba->delete(static::$table_name, ['id' => $model->id])) { - $model = null; - } - - return $success; - } - - /** - * Base instantiation method, can be overriden to add specific dependencies - * - * @param array $data - * @return BaseModel - */ - protected function create(array $data) - { - return new static::$model_class($this->dba, $this->logger, $data); - } - - /** - * @param array $condition Query condition - * @param array $params Additional query parameters - * @return BaseModel[] - * @throws \Exception - */ - protected function selectModels(array $condition, array $params = []) - { - $result = $this->dba->select(static::$table_name, [], $condition, $params); - - /** @var BaseModel $prototype */ - $prototype = null; - - $models = []; - - while ($record = $this->dba->fetch($result)) { - if ($prototype === null) { - $prototype = $this->create($record); - $models[] = $prototype; - } else { - $models[] = static::$model_class::createFromPrototype($prototype, $record); - } - } - - $this->dba->close($result); - - return $models; - } - - /** - * @param BaseCollection $collection - */ - public function saveCollection(BaseCollection $collection) - { - $collection->map([$this, 'update']); - } -} diff --git a/src/Collection/FSuggests.php b/src/Collection/FSuggests.php deleted file mode 100644 index 78c964636f..0000000000 --- a/src/Collection/FSuggests.php +++ /dev/null @@ -1,29 +0,0 @@ -. - * - */ - -namespace Friendica\Collection; - -use Friendica\BaseCollection; - -class FSuggests extends BaseCollection -{ - -} diff --git a/src/Collection/Notifications.php b/src/Collection/Notifications.php deleted file mode 100644 index adf0f48581..0000000000 --- a/src/Collection/Notifications.php +++ /dev/null @@ -1,36 +0,0 @@ -. - * - */ - -namespace Friendica\Collection; - -use Friendica\BaseCollection; -use Friendica\Model; - -class Notifications extends BaseCollection -{ - /** - * @return Model\Notification - */ - public function current() - { - return parent::current(); - } -} diff --git a/src/Contact/FriendSuggest/Depository/FriendSuggest.php b/src/Contact/FriendSuggest/Depository/FriendSuggest.php new file mode 100644 index 0000000000..9f3b39acca --- /dev/null +++ b/src/Contact/FriendSuggest/Depository/FriendSuggest.php @@ -0,0 +1,72 @@ + $fsuggest->uid, + 'cid' => $fsuggest->cid, + 'name' => $fsuggest->name, + 'url' => $fsuggest->url, + 'request' => $fsuggest->request, + 'photo' => $fsuggest->photo, + 'note' => $fsuggest->note, + ]; + } + + /** + * @param array $condition + * @param array $params + * + * @return Entity\FriendSuggest + * + * @throws NotFoundException The underlying exception if there's no FriendSuggest with the given conditions + */ + private function selectOne(array $condition, array $params = []): Entity\FriendSuggest + { + return parent::_selectOne($condition, $params); + } + + public function selectOneById(int $id): Entity\FriendSuggest + { + return $this->selectOne(['id' => $id]); + } + + public function save(Entity\FriendSuggest $fsuggest): Entity\FriendSuggest + { + try { + $fields = $this->convertToTableRow($fsuggest); + + if ($fsuggest->id) { + $this->db->update(self::$table_name, $fields, ['id' => $fsuggest->id]); + return $this->factory->createFromTableRow($fields); + } else { + $this->db->insert(self::$table_name, $fields); + return $this->selectOneById($this->db->lastInsertId()); + } + } catch (\Exception $exception) { + throw new FriendSuggestPersistenceException(sprintf('Cannot insert/update the FriendSuggestion %d for user %d', $fsuggest->id, $fsuggest->uid), $exception); + } + } +} diff --git a/src/Contact/FriendSuggest/Entity/FriendSuggest.php b/src/Contact/FriendSuggest/Entity/FriendSuggest.php new file mode 100644 index 0000000000..4fc8a2df96 --- /dev/null +++ b/src/Contact/FriendSuggest/Entity/FriendSuggest.php @@ -0,0 +1,83 @@ +. + * + */ + +namespace Friendica\Contact\FriendSuggest\Entity; + +use Friendica\BaseEntity; + +/** + * Model for interacting with a friend suggestion + * + * @property-read int $uid + * @property-read int $cid + * @property-read string $name + * @property-read string $url + * @property-read string $request + * @property-read string $photo + * @property-read string $note + * @property-read \DateTime created + * @property-read int|null $id + */ +class FriendSuggest extends BaseEntity +{ + /** @var int */ + protected $uid; + /** @var int */ + protected $cid; + /** @var string */ + protected $name; + /** @var string */ + protected $url; + /** @var string */ + protected $request; + /** @var string */ + protected $photo; + /** @var string */ + protected $note; + /** @var \DateTime */ + protected $created; + /** @var int|null */ + protected $id; + + /** + * @param int $uid + * @param int $cid + * @param string $name + * @param string $url + * @param string $request + * @param string $photo + * @param string $note + * @param \DateTime $created + * @param int|null $id + */ + public function __construct(int $uid, int $cid, string $name, string $url, string $request, string $photo, string $note, \DateTime $created, ?int $id = null) + { + $this->uid = $uid; + $this->cid = $cid; + $this->name = $name; + $this->url = $url; + $this->request = $request; + $this->photo = $photo; + $this->note = $note; + $this->created = $created; + $this->id = $id; + } +} diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php new file mode 100644 index 0000000000..4b901272df --- /dev/null +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php @@ -0,0 +1,11 @@ +createFromTableRow([ + 'uid' => $uid, + 'cid' => $cid, + 'name' => $name, + 'url' => $url, + 'request' => $request, + 'photo' => $photo, + 'note' => $note, + ]); + } +} diff --git a/src/DI.php b/src/DI.php index 28df28a325..eea219bd22 100644 --- a/src/DI.php +++ b/src/DI.php @@ -427,11 +427,19 @@ abstract class DI // /** - * @return Repository\FSuggest; + * @return Contact\FriendSuggest\Depository\FriendSuggest; */ public static function fsuggest() { - return self::$dice->create(Repository\FSuggest::class); + return self::$dice->create(Contact\FriendSuggest\Depository\FriendSuggest::class); + } + + /** + * @return Contact\FriendSuggest\Factory\FriendSuggest; + */ + public static function fsuggestFactory() + { + return self::$dice->create(Contact\FriendSuggest\Factory\FriendSuggest::class); } /** diff --git a/src/Model/FSuggest.php b/src/Model/FSuggest.php deleted file mode 100644 index d8dbd3911f..0000000000 --- a/src/Model/FSuggest.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - */ - -namespace Friendica\Model; - -use Friendica\BaseModel; - -/** - * Model for interacting with a friend suggestion - * - * @property int uid - * @property int cid - * @property string name - * @property string url - * @property string request - * @property string photo - * @property string note - * @property string created - */ -class FSuggest extends BaseModel -{ - -} diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index a53d47c481..e8e0fc2f09 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -68,16 +68,15 @@ class FriendSuggest extends BaseModule $note = Strings::escapeHtml(trim($_POST['note'] ?? '')); - $suggest = DI::fsuggest()->insert([ - 'uid' => local_user(), - 'cid' => $cid, - 'name' => $contact['name'], - 'url' => $contact['url'], - 'request' => $contact['request'], - 'photo' => $contact['avatar'], - 'note' => $note, - 'created' => DateTimeFormat::utcNow() - ]); + $suggest = DI::fsuggest()->save(DI::fsuggestFactory()->createNew( + local_user(), + $cid, + $contact['name'], + $contact['url'], + $contact['request'], + $contact['avatar'], + $note + )); Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, $suggest->id); diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index ab7b63866d..5e6f772472 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1782,7 +1782,7 @@ class Transmitter { $owner = User::getOwnerDataById($uid); - $suggestion = DI::fsuggest()->getById($suggestion_id); + $suggestion = DI::fsuggest()->selectOneById($suggestion_id); $data = ['@context' => ActivityPub::CONTEXT, 'id' => DI::baseUrl() . '/activity/' . System::createGUID(), diff --git a/src/Repository/FSuggest.php b/src/Repository/FSuggest.php deleted file mode 100644 index 1bbc6c739f..0000000000 --- a/src/Repository/FSuggest.php +++ /dev/null @@ -1,93 +0,0 @@ -. - * - */ - -namespace Friendica\Repository; - -use Friendica\BaseRepository; -use Friendica\Collection; -use Friendica\Model; - -class FSuggest extends BaseRepository -{ - protected static $table_name = 'fsuggest'; - - protected static $model_class = Model\FSuggest::class; - - protected static $collection_class = Collection\FSuggests::class; - - /** - * @param array $data - * @return Model\FSuggest - */ - protected function create(array $data) - { - return new Model\FSuggest($this->dba, $this->logger, $data); - } - - /** - * Returns the Friend Suggest based on it's ID - * - * @param int $id The id of the fsuggest - * - * @return Model\FSuggest - * - * @throws \Friendica\Network\HTTPException\NotFoundException - */ - public function getById(int $id) - { - return $this->selectFirst(['id' => $id]); - } - - /** - * @param array $condition - * @return Model\FSuggest - * @throws \Friendica\Network\HTTPException\NotFoundException - */ - public function selectFirst(array $condition) - { - return parent::selectFirst($condition); - } - - /** - * @param array $condition - * @param array $params - * @return Collection\FSuggests - * @throws \Exception - */ - public function select(array $condition = [], array $params = []) - { - return parent::select($condition, $params); - } - - /** - * @param array $condition - * @param array $params - * @param int|null $min_id - * @param int|null $max_id - * @param int $limit - * @return Collection\FSuggests - * @throws \Exception - */ - public function selectByBoundaries(array $condition = [], array $params = [], int $min_id = null, int $max_id = null, int $limit = self::LIMIT) - { - return parent::selectByBoundaries($condition, $params, $min_id, $max_id, $limit); - } -} diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index d69419eb18..16baea281d 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -90,7 +90,7 @@ class Notifier 'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid); } } elseif ($cmd == Delivery::SUGGESTION) { - $suggest = DI::fsuggest()->getById($target_id); + $suggest = DI::fsuggest()->selectOneById($target_id); $uid = $suggest->uid; $recipients[] = $suggest->cid; } elseif ($cmd == Delivery::REMOVAL) { From b407fbedc1ccf9b7fe5226898ee232482c0fe438 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 21 Oct 2021 23:13:19 +0200 Subject: [PATCH 02/15] Replace all 'fsuggest' usages with the new paradigm --- .../Collection/FriendSuggests.php | 9 +++ .../Depository/FriendSuggest.php | 75 ++++++++++++++++++- .../FriendSuggestNotFoundException.php | 11 +++ .../FriendSuggest/Factory/FriendSuggest.php | 8 +- src/Worker/Contact/RemoveContent.php | 2 +- src/Worker/Delivery.php | 12 ++- 6 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 src/Contact/FriendSuggest/Collection/FriendSuggests.php create mode 100644 src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php diff --git a/src/Contact/FriendSuggest/Collection/FriendSuggests.php b/src/Contact/FriendSuggest/Collection/FriendSuggests.php new file mode 100644 index 0000000000..ad382b39c5 --- /dev/null +++ b/src/Contact/FriendSuggest/Collection/FriendSuggests.php @@ -0,0 +1,9 @@ +selectOne(['id' => $id]); + return parent::_select($condition, $params); } + /** + * @param int $id + * + * @return Entity\FriendSuggest + * + * @throws FriendSuggestNotFoundException in case there's no suggestion for this id + */ + public function selectOneById(int $id): Entity\FriendSuggest + { + try { + return $this->selectOne(['id' => $id]); + } catch (NotFoundException $e) { + throw new FriendSuggestNotFoundException(sprintf('No FriendSuggest found for id %d', $id)); + } + } + + /** + * @param int $cid + * + * @return Collection\FriendSuggests + * + * @throws FriendSuggestPersistenceException In case the underlying storage cannot select the suggestion + */ + public function selectForContact(int $cid): Collection\FriendSuggests + { + try { + return $this->select(['cid' => $cid]); + } catch (\Exception $e) { + throw new FriendSuggestPersistenceException(sprintf('Cannot select FriendSuggestion for contact %d', $cid)); + } + } + + /** + * @param Entity\FriendSuggest $fsuggest + * + * @return Entity\FriendSuggest + * + * @throws FriendSuggestNotFoundException in case the underlying storage cannot save the suggestion + */ public function save(Entity\FriendSuggest $fsuggest): Entity\FriendSuggest { try { @@ -66,7 +116,24 @@ class FriendSuggest extends BaseDepository return $this->selectOneById($this->db->lastInsertId()); } } catch (\Exception $exception) { - throw new FriendSuggestPersistenceException(sprintf('Cannot insert/update the FriendSuggestion %d for user %d', $fsuggest->id, $fsuggest->uid), $exception); + throw new FriendSuggestNotFoundException(sprintf('Cannot insert/update the FriendSuggestion %d for user %d', $fsuggest->id, $fsuggest->uid), $exception); + } + } + + /** + * @param Collection\FriendSuggest $fsuggests + * + * @return bool + * + * @throws FriendSuggestNotFoundException in case the underlying storage cannot delete the suggestion + */ + public function delete(Collection\FriendSuggests $fsuggests): bool + { + try { + $ids = $fsuggests->column('id'); + return $this->db->delete(self::$table_name, ['id' => $ids]); + } catch (\Exception $exception) { + throw new FriendSuggestNotFoundException('Cannot delete the FriendSuggestions', $exception); } } } diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php new file mode 100644 index 0000000000..e5ba7e19d1 --- /dev/null +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php @@ -0,0 +1,11 @@ +createFromTableRow([ 'uid' => $uid, 'cid' => $cid, @@ -46,4 +45,9 @@ class FriendSuggest extends BaseFactory implements ICanCreateFromTableRow 'note' => $note, ]); } + + public function createEmpty(int $id): Entity\FriendSuggest + { + return $this->createFromTableRow(['id' => $id]); + } } diff --git a/src/Worker/Contact/RemoveContent.php b/src/Worker/Contact/RemoveContent.php index f0e6e631d7..cdb3214112 100644 --- a/src/Worker/Contact/RemoveContent.php +++ b/src/Worker/Contact/RemoveContent.php @@ -80,7 +80,7 @@ class RemoveContent DBA::delete('contact-relation', ['relation-cid' => $id]); DBA::delete('contact-relation', ['cid' => $id]); DBA::delete('event', ['cid' => $id]); - DBA::delete('fsuggest', ['cid' => $id]); + DI::fsuggest()->delete(DI::fsuggest()->selectForContact($id)); DBA::delete('post-tag', ['cid' => $id]); DBA::delete('user-contact', ['cid' => $id]); diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 8961b3f13d..44fded2c53 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -21,6 +21,8 @@ namespace Friendica\Worker; +use Friendica\Contact\FriendSuggest\Collection\FriendSuggests; +use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Database\DBA; @@ -64,11 +66,13 @@ class Delivery } $uid = $target_item['uid']; } elseif ($cmd == self::SUGGESTION) { - $target_item = DBA::selectFirst('fsuggest', [], ['id' => $post_uriid]); - if (!DBA::isResult($target_item)) { + try { + $target_item = DI::fsuggest()->selectOneById($post_uriid); + } catch (FriendSuggestNotFoundException $e) { + DI::logger()->info('Cannot find FriendSuggestion', ['id' => $post_uriid]); return; } - $uid = $target_item['uid']; + $uid = $target_item->uid; } elseif ($cmd == self::RELOCATION) { $uid = $post_uriid; $target_item = []; @@ -284,7 +288,7 @@ class Delivery } elseif ($cmd == self::SUGGESTION) { $item = $target_item; $atom = DFRN::fsuggest($item, $owner); - DBA::delete('fsuggest', ['id' => $item['id']]); + DI::fsuggest()->delete(new FriendSuggests([DI::fsuggest()->selectOneById($item['id'])])); } elseif ($cmd == self::RELOCATION) { $atom = DFRN::relocate($owner, $owner['uid']); } elseif ($followup) { From 5d92713a8eb8467385387fb2d2a3ac20f6eda06c Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 21 Oct 2021 23:18:08 +0200 Subject: [PATCH 03/15] Rename Depository to Repository --- ...{BaseDepository.php => BaseRepository.php} | 4 +-- .../FriendSuggest.php | 7 +++-- .../Introduction.php | 6 ++--- src/Core/UserImport.php | 2 +- src/DI.php | 24 ++++++++--------- src/Factory/Api/Mastodon/Account.php | 14 +++++----- src/Module/Api/Friendica/Profile/Show.php | 2 +- .../Factory/FormattedNotification.php | 6 ++--- .../Notification.php | 6 ++--- .../{Depository => Repository}/Notify.php | 6 ++--- .../ProfileField.php | 22 ++++++++-------- .../PermissionSet/Entity/PermissionSet.php | 4 +-- .../PermissionSet.php | 6 ++--- .../ProfileField/Entity/ProfileFieldTest.php | 10 +++---- .../ProfileFieldTest.php | 26 +++++++++---------- .../PermissionSetTest.php | 22 ++++++++-------- update.php | 2 +- 17 files changed, 84 insertions(+), 85 deletions(-) rename src/{BaseDepository.php => BaseRepository.php} (97%) rename src/Contact/FriendSuggest/{Depository => Repository}/FriendSuggest.php (96%) rename src/Contact/Introduction/{Depository => Repository}/Introduction.php (98%) rename src/Navigation/Notifications/{Depository => Repository}/Notification.php (96%) rename src/Navigation/Notifications/{Depository => Repository}/Notify.php (99%) rename src/Profile/ProfileField/{Depository => Repository}/ProfileField.php (92%) rename src/Security/PermissionSet/{Depository => Repository}/PermissionSet.php (98%) rename tests/src/Profile/ProfileField/{Depository => Repository}/ProfileFieldTest.php (84%) rename tests/src/Security/PermissionSet/{Depository => Repository}/PermissionSetTest.php (67%) diff --git a/src/BaseDepository.php b/src/BaseRepository.php similarity index 97% rename from src/BaseDepository.php rename to src/BaseRepository.php index 75118dd8cb..dccfe7fdc7 100644 --- a/src/BaseDepository.php +++ b/src/BaseRepository.php @@ -10,7 +10,7 @@ use Friendica\Network\HTTPException\NotFoundException; use Psr\Log\LoggerInterface; /** - * Depositories are meant to store and retrieve Entities from the database. + * Repositories are meant to store and retrieve Entities from the database. * * The reason why there are methods prefixed with an underscore is because PHP doesn't support generic polymorphism * which means we can't directly overload base methods and make parameters more strict (from a parent class to a child @@ -19,7 +19,7 @@ use Psr\Log\LoggerInterface; * Similarly, we can't make an overloaded method return type more strict until we only support PHP version 7.4 but this * is less pressing. */ -abstract class BaseDepository +abstract class BaseRepository { const LIMIT = 30; diff --git a/src/Contact/FriendSuggest/Depository/FriendSuggest.php b/src/Contact/FriendSuggest/Repository/FriendSuggest.php similarity index 96% rename from src/Contact/FriendSuggest/Depository/FriendSuggest.php rename to src/Contact/FriendSuggest/Repository/FriendSuggest.php index 76f96bdf04..77abd73537 100644 --- a/src/Contact/FriendSuggest/Depository/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Repository/FriendSuggest.php @@ -1,9 +1,8 @@ create(Contact\FriendSuggest\Depository\FriendSuggest::class); + return self::$dice->create(Contact\FriendSuggest\Repository\FriendSuggest::class); } /** @@ -443,11 +443,11 @@ abstract class DI } /** - * @return Contact\Introduction\Depository\Introduction + * @return Contact\Introduction\Repository\Introduction */ public static function intro() { - return self::$dice->create(Contact\Introduction\Depository\Introduction::class); + return self::$dice->create(Contact\Introduction\Repository\Introduction::class); } /** @@ -458,9 +458,9 @@ abstract class DI return self::$dice->create(Contact\Introduction\Factory\Introduction::class); } - public static function permissionSet(): Security\PermissionSet\Depository\PermissionSet + public static function permissionSet(): Security\PermissionSet\Repository\PermissionSet { - return self::$dice->create(Security\PermissionSet\Depository\PermissionSet::class); + return self::$dice->create(Security\PermissionSet\Repository\PermissionSet::class); } public static function permissionSetFactory(): Security\PermissionSet\Factory\PermissionSet @@ -468,9 +468,9 @@ abstract class DI return self::$dice->create(Security\PermissionSet\Factory\PermissionSet::class); } - public static function profileField(): Profile\ProfileField\Depository\ProfileField + public static function profileField(): Profile\ProfileField\Repository\ProfileField { - return self::$dice->create(Profile\ProfileField\Depository\ProfileField::class); + return self::$dice->create(Profile\ProfileField\Repository\ProfileField::class); } public static function profileFieldFactory(): Profile\ProfileField\Factory\ProfileField @@ -478,9 +478,9 @@ abstract class DI return self::$dice->create(Profile\ProfileField\Factory\ProfileField::class); } - public static function notification(): Navigation\Notifications\Depository\Notification + public static function notification(): Navigation\Notifications\Repository\Notification { - return self::$dice->create(Navigation\Notifications\Depository\Notification::class); + return self::$dice->create(Navigation\Notifications\Repository\Notification::class); } public static function notificationFactory(): Navigation\Notifications\Factory\Notification @@ -488,9 +488,9 @@ abstract class DI return self::$dice->create(Navigation\Notifications\Factory\Notification::class); } - public static function notify(): Navigation\Notifications\Depository\Notify + public static function notify(): Navigation\Notifications\Repository\Notify { - return self::$dice->create(Navigation\Notifications\Depository\Notify::class); + return self::$dice->create(Navigation\Notifications\Repository\Notify::class); } public static function notifyFactory(): Navigation\Notifications\Factory\Notify diff --git a/src/Factory/Api/Mastodon/Account.php b/src/Factory/Api/Mastodon/Account.php index a987e6874c..7b7eba0ed5 100644 --- a/src/Factory/Api/Mastodon/Account.php +++ b/src/Factory/Api/Mastodon/Account.php @@ -27,7 +27,7 @@ use Friendica\Collection\Api\Mastodon\Fields; use Friendica\Model\APContact; use Friendica\Model\Contact; use Friendica\Network\HTTPException; -use Friendica\Profile\ProfileField\Depository\ProfileField as ProfileFieldDepository; +use Friendica\Profile\ProfileField\Repository\ProfileField as ProfileFieldRepository; use ImagickException; use Psr\Log\LoggerInterface; @@ -35,17 +35,17 @@ class Account extends BaseFactory { /** @var BaseURL */ private $baseUrl; - /** @var ProfileFieldDepository */ - private $profileFieldDepo; + /** @var ProfileFieldRepository */ + private $profileFieldRepo; /** @var Field */ private $mstdnFieldFactory; - public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileFieldDepository $profileFieldDepo, Field $mstdnFieldFactory) + public function __construct(LoggerInterface $logger, BaseURL $baseURL, ProfileFieldRepository $profileFieldRepo, Field $mstdnFieldFactory) { parent::__construct($logger); $this->baseUrl = $baseURL; - $this->profileFieldDepo = $profileFieldDepo; + $this->profileFieldRepo = $profileFieldRepo; $this->mstdnFieldFactory = $mstdnFieldFactory; } @@ -76,7 +76,7 @@ class Account extends BaseFactory $self_contact = Contact::selectFirst(['uid'], ['nurl' => $publicContact['nurl'], 'self' => true]); if (!empty($self_contact['uid'])) { - $profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($self_contact['uid']); + $profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']); $fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields); } else { $fields = new Fields(); @@ -94,7 +94,7 @@ class Account extends BaseFactory { $publicContact = Contact::selectFirst([], ['uid' => $userId, 'self' => true]); - $profileFields = $this->profileFieldDepo->selectPublicFieldsByUserId($userId); + $profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId); $fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields); $apContact = APContact::getByURL($publicContact['url'], false); diff --git a/src/Module/Api/Friendica/Profile/Show.php b/src/Module/Api/Friendica/Profile/Show.php index 8102ac4bcc..4167e6c61f 100644 --- a/src/Module/Api/Friendica/Profile/Show.php +++ b/src/Module/Api/Friendica/Profile/Show.php @@ -28,7 +28,7 @@ use Friendica\Model\Contact; use Friendica\Model\Profile; use Friendica\Module\BaseApi; use Friendica\Network\HTTPException; -use Friendica\Security\PermissionSet\Depository\PermissionSet; +use Friendica\Security\PermissionSet\Repository\PermissionSet; /** * API endpoint: /api/friendica/profile/show diff --git a/src/Navigation/Notifications/Factory/FormattedNotification.php b/src/Navigation/Notifications/Factory/FormattedNotification.php index 4e8c1b8462..df0a779155 100644 --- a/src/Navigation/Notifications/Factory/FormattedNotification.php +++ b/src/Navigation/Notifications/Factory/FormattedNotification.php @@ -32,7 +32,7 @@ use Friendica\Model\Contact; use Friendica\Model\Post; use Friendica\Module\BaseNotifications; use Friendica\Navigation\Notifications\Collection\FormattedNotifications; -use Friendica\Navigation\Notifications\Depository; +use Friendica\Navigation\Notifications\Repository; use Friendica\Navigation\Notifications\ValueObject; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Protocol\Activity; @@ -54,14 +54,14 @@ class FormattedNotification extends BaseFactory { /** @var Database */ private $dba; - /** @var Depository\Notify */ + /** @var Repository\Notify */ private $notify; /** @var BaseURL */ private $baseUrl; /** @var L10n */ private $l10n; - public function __construct(LoggerInterface $logger, Database $dba, Depository\Notify $notify, BaseURL $baseUrl, L10n $l10n) + public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notify, BaseURL $baseUrl, L10n $l10n) { parent::__construct($logger); diff --git a/src/Navigation/Notifications/Depository/Notification.php b/src/Navigation/Notifications/Repository/Notification.php similarity index 96% rename from src/Navigation/Notifications/Depository/Notification.php rename to src/Navigation/Notifications/Repository/Notification.php index a93bce6657..154461e236 100644 --- a/src/Navigation/Notifications/Depository/Notification.php +++ b/src/Navigation/Notifications/Repository/Notification.php @@ -1,10 +1,10 @@ permissionSetDepository = $permissionSetDepository; + $this->permissionSetRepository = $permissionSetRepository; } /** @@ -124,7 +124,7 @@ class ProfileField extends BaseDepository public function selectPublicFieldsByUserId(int $uid): Collection\ProfileFields { try { - $publicPermissionSet = $this->permissionSetDepository->selectPublicForUser($uid); + $publicPermissionSet = $this->permissionSetRepository->selectPublicForUser($uid); return $this->select([ 'uid' => $uid, @@ -162,12 +162,12 @@ class ProfileField extends BaseDepository */ public function selectByContactId(int $cid, int $uid): Collection\ProfileFields { - $permissionSets = $this->permissionSetDepository->selectByContactId($cid, $uid); + $permissionSets = $this->permissionSetRepository->selectByContactId($cid, $uid); $permissionSetIds = $permissionSets->column('id'); // Includes public custom fields - $permissionSetIds[] = $this->permissionSetDepository->selectPublicForUser($uid)->id; + $permissionSetIds[] = $this->permissionSetRepository->selectPublicForUser($uid)->id; return $this->select( ['uid' => $uid, 'psid' => $permissionSetIds], diff --git a/src/Security/PermissionSet/Entity/PermissionSet.php b/src/Security/PermissionSet/Entity/PermissionSet.php index 6a04093315..830c631a4c 100644 --- a/src/Security/PermissionSet/Entity/PermissionSet.php +++ b/src/Security/PermissionSet/Entity/PermissionSet.php @@ -3,7 +3,7 @@ namespace Friendica\Security\PermissionSet\Entity; use Friendica\BaseEntity; -use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository; +use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository; /** * @property-read int|null $id @@ -55,7 +55,7 @@ class PermissionSet extends BaseEntity */ public function isPublic(): bool { - return (($this->id === PermissionSetDepository::PUBLIC) || + return (($this->id === PermissionSetRepository::PUBLIC) || (is_null($this->id) && empty($this->allow_cid) && empty($this->allow_gid) && diff --git a/src/Security/PermissionSet/Depository/PermissionSet.php b/src/Security/PermissionSet/Repository/PermissionSet.php similarity index 98% rename from src/Security/PermissionSet/Depository/PermissionSet.php rename to src/Security/PermissionSet/Repository/PermissionSet.php index b91f452180..af02646463 100644 --- a/src/Security/PermissionSet/Depository/PermissionSet.php +++ b/src/Security/PermissionSet/Repository/PermissionSet.php @@ -19,10 +19,10 @@ * */ -namespace Friendica\Security\PermissionSet\Depository; +namespace Friendica\Security\PermissionSet\Repository; use Exception; -use Friendica\BaseDepository; +use Friendica\BaseRepository; use Friendica\Database\Database; use Friendica\Model\Contact; use Friendica\Model\Group; @@ -33,7 +33,7 @@ use Friendica\Security\PermissionSet\Entity; use Friendica\Util\ACLFormatter; use Psr\Log\LoggerInterface; -class PermissionSet extends BaseDepository +class PermissionSet extends BaseRepository { /** @var int Virtual permission set id for public permission */ const PUBLIC = 0; diff --git a/tests/src/Profile/ProfileField/Entity/ProfileFieldTest.php b/tests/src/Profile/ProfileField/Entity/ProfileFieldTest.php index 8acd1d94ca..275a1d5972 100644 --- a/tests/src/Profile/ProfileField/Entity/ProfileFieldTest.php +++ b/tests/src/Profile/ProfileField/Entity/ProfileFieldTest.php @@ -6,7 +6,7 @@ use Friendica\Profile\ProfileField\Entity\ProfileField; use Friendica\Profile\ProfileField\Exception\ProfileFieldNotFoundException; use Friendica\Profile\ProfileField\Exception\UnexpectedPermissionSetException; use Friendica\Profile\ProfileField\Factory\ProfileField as ProfileFieldFactory; -use Friendica\Security\PermissionSet\Depository\PermissionSet as PermissionSetDepository; +use Friendica\Security\PermissionSet\Repository\PermissionSet as PermissionSetRepository; use Friendica\Security\PermissionSet\Factory\PermissionSet as PermissionSetFactory; use Friendica\Test\MockedTest; use Friendica\Util\ACLFormatter; @@ -16,8 +16,8 @@ use Mockery\MockInterface; class ProfileFieldTest extends MockedTest { - /** @var MockInterface|PermissionSetDepository */ - protected $permissionSetDepository; + /** @var MockInterface|PermissionSetRepository */ + protected $permissionSetRepository; /** @var ProfileFieldFactory */ protected $profileFieldFactory; /** @var MockInterface|PermissionSetFactory */ @@ -27,7 +27,7 @@ class ProfileFieldTest extends MockedTest { parent::setUp(); - $this->permissionSetDepository = \Mockery::mock(PermissionSetDepository::class); + $this->permissionSetRepository = \Mockery::mock(PermissionSetRepository::class); $this->permissionSetFactory = new PermissionSetFactory(new VoidLogger(), new ACLFormatter()); $this->profileFieldFactory = new ProfileFieldFactory(new VoidLogger(), $this->permissionSetFactory); } @@ -180,7 +180,7 @@ class ProfileFieldTest extends MockedTest $permissionSet = $this->permissionSetFactory->createFromTableRow(['uid' => $uid, 'id' => $psid]); - $this->permissionSetDepository->shouldReceive('selectOneById')->with($psid, $uid)->andReturns($permissionSet); + $this->permissionSetRepository->shouldReceive('selectOneById')->with($psid, $uid)->andReturns($permissionSet); self::assertEquals($psid, $entity->permissionSet->id); } diff --git a/tests/src/Profile/ProfileField/Depository/ProfileFieldTest.php b/tests/src/Profile/ProfileField/Repository/ProfileFieldTest.php similarity index 84% rename from tests/src/Profile/ProfileField/Depository/ProfileFieldTest.php rename to tests/src/Profile/ProfileField/Repository/ProfileFieldTest.php index 87ea6ca9c5..0da41f51c2 100644 --- a/tests/src/Profile/ProfileField/Depository/ProfileFieldTest.php +++ b/tests/src/Profile/ProfileField/Repository/ProfileFieldTest.php @@ -1,27 +1,27 @@ depository = DI::profileField(); $this->factory = DI::profileFieldFactory(); $this->permissionSetFactory = DI::permissionSetFactory(); - $this->permissionSetDepository = DI::permissionSet(); + $this->permissionSetRepository = DI::permissionSet(); } /** @@ -53,7 +53,7 @@ class ProfileFieldTest extends FixtureTest */ public function testSaveNew() { - $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); + $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); self::assertEquals($profileField->uid, $profileField->permissionSet->uid); @@ -75,7 +75,7 @@ class ProfileFieldTest extends FixtureTest */ public function testUpdateOrder() { - $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); + $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); self::assertEquals($profileField->uid, $profileField->permissionSet->uid); @@ -108,7 +108,7 @@ class ProfileFieldTest extends FixtureTest */ public function testUpdate() { - $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetDepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); + $profileField = $this->factory->createFromValues(42, 0, 'public', 'value', $this->permissionSetRepository->save($this->permissionSetFactory->createFromString(42, '', '<~>'))); self::assertEquals($profileField->uid, $profileField->permissionSet->uid); @@ -121,12 +121,12 @@ class ProfileFieldTest extends FixtureTest self::assertEquals($savedProfileField, $selectedProfileField); - $savedProfileField->update('another', 5, $this->permissionSetDepository->selectPublicForUser(42)); + $savedProfileField->update('another', 5, $this->permissionSetRepository->selectPublicForUser(42)); self::assertEquals(PermissionSet::PUBLIC, $savedProfileField->permissionSet->id); $publicProfileField = $this->depository->save($savedProfileField); - self::assertEquals($this->permissionSetDepository->selectPublicForUser(42), $publicProfileField->permissionSet); + self::assertEquals($this->permissionSetRepository->selectPublicForUser(42), $publicProfileField->permissionSet); self::assertEquals('another', $publicProfileField->value); self::assertEquals(5, $publicProfileField->order); diff --git a/tests/src/Security/PermissionSet/Depository/PermissionSetTest.php b/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php similarity index 67% rename from tests/src/Security/PermissionSet/Depository/PermissionSetTest.php rename to tests/src/Security/PermissionSet/Repository/PermissionSetTest.php index 596b1e6c15..697c5885ff 100644 --- a/tests/src/Security/PermissionSet/Depository/PermissionSetTest.php +++ b/tests/src/Security/PermissionSet/Repository/PermissionSetTest.php @@ -1,8 +1,8 @@ depository = DI::permissionSet(); + $this->repository = DI::permissionSet(); $this->factory = DI::permissionSetFactory(); } public function testSelectOneByIdPublic() { - $permissionSet = $this->depository->selectPublicForUser(1); + $permissionSet = $this->repository->selectPublicForUser(1); $this->assertInstanceOf(PermissionSet::class, $permissionSet); self::assertEmpty($permissionSet->allow_cid); self::assertEmpty($permissionSet->allow_gid); self::assertEmpty($permissionSet->deny_cid); self::assertEmpty($permissionSet->deny_gid); - self::assertEmpty(PermissionSetDepository::PUBLIC, $permissionSet->id); + self::assertEmpty(PermissionSetRepository::PUBLIC, $permissionSet->id); self::assertEquals(1, $permissionSet->uid); } @@ -43,21 +43,21 @@ class PermissionSetTest extends FixtureTest { $permissionSet = $this->factory->createFromString(42, '', '<~>'); - $permissionSet = $this->depository->selectOrCreate($permissionSet); + $permissionSet = $this->repository->selectOrCreate($permissionSet); self::assertNotNull($permissionSet->id); - $permissionSetSelected = $this->depository->selectOneById($permissionSet->id, 42); + $permissionSetSelected = $this->repository->selectOneById($permissionSet->id, 42); self::assertEquals($permissionSet, $permissionSetSelected); $newPermissionSet = $permissionSet->withAllowedContacts(['1', '2']); - $savedPermissionSet = $this->depository->save($newPermissionSet); + $savedPermissionSet = $this->repository->save($newPermissionSet); self::assertNotNull($savedPermissionSet->id); self::assertNull($newPermissionSet->id); - $permissionSetSavedSelected = $this->depository->selectOneById($savedPermissionSet->id, 42); + $permissionSetSavedSelected = $this->repository->selectOneById($savedPermissionSet->id, 42); self::assertEquals($savedPermissionSet, $permissionSetSavedSelected); } diff --git a/update.php b/update.php index 85f407d36c..a2999ed5a5 100644 --- a/update.php +++ b/update.php @@ -55,7 +55,7 @@ use Friendica\Model\Photo; use Friendica\Model\Post; use Friendica\Model\Profile; use Friendica\Model\Storage; -use Friendica\Security\PermissionSet\Depository\PermissionSet; +use Friendica\Security\PermissionSet\Repository\PermissionSet; use Friendica\Worker\Delivery; // Post-update script of PR 5751 From 4a386b2f36b621437bb7a38d64a875ef09e52614 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 22 Oct 2021 09:29:41 +0200 Subject: [PATCH 04/15] Add some missing Copyright header --- src/BaseRepository.php | 19 +++++++++++++++++++ .../Collection/FriendSuggests.php | 19 +++++++++++++++++++ .../FriendSuggestNotFoundException.php | 19 +++++++++++++++++++ .../FriendSuggestPersistenceException.php | 19 +++++++++++++++++++ .../FriendSuggest/Factory/FriendSuggest.php | 19 +++++++++++++++++++ .../Repository/FriendSuggest.php | 19 +++++++++++++++++++ .../Introduction/Collection/Introductions.php | 19 +++++++++++++++++++ .../IntroductionNotFoundException.php | 19 +++++++++++++++++++ .../IntroductionPersistenceException.php | 19 +++++++++++++++++++ .../Collection/PermissionSets.php | 19 +++++++++++++++++++ .../PermissionSet/Entity/PermissionSet.php | 19 +++++++++++++++++++ .../PermissionSet/Factory/PermissionSet.php | 19 +++++++++++++++++++ .../TwoFactor/Collection/TrustedBrowsers.php | 19 +++++++++++++++++++ .../TwoFactor/Factory/TrustedBrowser.php | 19 +++++++++++++++++++ .../TwoFactor/Model/TrustedBrowser.php | 19 +++++++++++++++++++ .../TwoFactor/Repository/TrustedBrowser.php | 19 +++++++++++++++++++ 16 files changed, 304 insertions(+) diff --git a/src/BaseRepository.php b/src/BaseRepository.php index dccfe7fdc7..b86eff983a 100644 --- a/src/BaseRepository.php +++ b/src/BaseRepository.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica; diff --git a/src/Contact/FriendSuggest/Collection/FriendSuggests.php b/src/Contact/FriendSuggest/Collection/FriendSuggests.php index ad382b39c5..be896ad0d8 100644 --- a/src/Contact/FriendSuggest/Collection/FriendSuggests.php +++ b/src/Contact/FriendSuggest/Collection/FriendSuggests.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\FriendSuggest\Collection; diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php index e5ba7e19d1..af699b1763 100644 --- a/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\FriendSuggest\Exception; diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php index 4b901272df..3dcb36939f 100644 --- a/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\FriendSuggest\Exception; diff --git a/src/Contact/FriendSuggest/Factory/FriendSuggest.php b/src/Contact/FriendSuggest/Factory/FriendSuggest.php index 1a3660e856..dcda234b32 100644 --- a/src/Contact/FriendSuggest/Factory/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Factory/FriendSuggest.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\FriendSuggest\Factory; diff --git a/src/Contact/FriendSuggest/Repository/FriendSuggest.php b/src/Contact/FriendSuggest/Repository/FriendSuggest.php index 77abd73537..eefc1a7636 100644 --- a/src/Contact/FriendSuggest/Repository/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Repository/FriendSuggest.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\FriendSuggest\Repository; diff --git a/src/Contact/Introduction/Collection/Introductions.php b/src/Contact/Introduction/Collection/Introductions.php index 4df89cee43..697be46f95 100644 --- a/src/Contact/Introduction/Collection/Introductions.php +++ b/src/Contact/Introduction/Collection/Introductions.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\Introduction\Collection; diff --git a/src/Contact/Introduction/Exception/IntroductionNotFoundException.php b/src/Contact/Introduction/Exception/IntroductionNotFoundException.php index f48c9ea22c..aee01f3472 100644 --- a/src/Contact/Introduction/Exception/IntroductionNotFoundException.php +++ b/src/Contact/Introduction/Exception/IntroductionNotFoundException.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\Introduction\Exception; diff --git a/src/Contact/Introduction/Exception/IntroductionPersistenceException.php b/src/Contact/Introduction/Exception/IntroductionPersistenceException.php index 99fb919e38..e0f8d2baf0 100644 --- a/src/Contact/Introduction/Exception/IntroductionPersistenceException.php +++ b/src/Contact/Introduction/Exception/IntroductionPersistenceException.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Contact\Introduction\Exception; diff --git a/src/Security/PermissionSet/Collection/PermissionSets.php b/src/Security/PermissionSet/Collection/PermissionSets.php index c15b23a68a..a18a05d176 100644 --- a/src/Security/PermissionSet/Collection/PermissionSets.php +++ b/src/Security/PermissionSet/Collection/PermissionSets.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\PermissionSet\Collection; diff --git a/src/Security/PermissionSet/Entity/PermissionSet.php b/src/Security/PermissionSet/Entity/PermissionSet.php index 830c631a4c..eb71909f1f 100644 --- a/src/Security/PermissionSet/Entity/PermissionSet.php +++ b/src/Security/PermissionSet/Entity/PermissionSet.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\PermissionSet\Entity; diff --git a/src/Security/PermissionSet/Factory/PermissionSet.php b/src/Security/PermissionSet/Factory/PermissionSet.php index bde6cd73f1..969dfa1854 100644 --- a/src/Security/PermissionSet/Factory/PermissionSet.php +++ b/src/Security/PermissionSet/Factory/PermissionSet.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\PermissionSet\Factory; diff --git a/src/Security/TwoFactor/Collection/TrustedBrowsers.php b/src/Security/TwoFactor/Collection/TrustedBrowsers.php index 659e16a5b5..f3958802b1 100644 --- a/src/Security/TwoFactor/Collection/TrustedBrowsers.php +++ b/src/Security/TwoFactor/Collection/TrustedBrowsers.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\TwoFactor\Collection; diff --git a/src/Security/TwoFactor/Factory/TrustedBrowser.php b/src/Security/TwoFactor/Factory/TrustedBrowser.php index f190474a62..2f5c1a3136 100644 --- a/src/Security/TwoFactor/Factory/TrustedBrowser.php +++ b/src/Security/TwoFactor/Factory/TrustedBrowser.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\TwoFactor\Factory; diff --git a/src/Security/TwoFactor/Model/TrustedBrowser.php b/src/Security/TwoFactor/Model/TrustedBrowser.php index 7acc237858..4a3295cc65 100644 --- a/src/Security/TwoFactor/Model/TrustedBrowser.php +++ b/src/Security/TwoFactor/Model/TrustedBrowser.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\TwoFactor\Model; diff --git a/src/Security/TwoFactor/Repository/TrustedBrowser.php b/src/Security/TwoFactor/Repository/TrustedBrowser.php index 6d708d3673..35407029cd 100644 --- a/src/Security/TwoFactor/Repository/TrustedBrowser.php +++ b/src/Security/TwoFactor/Repository/TrustedBrowser.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Security\TwoFactor\Repository; From 61839d503a8f0f26e6f0b6860c0f35ee90ac4d54 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 22 Oct 2021 19:10:55 +0200 Subject: [PATCH 05/15] Fix "Suggest a friend" text --- src/Module/FriendSuggest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/FriendSuggest.php b/src/Module/FriendSuggest.php index e8e0fc2f09..78e75bc314 100644 --- a/src/Module/FriendSuggest.php +++ b/src/Module/FriendSuggest.php @@ -93,7 +93,7 @@ class FriendSuggest extends BaseModule DI::baseUrl()->redirect(); } - $contacts = ContactModel::selectToArray(['id', 'name'], [ + $suggestableContacts = ContactModel::selectToArray(['id', 'name'], [ '`uid` = ? AND `id` != ? AND `network` = ? @@ -110,8 +110,8 @@ class FriendSuggest extends BaseModule $formattedContacts = []; - foreach ($contacts as $contact) { - $formattedContacts[$contact['id']] = $contact['name']; + foreach ($suggestableContacts as $suggestableContact) { + $formattedContacts[$suggestableContact['id']] = $suggestableContact['name']; } $tpl = Renderer::getMarkupTemplate('fsuggest.tpl'); From 6623780cf8f7cff97937e2ec65b910be7da01d6c Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 22 Oct 2021 19:13:40 +0200 Subject: [PATCH 06/15] Fix FSuggest conversation --- src/Contact/FriendSuggest/Repository/FriendSuggest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Contact/FriendSuggest/Repository/FriendSuggest.php b/src/Contact/FriendSuggest/Repository/FriendSuggest.php index eefc1a7636..b837299224 100644 --- a/src/Contact/FriendSuggest/Repository/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Repository/FriendSuggest.php @@ -29,6 +29,7 @@ use Friendica\Contact\FriendSuggest\Exception\FriendSuggestPersistenceException; use Friendica\Contact\FriendSuggest\Factory; use Friendica\Database\Database; use Friendica\Network\HTTPException\NotFoundException; +use Friendica\Util\DateTimeFormat; use Psr\Log\LoggerInterface; class FriendSuggest extends BaseRepository @@ -53,6 +54,7 @@ class FriendSuggest extends BaseRepository 'request' => $fsuggest->request, 'photo' => $fsuggest->photo, 'note' => $fsuggest->note, + 'created' => $fsuggest->created->format(DateTimeFormat::MYSQL), ]; } From 1c100bbac02bb4a77a252767a3739062825ea301 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 22 Oct 2021 21:30:54 +0200 Subject: [PATCH 07/15] Added basic unit tests --- .../Factory/FriendSuggestTest.php | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php diff --git a/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php b/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php new file mode 100644 index 0000000000..86c956a838 --- /dev/null +++ b/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php @@ -0,0 +1,113 @@ + [ + 'input' => [ + 'uid' => 12, + 'cid' => 13, + 'name' => 'test', + 'url' => 'https://friendica.local/profile/test', + 'request' => 'https://friendica.local/dfrn_request/test', + 'photo' => 'https://friendica.local/photo/profile/test', + 'note' => 'a common note', + 'created' => '2021-10-12 12:23:00' + ], + 'assertion' => [ + 'uid' => 12, + 'cid' => 13, + 'name' => 'test', + 'url' => 'https://friendica.local/profile/test', + 'request' => 'https://friendica.local/dfrn_request/test', + 'photo' => 'https://friendica.local/photo/profile/test', + 'note' => 'a common note', + 'created' => new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), + 'id' => null, + ], + ], + 'minimum' => [ + 'input' => [ + 'id' => 20, + ], + 'assertion' => [ + 'id' => 20, + ] + ], + 'full' => [ + 'input' => [ + 'uid' => 12, + 'cid' => 13, + 'name' => 'test', + 'url' => 'https://friendica.local/profile/test', + 'request' => 'https://friendica.local/dfrn_request/test', + 'photo' => 'https://friendica.local/photo/profile/test', + 'note' => 'a common note', + 'created' => '2021-10-12 12:23:00', + 'id' => 666, + ], + 'assertion' => [ + 'uid' => 12, + 'cid' => 13, + 'name' => 'test', + 'url' => 'https://friendica.local/profile/test', + 'request' => 'https://friendica.local/dfrn_request/test', + 'photo' => 'https://friendica.local/photo/profile/test', + 'note' => 'a common note', + 'created' => new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), + 'id' => 666, + ], + ], + ]; + } + + public function assertFriendSuggest(Entity\FriendSuggest $friendSuggest, array $assertion) + { + self::assertEquals($assertion['id'] ?? null, $friendSuggest->id); + self::assertEquals($assertion['uid'] ?? 0, $friendSuggest->uid); + self::assertEquals($assertion['cid'] ?? 0, $friendSuggest->cid); + self::assertEquals($assertion['name'] ?? '', $friendSuggest->name); + self::assertEquals($assertion['url'] ?? '', $friendSuggest->url); + self::assertEquals($assertion['request'] ?? '', $friendSuggest->request); + self::assertEquals($assertion['photo'] ?? '', $friendSuggest->photo); + self::assertEquals($assertion['note'] ?? '', $friendSuggest->note); + if (empty($assertion['created'])) { + self::assertInstanceOf(\DateTime::class, $friendSuggest->created); + } else { + self::assertEquals($assertion['created'], $friendSuggest->created); + } + } + + public function testCreateNew() + { + $factory = new FriendSuggest(new VoidLogger()); + + $this->assertFriendSuggest($factory->createNew(12, 13), ['uid' => 12, 'cid' => 13]); + } + + /** + * @dataProvider dataCreate + */ + public function testCreateFromTableRow(array $input, array $assertion) + { + $factory = new FriendSuggest(new VoidLogger()); + + $this->assertFriendSuggest($factory->createFromTableRow($input), $assertion); + } + + public function testCreateEmpty() + { + $factory = new FriendSuggest(new VoidLogger()); + + $this->assertFriendSuggest($factory->createEmpty(66), ['id' => 66]); + } +} From 6a7cbefaa5474ead0946992dc8cda87b68de7a4f Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 22 Oct 2021 21:54:36 +0200 Subject: [PATCH 08/15] Improve tests :-) --- .../Factory/FriendSuggestTest.php | 93 ++++++++++--------- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php b/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php index 86c956a838..afa0711ae0 100644 --- a/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php +++ b/tests/src/Contact/FriendSuggest/Factory/FriendSuggestTest.php @@ -23,25 +23,32 @@ class FriendSuggestTest extends MockedTest 'note' => 'a common note', 'created' => '2021-10-12 12:23:00' ], - 'assertion' => [ - 'uid' => 12, - 'cid' => 13, - 'name' => 'test', - 'url' => 'https://friendica.local/profile/test', - 'request' => 'https://friendica.local/dfrn_request/test', - 'photo' => 'https://friendica.local/photo/profile/test', - 'note' => 'a common note', - 'created' => new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), - 'id' => null, - ], + 'assertion' => new Entity\FriendSuggest( + 12, + 13, + 'test', + 'https://friendica.local/profile/test', + 'https://friendica.local/dfrn_request/test', + 'https://friendica.local/photo/profile/test', + 'a common note', + new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')) + ), ], 'minimum' => [ 'input' => [ 'id' => 20, ], - 'assertion' => [ - 'id' => 20, - ] + 'assertion' => new Entity\FriendSuggest( + 0, + 0, + '', + '', + '', + '', + '', + new \DateTime('now', new \DateTimeZone('URC')), + 28 + ), ], 'full' => [ 'input' => [ @@ -55,49 +62,49 @@ class FriendSuggestTest extends MockedTest 'created' => '2021-10-12 12:23:00', 'id' => 666, ], - 'assertion' => [ - 'uid' => 12, - 'cid' => 13, - 'name' => 'test', - 'url' => 'https://friendica.local/profile/test', - 'request' => 'https://friendica.local/dfrn_request/test', - 'photo' => 'https://friendica.local/photo/profile/test', - 'note' => 'a common note', - 'created' => new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), - 'id' => 666, - ], + 'assertion' => new Entity\FriendSuggest( + 12, + 13, + 'test', + 'https://friendica.local/profile/test', + 'https://friendica.local/dfrn_request/test', + 'https://friendica.local/photo/profile/test', + 'a common note', + new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), + 666 + ), ], ]; } - public function assertFriendSuggest(Entity\FriendSuggest $friendSuggest, array $assertion) + public function assertFriendSuggest(Entity\FriendSuggest $assertion, Entity\FriendSuggest $friendSuggest) { - self::assertEquals($assertion['id'] ?? null, $friendSuggest->id); - self::assertEquals($assertion['uid'] ?? 0, $friendSuggest->uid); - self::assertEquals($assertion['cid'] ?? 0, $friendSuggest->cid); - self::assertEquals($assertion['name'] ?? '', $friendSuggest->name); - self::assertEquals($assertion['url'] ?? '', $friendSuggest->url); - self::assertEquals($assertion['request'] ?? '', $friendSuggest->request); - self::assertEquals($assertion['photo'] ?? '', $friendSuggest->photo); - self::assertEquals($assertion['note'] ?? '', $friendSuggest->note); - if (empty($assertion['created'])) { - self::assertInstanceOf(\DateTime::class, $friendSuggest->created); - } else { - self::assertEquals($assertion['created'], $friendSuggest->created); - } + self::assertEquals($assertion->id, $friendSuggest->id); + self::assertEquals($assertion->uid, $friendSuggest->uid); + self::assertEquals($assertion->cid, $friendSuggest->cid); + self::assertEquals($assertion->name, $friendSuggest->name); + self::assertEquals($assertion->url, $friendSuggest->url); + self::assertEquals($assertion->request, $friendSuggest->request); + self::assertEquals($assertion->photo, $friendSuggest->photo); + self::assertEquals($assertion->note, $friendSuggest->note); } public function testCreateNew() { $factory = new FriendSuggest(new VoidLogger()); - $this->assertFriendSuggest($factory->createNew(12, 13), ['uid' => 12, 'cid' => 13]); + $this->assertFriendSuggest( + $factory->createNew(12, 13), + new Entity\FriendSuggest(12, 13, '', '', '', '', '', + new \DateTime('now', new \DateTimeZone('UTC')), null + ) + ); } /** * @dataProvider dataCreate */ - public function testCreateFromTableRow(array $input, array $assertion) + public function testCreateFromTableRow(array $input, Entity\FriendSuggest $assertion) { $factory = new FriendSuggest(new VoidLogger()); @@ -108,6 +115,8 @@ class FriendSuggestTest extends MockedTest { $factory = new FriendSuggest(new VoidLogger()); - $this->assertFriendSuggest($factory->createEmpty(66), ['id' => 66]); + $this->assertFriendSuggest($factory->createEmpty(66), new Entity\FriendSuggest(0, 0, '', '', '', '', '', + new \DateTime('now', new \DateTimeZone('UTC')), 66 + )); } } From 74cfb320850139d57224852beee22801a3e45b28 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 06:49:22 +0200 Subject: [PATCH 09/15] Update src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php Co-authored-by: Hypolite Petovan --- .../FriendSuggest/Exception/FriendSuggestNotFoundException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php index af699b1763..04f0b75a3a 100644 --- a/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestNotFoundException.php @@ -23,7 +23,7 @@ namespace Friendica\Contact\FriendSuggest\Exception; class FriendSuggestNotFoundException extends \OutOfBoundsException { - public function __construct($message = "", \Throwable $previous = null) + public function __construct($message = '', \Throwable $previous = null) { parent::__construct($message, 404, $previous); } From 92c7b99a4f67e7b6ea280aa3484b45cbd53cd679 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 06:49:32 +0200 Subject: [PATCH 10/15] Update src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php Co-authored-by: Hypolite Petovan --- .../Exception/FriendSuggestPersistenceException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php index 3dcb36939f..daa2774505 100644 --- a/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php +++ b/src/Contact/FriendSuggest/Exception/FriendSuggestPersistenceException.php @@ -23,7 +23,7 @@ namespace Friendica\Contact\FriendSuggest\Exception; class FriendSuggestPersistenceException extends \RuntimeException { - public function __construct($message = "", \Throwable $previous = null) + public function __construct($message = '', \Throwable $previous = null) { parent::__construct($message, 500, $previous); } From 0d517b590d96b9567320517391b6cf994037b2b9 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 15:47:07 +0200 Subject: [PATCH 11/15] fetch new FSuggest after update --- src/Contact/FriendSuggest/Repository/FriendSuggest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Contact/FriendSuggest/Repository/FriendSuggest.php b/src/Contact/FriendSuggest/Repository/FriendSuggest.php index b837299224..dd607edccc 100644 --- a/src/Contact/FriendSuggest/Repository/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Repository/FriendSuggest.php @@ -130,7 +130,7 @@ class FriendSuggest extends BaseRepository if ($fsuggest->id) { $this->db->update(self::$table_name, $fields, ['id' => $fsuggest->id]); - return $this->factory->createFromTableRow($fields); + return $this->selectOneById($fsuggest->id); } else { $this->db->insert(self::$table_name, $fields); return $this->selectOneById($this->db->lastInsertId()); @@ -141,7 +141,7 @@ class FriendSuggest extends BaseRepository } /** - * @param Collection\FriendSuggest $fsuggests + * @param Collection\FriendSuggests $fsuggests * * @return bool * From 8c9eb9a58d313de8cfe50674929ede4dfacc9d19 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 20:05:51 +0200 Subject: [PATCH 12/15] Fix FSuggestselect --- src/Contact/FriendSuggest/Repository/FriendSuggest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contact/FriendSuggest/Repository/FriendSuggest.php b/src/Contact/FriendSuggest/Repository/FriendSuggest.php index dd607edccc..36f8119199 100644 --- a/src/Contact/FriendSuggest/Repository/FriendSuggest.php +++ b/src/Contact/FriendSuggest/Repository/FriendSuggest.php @@ -81,7 +81,7 @@ class FriendSuggest extends BaseRepository */ private function select(array $condition, array $params = []): Collection\FriendSuggests { - return parent::_select($condition, $params); + return new Collection\FriendSuggests(parent::_select($condition, $params)->getArrayCopy()); } /** From 01659d731f3b3c2d4dabbf2618c0521ddb8321d6 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 20:17:12 +0200 Subject: [PATCH 13/15] Fix FSuggestselect --- src/Worker/Delivery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 44fded2c53..3970090160 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -67,12 +67,12 @@ class Delivery $uid = $target_item['uid']; } elseif ($cmd == self::SUGGESTION) { try { - $target_item = DI::fsuggest()->selectOneById($post_uriid); + $target_item = DI::fsuggest()->selectOneById($post_uriid)->toArray(); } catch (FriendSuggestNotFoundException $e) { DI::logger()->info('Cannot find FriendSuggestion', ['id' => $post_uriid]); return; } - $uid = $target_item->uid; + $uid = $target_item['uid']; } elseif ($cmd == self::RELOCATION) { $uid = $post_uriid; $target_item = []; From eacb5847035ed35cfb8b3e70227efefbc7c710cb Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 20:22:34 +0200 Subject: [PATCH 14/15] Fix PHP_NOTICE because of fsuggestion --- src/Worker/Delivery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 3970090160..36d576cffe 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -213,7 +213,7 @@ class Delivery // Also transmit via Diaspora if this is a direct answer to a Diaspora comment. // This is done since the uri wouldn't match (Diaspora doesn't transmit it) // Also transmit relayed posts from Diaspora contacts via Diaspora. - if (($contact['network'] != Protocol::DIASPORA) && in_array(Protocol::DIASPORA, [$parent['network'] ?? '', $thr_parent['network'] ?? '', $target_item['network']])) { + if (($contact['network'] != Protocol::DIASPORA) && in_array(Protocol::DIASPORA, [$parent['network'] ?? '', $thr_parent['network'] ?? '', $target_item['network']] ?? '')) { Logger::info('Enforcing the Diaspora protocol', ['id' => $contact['id'], 'network' => $contact['network'], 'parent' => $parent['network'], 'thread-parent' => $thr_parent['network'], 'post' => $target_item['network']]); $contact['network'] = Protocol::DIASPORA; } @@ -273,7 +273,7 @@ class Delivery private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup, $server_protocol) { // Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora - if (Diaspora::isReshare($target_item['body']) && !empty(FContact::getByURL($contact['addr'], false))) { + if (Diaspora::isReshare($target_item['body'] ?? '') && !empty(FContact::getByURL($contact['addr'], false))) { Logger::info('Reshare will be transmitted via Diaspora', ['url' => $contact['url'], 'guid' => ($target_item['guid'] ?? '') ?: $target_item['id']]); self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup); return; From d0e98422a5f0de471fdbcdc531b09de38cf2aa86 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 21 Oct 2021 23:19:04 +0200 Subject: [PATCH 15/15] Update messages.po --- view/lang/C/messages.po | 528 ++++++++++++++++++++-------------------- 1 file changed, 264 insertions(+), 264 deletions(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index d286b0337d..30293b755f 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2021.12-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-23 17:25+0000\n" +"POT-Creation-Date: 2021-10-23 21:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -393,7 +393,7 @@ msgstr "" #: src/Module/Debug/ActivityPubConversion.php:141 #: src/Module/Debug/Babel.php:313 src/Module/Debug/Localtime.php:64 #: src/Module/Debug/Probe.php:56 src/Module/Debug/WebFinger.php:53 -#: src/Module/Delegation.php:147 src/Module/FriendSuggest.php:129 +#: src/Module/Delegation.php:147 src/Module/FriendSuggest.php:128 #: src/Module/Install.php:245 src/Module/Install.php:287 #: src/Module/Install.php:324 src/Module/Invite.php:177 #: src/Module/Item/Compose.php:150 src/Module/Profile/Profile.php:247 @@ -1114,11 +1114,11 @@ msgstr "" #: mod/redir.php:55 mod/redir.php:129 src/Module/Contact/Advanced.php:54 #: src/Module/Contact/Advanced.php:105 src/Module/Contact/Contacts.php:36 #: src/Module/Contact/Media.php:43 src/Module/FriendSuggest.php:54 -#: src/Module/FriendSuggest.php:93 src/Module/Group.php:105 +#: src/Module/FriendSuggest.php:92 src/Module/Group.php:105 msgid "Contact not found." msgstr "" -#: mod/removeme.php:63 src/Navigation/Notifications/Depository/Notify.php:454 +#: mod/removeme.php:63 src/Navigation/Notifications/Repository/Notify.php:454 msgid "[Friendica System Notify]" msgstr "" @@ -7903,15 +7903,15 @@ msgstr "" msgid "Suggested contact not found." msgstr "" -#: src/Module/FriendSuggest.php:84 +#: src/Module/FriendSuggest.php:83 msgid "Friend suggestion sent." msgstr "" -#: src/Module/FriendSuggest.php:121 +#: src/Module/FriendSuggest.php:120 msgid "Suggest Friends" msgstr "" -#: src/Module/FriendSuggest.php:124 +#: src/Module/FriendSuggest.php:123 #, php-format msgid "Suggest a friend for %s" msgstr "" @@ -9920,262 +9920,6 @@ msgid "" "features and resources." msgstr "" -#: src/Navigation/Notifications/Depository/Notify.php:192 -#: src/Navigation/Notifications/Depository/Notify.php:675 -msgid "[Friendica:Notify]" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:256 -#, php-format -msgid "%s New mail received at %s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:258 -#, php-format -msgid "%1$s sent you a new private message at %2$s." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:259 -msgid "a private message" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:259 -#, php-format -msgid "%1$s sent you %2$s." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:261 -#, php-format -msgid "Please visit %s to view and/or reply to your private messages." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:292 -#, php-format -msgid "%1$s commented on %2$s's %3$s %4$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:297 -#, php-format -msgid "%1$s commented on your %2$s %3$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:301 -#, php-format -msgid "%1$s commented on their %2$s %3$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:305 -#: src/Navigation/Notifications/Depository/Notify.php:710 -#, php-format -msgid "%1$s Comment to conversation #%2$d by %3$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:307 -#, php-format -msgid "%s commented on an item/conversation you have been following." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:311 -#: src/Navigation/Notifications/Depository/Notify.php:326 -#: src/Navigation/Notifications/Depository/Notify.php:345 -#: src/Navigation/Notifications/Depository/Notify.php:725 -#, php-format -msgid "Please visit %s to view and/or reply to the conversation." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:318 -#, php-format -msgid "%s %s posted to your profile wall" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:320 -#, php-format -msgid "%1$s posted to your profile wall at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:321 -#, php-format -msgid "%1$s posted to [url=%2$s]your wall[/url]" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:333 -#, php-format -msgid "%1$s %2$s poked you" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:335 -#, php-format -msgid "%1$s poked you at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:336 -#, php-format -msgid "%1$s [url=%2$s]poked you[/url]." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:353 -#, php-format -msgid "%s Introduction received" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:355 -#, php-format -msgid "You've received an introduction from '%1$s' at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:356 -#, php-format -msgid "You've received [url=%1$s]an introduction[/url] from %2$s." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:361 -#: src/Navigation/Notifications/Depository/Notify.php:407 -#, php-format -msgid "You may visit their profile at %s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:363 -#, php-format -msgid "Please visit %s to approve or reject the introduction." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:370 -#, php-format -msgid "%s A new person is sharing with you" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:372 -#: src/Navigation/Notifications/Depository/Notify.php:373 -#, php-format -msgid "%1$s is sharing with you at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:380 -#, php-format -msgid "%s You have a new follower" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:382 -#: src/Navigation/Notifications/Depository/Notify.php:383 -#, php-format -msgid "You have a new follower at %2$s : %1$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:396 -#, php-format -msgid "%s Friend suggestion received" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:398 -#, php-format -msgid "You've received a friend suggestion from '%1$s' at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:399 -#, php-format -msgid "You've received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:405 -msgid "Name:" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:406 -msgid "Photo:" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:409 -#, php-format -msgid "Please visit %s to approve or reject the suggestion." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:417 -#: src/Navigation/Notifications/Depository/Notify.php:432 -#, php-format -msgid "%s Connection accepted" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:419 -#: src/Navigation/Notifications/Depository/Notify.php:434 -#, php-format -msgid "'%1$s' has accepted your connection request at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:420 -#: src/Navigation/Notifications/Depository/Notify.php:435 -#, php-format -msgid "%2$s has accepted your [url=%1$s]connection request[/url]." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:425 -msgid "" -"You are now mutual friends and may exchange status updates, photos, and " -"email without restriction." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:427 -#, php-format -msgid "Please visit %s if you wish to make any changes to this relationship." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:440 -#, php-format -msgid "" -"'%1$s' has chosen to accept you a fan, which restricts some forms of " -"communication - such as private messaging and some profile interactions. If " -"this is a celebrity or community page, these settings were applied " -"automatically." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:442 -#, php-format -msgid "" -"'%1$s' may choose to extend this into a two-way or more permissive " -"relationship in the future." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:444 -#, php-format -msgid "Please visit %s if you wish to make any changes to this relationship." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:454 -msgid "registration request" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:456 -#, php-format -msgid "You've received a registration request from '%1$s' at %2$s" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:457 -#, php-format -msgid "You've received a [url=%1$s]registration request[/url] from %2$s." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:462 -#, php-format -msgid "" -"Full Name:\t%s\n" -"Site Location:\t%s\n" -"Login Name:\t%s (%s)" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:468 -#, php-format -msgid "Please visit %s to approve or reject the request." -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:704 -#, php-format -msgid "%s %s tagged you" -msgstr "" - -#: src/Navigation/Notifications/Depository/Notify.php:707 -#, php-format -msgid "%s %s shared a new post" -msgstr "" - #: src/Navigation/Notifications/Factory/FormattedNotification.php:89 #, php-format msgid "%s liked %s's post" @@ -10334,6 +10078,262 @@ msgstr "" msgid "%1$s shared a post" msgstr "" +#: src/Navigation/Notifications/Repository/Notify.php:192 +#: src/Navigation/Notifications/Repository/Notify.php:675 +msgid "[Friendica:Notify]" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:256 +#, php-format +msgid "%s New mail received at %s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:258 +#, php-format +msgid "%1$s sent you a new private message at %2$s." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:259 +msgid "a private message" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:259 +#, php-format +msgid "%1$s sent you %2$s." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:261 +#, php-format +msgid "Please visit %s to view and/or reply to your private messages." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:292 +#, php-format +msgid "%1$s commented on %2$s's %3$s %4$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:297 +#, php-format +msgid "%1$s commented on your %2$s %3$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:301 +#, php-format +msgid "%1$s commented on their %2$s %3$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:305 +#: src/Navigation/Notifications/Repository/Notify.php:710 +#, php-format +msgid "%1$s Comment to conversation #%2$d by %3$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:307 +#, php-format +msgid "%s commented on an item/conversation you have been following." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:311 +#: src/Navigation/Notifications/Repository/Notify.php:326 +#: src/Navigation/Notifications/Repository/Notify.php:345 +#: src/Navigation/Notifications/Repository/Notify.php:725 +#, php-format +msgid "Please visit %s to view and/or reply to the conversation." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:318 +#, php-format +msgid "%s %s posted to your profile wall" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:320 +#, php-format +msgid "%1$s posted to your profile wall at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:321 +#, php-format +msgid "%1$s posted to [url=%2$s]your wall[/url]" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:333 +#, php-format +msgid "%1$s %2$s poked you" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:335 +#, php-format +msgid "%1$s poked you at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:336 +#, php-format +msgid "%1$s [url=%2$s]poked you[/url]." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:353 +#, php-format +msgid "%s Introduction received" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:355 +#, php-format +msgid "You've received an introduction from '%1$s' at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:356 +#, php-format +msgid "You've received [url=%1$s]an introduction[/url] from %2$s." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:361 +#: src/Navigation/Notifications/Repository/Notify.php:407 +#, php-format +msgid "You may visit their profile at %s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:363 +#, php-format +msgid "Please visit %s to approve or reject the introduction." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:370 +#, php-format +msgid "%s A new person is sharing with you" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:372 +#: src/Navigation/Notifications/Repository/Notify.php:373 +#, php-format +msgid "%1$s is sharing with you at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:380 +#, php-format +msgid "%s You have a new follower" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:382 +#: src/Navigation/Notifications/Repository/Notify.php:383 +#, php-format +msgid "You have a new follower at %2$s : %1$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:396 +#, php-format +msgid "%s Friend suggestion received" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:398 +#, php-format +msgid "You've received a friend suggestion from '%1$s' at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:399 +#, php-format +msgid "You've received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:405 +msgid "Name:" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:406 +msgid "Photo:" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:409 +#, php-format +msgid "Please visit %s to approve or reject the suggestion." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:417 +#: src/Navigation/Notifications/Repository/Notify.php:432 +#, php-format +msgid "%s Connection accepted" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:419 +#: src/Navigation/Notifications/Repository/Notify.php:434 +#, php-format +msgid "'%1$s' has accepted your connection request at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:420 +#: src/Navigation/Notifications/Repository/Notify.php:435 +#, php-format +msgid "%2$s has accepted your [url=%1$s]connection request[/url]." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:425 +msgid "" +"You are now mutual friends and may exchange status updates, photos, and " +"email without restriction." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:427 +#, php-format +msgid "Please visit %s if you wish to make any changes to this relationship." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:440 +#, php-format +msgid "" +"'%1$s' has chosen to accept you a fan, which restricts some forms of " +"communication - such as private messaging and some profile interactions. If " +"this is a celebrity or community page, these settings were applied " +"automatically." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:442 +#, php-format +msgid "" +"'%1$s' may choose to extend this into a two-way or more permissive " +"relationship in the future." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:444 +#, php-format +msgid "Please visit %s if you wish to make any changes to this relationship." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:454 +msgid "registration request" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:456 +#, php-format +msgid "You've received a registration request from '%1$s' at %2$s" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:457 +#, php-format +msgid "You've received a [url=%1$s]registration request[/url] from %2$s." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:462 +#, php-format +msgid "" +"Full Name:\t%s\n" +"Site Location:\t%s\n" +"Login Name:\t%s (%s)" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:468 +#, php-format +msgid "Please visit %s to approve or reject the request." +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:704 +#, php-format +msgid "%s %s tagged you" +msgstr "" + +#: src/Navigation/Notifications/Repository/Notify.php:707 +#, php-format +msgid "%s %s shared a new post" +msgstr "" + #: src/Object/EMail/ItemCCEMail.php:42 #, php-format msgid "" @@ -10687,7 +10687,7 @@ msgstr "" msgid "%1$d %2$s ago" msgstr "" -#: src/Worker/Delivery.php:521 +#: src/Worker/Delivery.php:525 msgid "(no subject)" msgstr ""