* Sends an unfriend message. Removes the contact for two-way unfriending or sharing only protocols (feed an mail)
*
* @param array $user User unfriending
- * @param array $contact Contact unfriended
+ * @param array $contact Contact (uid != 0) unfriended
* @param boolean $two_way Revoke eventual inbound follow as well
* @return bool|null true if successful, false if not, null if no action was performed
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public static function terminateFriendship(array $user, array $contact, bool $two_way = false): bool
+ public static function terminateFriendship(array $user, array $contact): bool
{
- $result = Protocol::terminateFriendship($user, $contact, $two_way);
+ $result = Protocol::terminateFriendship($user, $contact);
- if ($two_way || in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) {
+ if ($contact['rel'] == Contact::SHARING || in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) {
self::remove($contact['id']);
} else {
self::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
// A null value here means the remote network doesn't support explicit follow revocation, we can still
// break the locally recorded relationship
if ($result !== false) {
- DBA::update('contact', ['rel' => $contact['rel'] == self::FRIEND ? self::SHARING : self::NOTHING], ['id' => $contact['id']]);
+ if ($contact['rel'] == self::FRIEND) {
+ self::update(['rel' => self::SHARING], ['id' => $contact['id']]);
+ } else {
+ self::remove($contact['id']);
+ }
}
return $result;
$pm_url = '';
$status_link = '';
$photos_link = '';
- $contact_drop_link = '';
$poke_link = '';
if ($uid == 0) {
$posts_link = DI::baseUrl() . '/contact/' . $contact['id'] . '/conversations';
- if (!$contact['self']) {
- $contact_drop_link = DI::baseUrl() . '/contact/' . $contact['id'] . '/drop?confirm=1';
- }
-
$follow_link = '';
$unfollow_link = '';
if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
}
}
- if (!empty($follow_link) || !empty($unfollow_link)) {
- $contact_drop_link = '';
- }
-
/**
* Menu array:
* "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
'photos' => [DI::l10n()->t('View Photos') , $photos_link , true],
'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
- 'drop' => [DI::l10n()->t('Drop Contact') , $contact_drop_link, false],
'pm' => [DI::l10n()->t('Send PM') , $pm_url , false],
'poke' => [DI::l10n()->t('Poke') , $poke_link , false],
'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true],
* @param bool $thread_mode
* @param int $update Update mode
* @param int $parent Item parent ID for the update mode
+ * @param bool $only_media Only display media content
* @return string posts in HTML
* @throws \Exception
*/
- public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0, $parent = 0)
+ public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0, $parent = 0, bool $only_media = false)
{
- return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update, $parent);
+ return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update, $parent, $only_media);
}
/**
* @param int $cid Contact ID
* @param bool $thread_mode
* @param int $update Update mode
- * @param int $parent Item parent ID for the update mode
+ * @param int $parent Item parent ID for the update mode
+ * @param bool $only_media Only display media content
* @return string posts in HTML
* @throws \Exception
*/
- public static function getPostsFromId($cid, $thread_mode = false, $update = 0, $parent = 0)
+ public static function getPostsFromId($cid, $thread_mode = false, $update = 0, $parent = 0, bool $only_media = false)
{
- $a = DI::app();
-
$contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
if (!DBA::isResult($contact)) {
return '';
}
}
+ if ($only_media) {
+ $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
+ Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
+ }
+
if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
// Ensure to always have the correct network type, independent from the connection request method
self::updateFromProbe($contact['id']);
- Post\UserNotification::insertNotication($contact['id'], Verb::getID(Activity::FOLLOW), $importer['uid']);
+ Post\UserNotification::insertNotification($contact['id'], Verb::getID(Activity::FOLLOW), $importer['uid']);
return true;
} else {
self::updateAvatar($contact_id, $photo, true);
- Post\UserNotification::insertNotication($contact_id, Verb::getID(Activity::FOLLOW), $importer['uid']);
+ Post\UserNotification::insertNotification($contact_id, Verb::getID(Activity::FOLLOW), $importer['uid']);
$contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]);