Merge remote-tracking branch 'upstream/develop' into network-thread-view
This commit is contained in:
commit
eea355ae3b
31 changed files with 886 additions and 870 deletions
|
@ -71,6 +71,44 @@ class Protocol
|
|||
|
||||
const PHANTOM = 'unkn'; // Place holder
|
||||
|
||||
/**
|
||||
* Returns whether the provided protocol supports following
|
||||
*
|
||||
* @param $protocol
|
||||
* @return bool
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function supportsFollow($protocol): bool
|
||||
{
|
||||
if (in_array($protocol, self::NATIVE_SUPPORT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$result = null;
|
||||
Hook::callAll('support_follow', $result);
|
||||
|
||||
return $result === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the provided protocol supports revoking inbound follows
|
||||
*
|
||||
* @param $protocol
|
||||
* @return bool
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function supportsRevokeFollow($protocol): bool
|
||||
{
|
||||
if (in_array($protocol, self::NATIVE_SUPPORT)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$result = null;
|
||||
Hook::callAll('support_revoke_follow', $result);
|
||||
|
||||
return $result === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address string for the provided profile URL
|
||||
*
|
||||
|
@ -212,7 +250,7 @@ class Protocol
|
|||
return ActivityPub\Transmitter::sendContactUndo($contact['url'], $contact['id'], $user['uid']);
|
||||
}
|
||||
|
||||
// Catch-all addon hook
|
||||
// Catch-all hook for connector addons
|
||||
$hook_data = [
|
||||
'contact' => $contact,
|
||||
'two_way' => $two_way,
|
||||
|
@ -222,4 +260,36 @@ class Protocol
|
|||
|
||||
return $hook_data['result'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke an incoming follow from the provided contact
|
||||
*
|
||||
* @param array $contact Private contact (uid != 0) array
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function revokeFollow(array $contact)
|
||||
{
|
||||
if (empty($contact['network'])) {
|
||||
throw new \InvalidArgumentException('Missing network key in contact array');
|
||||
}
|
||||
|
||||
$protocol = $contact['network'];
|
||||
if ($protocol == Protocol::DFRN && !empty($contact['protocol'])) {
|
||||
$protocol = $contact['protocol'];
|
||||
}
|
||||
|
||||
if ($protocol == Protocol::ACTIVITYPUB) {
|
||||
return ActivityPub\Transmitter::sendContactReject($contact['url'], $contact['hub-verify'], $contact['uid']);
|
||||
}
|
||||
|
||||
// Catch-all hook for connector addons
|
||||
$hook_data = [
|
||||
'contact' => $contact,
|
||||
'result' => null,
|
||||
];
|
||||
Hook::callAll('revoke_follow', $hook_data);
|
||||
|
||||
return $hook_data['result'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -849,6 +849,36 @@ class Contact
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke follow privileges of the remote user contact
|
||||
*
|
||||
* @param array $contact Contact unfriended
|
||||
* @return bool|null Whether the remote operation is successful or null if no remote operation was performed
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function revokeFollow(array $contact): bool
|
||||
{
|
||||
if (empty($contact['network'])) {
|
||||
throw new \InvalidArgumentException('Empty network in contact array');
|
||||
}
|
||||
|
||||
if (empty($contact['uid'])) {
|
||||
throw new \InvalidArgumentException('Unexpected public contact record');
|
||||
}
|
||||
|
||||
$result = Protocol::revokeFollow($contact);
|
||||
|
||||
// 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']]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Marks a contact for archival after a communication issue delay
|
||||
*
|
||||
|
@ -964,7 +994,6 @@ class Contact
|
|||
$pm_url = '';
|
||||
$status_link = '';
|
||||
$photos_link = '';
|
||||
$contact_drop_link = '';
|
||||
$poke_link = '';
|
||||
|
||||
if ($uid == 0) {
|
||||
|
@ -1016,13 +1045,9 @@ class Contact
|
|||
|
||||
$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'] && in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
|
||||
if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
|
||||
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
|
||||
$unfollow_link = 'unfollow?url=' . urlencode($contact['url']) . '&auto=1';
|
||||
} elseif(!$contact['pending']) {
|
||||
|
@ -1030,10 +1055,6 @@ class Contact
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($follow_link) || !empty($unfollow_link)) {
|
||||
$contact_drop_link = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu array:
|
||||
* "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
|
||||
|
@ -1053,7 +1074,6 @@ class Contact
|
|||
'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],
|
||||
|
@ -1340,12 +1360,13 @@ class Contact
|
|||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1354,14 +1375,13 @@ class Contact
|
|||
* @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 '';
|
||||
|
@ -1392,6 +1412,11 @@ class Contact
|
|||
}
|
||||
}
|
||||
|
||||
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'));
|
||||
|
|
|
@ -68,15 +68,14 @@ class BaseProfile extends BaseModule
|
|||
'id' => 'photo-tab',
|
||||
'accesskey' => 'h',
|
||||
],
|
||||
// @todo Currently deactivated since it doesn't really work
|
||||
// [
|
||||
// 'label' => DI::l10n()->t('Videos'),
|
||||
// 'url' => DI::baseUrl() . '/videos/' . $nickname,
|
||||
// 'sel' => $current == 'videos' ? 'active' : '',
|
||||
// 'title' => DI::l10n()->t('Videos'),
|
||||
// 'id' => 'video-tab',
|
||||
// 'accesskey' => 'v',
|
||||
// ],
|
||||
[
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => $baseProfileUrl . '/media',
|
||||
'sel' => $current == 'media' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Media'),
|
||||
'id' => 'media-tab',
|
||||
'accesskey' => 'd',
|
||||
],
|
||||
];
|
||||
|
||||
// the calendar link for the full featured events calendar
|
||||
|
|
|
@ -52,6 +52,7 @@ class Contact extends BaseModule
|
|||
const TAB_PROFILE = 3;
|
||||
const TAB_CONTACTS = 4;
|
||||
const TAB_ADVANCED = 5;
|
||||
const TAB_MEDIA = 6;
|
||||
|
||||
private static function batchActions()
|
||||
{
|
||||
|
@ -86,12 +87,6 @@ class Contact extends BaseModule
|
|||
self::toggleIgnoreContact($cdata['public']);
|
||||
$count_actions++;
|
||||
}
|
||||
|
||||
if (!empty($_POST['contacts_batch_drop']) && $cdata['user']
|
||||
&& self::dropContact($cdata['user'], local_user())
|
||||
) {
|
||||
$count_actions++;
|
||||
}
|
||||
}
|
||||
if ($count_actions > 0) {
|
||||
info(DI::l10n()->tt('%d contact edited.', '%d contacts edited.', $count_actions));
|
||||
|
@ -229,31 +224,6 @@ class Contact extends BaseModule
|
|||
Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $contact_id Id for contact with uid != 0
|
||||
* @param int $uid Id for user we want to drop the contact for
|
||||
* @return bool
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function dropContact(int $contact_id, int $uid): bool
|
||||
{
|
||||
$contact = Model\Contact::getContactForUser($contact_id, $uid);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$owner = Model\User::getOwnerDataById($uid);
|
||||
if (!DBA::isResult($owner)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Model\Contact::terminateFriendship($owner, $contact, true);
|
||||
Model\Contact::remove($contact['id']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [], $update = 0)
|
||||
{
|
||||
if (!local_user()) {
|
||||
|
@ -372,7 +342,7 @@ class Contact extends BaseModule
|
|||
}
|
||||
|
||||
if ($cmd === 'posts') {
|
||||
return self::getPostsHTML($a, $contact_id);
|
||||
return self::getPostsHTML($contact_id);
|
||||
}
|
||||
|
||||
if ($cmd === 'conversations') {
|
||||
|
@ -425,36 +395,6 @@ class Contact extends BaseModule
|
|||
DI::baseUrl()->redirect('contact/' . $cdata['public']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($cmd === 'drop' && $cdata['user']) {
|
||||
// Check if we should do HTML-based delete confirmation
|
||||
if (!empty($_REQUEST['confirm'])) {
|
||||
DI::page()['aside'] = '';
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
|
||||
'$header' => DI::l10n()->t('Drop contact'),
|
||||
'$contact' => self::getContactTemplateVars($orig_record),
|
||||
'$method' => 'get',
|
||||
'$message' => DI::l10n()->t('Do you really want to delete this contact?'),
|
||||
'$confirm' => DI::l10n()->t('Yes'),
|
||||
'$confirm_url' => DI::args()->getCommand(),
|
||||
'$confirm_name' => 't',
|
||||
'$confirm_value' => BaseModule::getFormSecurityToken('contact_action'),
|
||||
'$cancel' => DI::l10n()->t('Cancel'),
|
||||
]);
|
||||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!empty($_REQUEST['canceled'])) {
|
||||
DI::baseUrl()->redirect('contact');
|
||||
}
|
||||
|
||||
if (self::dropContact($cdata['user'], local_user())) {
|
||||
info(DI::l10n()->t('Contact has been removed.'));
|
||||
}
|
||||
|
||||
DI::baseUrl()->redirect('contact');
|
||||
// NOTREACHED
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['return_path'] = DI::args()->getQueryString();
|
||||
|
@ -856,13 +796,11 @@ class Contact extends BaseModule
|
|||
'$cmd' => DI::args()->getCommand(),
|
||||
'$contacts' => $contacts,
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken('contact_batch_actions'),
|
||||
'$contact_drop_confirm' => DI::l10n()->t('Do you really want to delete this contact?'),
|
||||
'multiselect' => 1,
|
||||
'$batch_actions' => [
|
||||
'contacts_batch_update' => DI::l10n()->t('Update'),
|
||||
'contacts_batch_block' => DI::l10n()->t('Block') . '/' . DI::l10n()->t('Unblock'),
|
||||
'contacts_batch_ignore' => DI::l10n()->t('Ignore') . '/' . DI::l10n()->t('Unignore'),
|
||||
'contacts_batch_drop' => DI::l10n()->t('Delete'),
|
||||
],
|
||||
'$h_batch_actions' => DI::l10n()->t('Batch Actions'),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
|
@ -911,6 +849,14 @@ class Contact extends BaseModule
|
|||
'id' => 'posts-tab',
|
||||
'accesskey' => 'p',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Media'),
|
||||
'url' => 'contact/' . $pcid . '/media',
|
||||
'sel' => (($active_tab == self::TAB_MEDIA) ? 'active' : ''),
|
||||
'title' => DI::l10n()->t('Posts containing media objects'),
|
||||
'id' => 'media-tab',
|
||||
'accesskey' => 'd',
|
||||
],
|
||||
[
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => 'contact/' . $cid,
|
||||
|
@ -979,7 +925,7 @@ class Contact extends BaseModule
|
|||
return $o;
|
||||
}
|
||||
|
||||
private static function getPostsHTML($a, $contact_id)
|
||||
private static function getPostsHTML(int $contact_id)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'id'], ['id' => $contact_id, 'deleted' => false]);
|
||||
|
||||
|
@ -1145,13 +1091,13 @@ class Contact extends BaseModule
|
|||
'id' => 'toggle-ignore',
|
||||
];
|
||||
|
||||
if ($contact['uid'] != 0) {
|
||||
$contact_actions['delete'] = [
|
||||
'label' => DI::l10n()->t('Delete'),
|
||||
'url' => 'contact/' . $contact['id'] . '/drop?t=' . $formSecurityToken,
|
||||
'title' => DI::l10n()->t('Delete contact'),
|
||||
if ($contact['uid'] != 0 && Protocol::supportsRevokeFollow($contact['network']) && in_array($contact['rel'], [Model\Contact::FOLLOWER, Model\Contact::FRIEND])) {
|
||||
$contact_actions['revoke_follow'] = [
|
||||
'label' => DI::l10n()->t('Revoke Follow'),
|
||||
'url' => 'contact/' . $contact['id'] . '/revoke',
|
||||
'title' => DI::l10n()->t('Revoke the follow from this contact'),
|
||||
'sel' => '',
|
||||
'id' => 'delete',
|
||||
'id' => 'revoke_follow',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
54
src/Module/Contact/Media.php
Normal file
54
src/Module/Contact/Media.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\Contact as ModelContact;
|
||||
use Friendica\Module\Contact;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
|
||||
/**
|
||||
* GUI for media posts of a contact
|
||||
*/
|
||||
class Media extends BaseModule
|
||||
{
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
$cid = $parameters['id'];
|
||||
|
||||
$contact = Model\Contact::selectFirst([], ['id' => $cid]);
|
||||
if (empty($contact)) {
|
||||
throw new BadRequestException(DI::l10n()->t('Contact not found.'));
|
||||
}
|
||||
|
||||
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
||||
|
||||
$o = Contact::getTabsHTML($contact, Contact::TAB_MEDIA);
|
||||
|
||||
$o .= ModelContact::getPostsFromUrl($contact['url'], false, 0, 0, true);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
108
src/Module/Contact/Revoke.php
Normal file
108
src/Module/Contact/Revoke.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Contact;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module\Contact;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class Revoke extends BaseModule
|
||||
{
|
||||
/** @var array */
|
||||
private static $contact;
|
||||
|
||||
public static function init(array $parameters = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = Model\Contact::getPublicAndUserContactID($parameters['id'], local_user());
|
||||
if (!DBA::isResult($data)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Unknown contact.'));
|
||||
}
|
||||
|
||||
if (empty($data['user'])) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
self::$contact = Model\Contact::getById($data['user']);
|
||||
|
||||
if (self::$contact['deleted']) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact is deleted.'));
|
||||
}
|
||||
|
||||
if (!empty(self::$contact['network']) && self::$contact['network'] == Protocol::PHANTOM) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact is being deleted.'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
throw new HTTPException\UnauthorizedException();
|
||||
}
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('contact/' . $parameters['id'], 'contact_revoke');
|
||||
|
||||
$result = Model\Contact::revokeFollow(self::$contact);
|
||||
if ($result === true) {
|
||||
notice(DI::l10n()->t('Follow was successfully revoked.'));
|
||||
} elseif ($result === null) {
|
||||
notice(DI::l10n()->t('Follow was successfully revoked, however the remote contact won\'t be aware of this revokation.'));
|
||||
} else {
|
||||
notice(DI::l10n()->t('Unable to revoke follow, please try again later or contact the administrator.'));
|
||||
}
|
||||
|
||||
DI::baseUrl()->redirect('contact/' . $parameters['id']);
|
||||
}
|
||||
|
||||
public static function content(array $parameters = []): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
Nav::setSelected('contact');
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_drop_confirm.tpl'), [
|
||||
'$l10n' => [
|
||||
'header' => DI::l10n()->t('Revoke Follow'),
|
||||
'message' => DI::l10n()->t('Do you really want to revoke this contact\'s follow? This cannot be undone and they will have to manually follow you back again.'),
|
||||
'confirm' => DI::l10n()->t('Yes'),
|
||||
'cancel' => DI::l10n()->t('Cancel'),
|
||||
],
|
||||
'$contact' => Contact::getContactTemplateVars(self::$contact),
|
||||
'$method' => 'post',
|
||||
'$confirm_url' => DI::args()->getCommand(),
|
||||
'$confirm_name' => 'form_security_token',
|
||||
'$confirm_value' => BaseModule::getFormSecurityToken('contact_revoke'),
|
||||
]);
|
||||
}
|
||||
}
|
53
src/Module/Profile/Media.php
Normal file
53
src/Module/Profile/Media.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
use Friendica\Module\BaseProfile;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class Media extends BaseProfile
|
||||
{
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
$profile = ProfileModel::load($a, $parameters['nickname']);
|
||||
if (empty($profile)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
if (!$profile['net-publish']) {
|
||||
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$is_owner = local_user() == $profile['uid'];
|
||||
|
||||
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$o .= Contact::getPostsFromUrl($profile['url'], false, 0, 0, true);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
|
@ -1037,9 +1037,12 @@ class Processor
|
|||
|
||||
self::switchContact($cid);
|
||||
|
||||
if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING])) {
|
||||
$contact = Contact::getById($cid, ['rel']);
|
||||
if ($contact['rel'] == Contact::SHARING) {
|
||||
Contact::remove($cid);
|
||||
Logger::info('Rejected contact request - contact removed', ['contact' => $cid, 'user' => $uid]);
|
||||
} elseif ($contact['rel'] == Contact::FRIEND) {
|
||||
Contact::update(['rel' => Contact::FOLLOWER], ['id' => $cid]);
|
||||
} else {
|
||||
Logger::info('Rejected contact request', ['contact' => $cid, 'user' => $uid]);
|
||||
}
|
||||
|
|
|
@ -2047,15 +2047,16 @@ class Transmitter
|
|||
* @param string $target Target profile
|
||||
* @param $id
|
||||
* @param integer $uid User ID
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @return bool Operation success
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function sendContactReject($target, $id, $uid)
|
||||
public static function sendContactReject($target, $id, $uid): bool
|
||||
{
|
||||
$profile = APContact::getByURL($target);
|
||||
if (empty($profile['inbox'])) {
|
||||
Logger::warning('No inbox found for target', ['target' => $target, 'profile' => $profile]);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
@ -2075,7 +2076,7 @@ class Transmitter
|
|||
Logger::debug('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id);
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
HTTPSignature::transmit($signed, $profile['inbox'], $uid);
|
||||
return HTTPSignature::transmit($signed, $profile['inbox'], $uid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue