mirror of
https://github.com/friendica/friendica
synced 2025-04-26 09:10:15 +00:00
Move contact profile GET actions to separate module class
This commit is contained in:
parent
974b750d6d
commit
204b077353
3 changed files with 76 additions and 137 deletions
|
@ -164,6 +164,53 @@ class Profile extends BaseModule
|
|||
$this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
|
||||
}
|
||||
|
||||
if (isset($parameters['action'])) {
|
||||
self::checkFormSecurityTokenRedirectOnError('contact/' . $contact['id'], 'contact_action', 't');
|
||||
|
||||
$cmd = $parameters['action'];
|
||||
if ($cmd === 'update' && $localRelationship->rel !== Contact::NOTHING) {
|
||||
Module\Contact::updateContactFromPoll($contact['id']);
|
||||
}
|
||||
|
||||
if ($cmd === 'updateprofile' && $localRelationship->rel !== Contact::NOTHING) {
|
||||
self::updateContactFromProbe($contact['id']);
|
||||
}
|
||||
|
||||
if ($cmd === 'block') {
|
||||
if ($localRelationship->blocked) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setBlocked($contact['id'], local_user(), false);
|
||||
|
||||
$message = $this->t('Contact has been unblocked');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setBlocked($contact['id'], local_user(), true);
|
||||
$message = $this->t('Contact has been blocked');
|
||||
}
|
||||
|
||||
// @TODO: add $this->localRelationship->save($localRelationship);
|
||||
info($message);
|
||||
}
|
||||
|
||||
if ($cmd === 'ignore') {
|
||||
if ($localRelationship->ignored) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setIgnored($contact['id'], local_user(), false);
|
||||
|
||||
$message = $this->t('Contact has been unignored');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setIgnored($contact['id'], local_user(), true);
|
||||
$message = $this->t('Contact has been ignored');
|
||||
}
|
||||
|
||||
// @TODO: add $this->localRelationship->save($localRelationship);
|
||||
info($message);
|
||||
}
|
||||
|
||||
$this->baseUrl->redirect('contact/' . $contact['id']);
|
||||
}
|
||||
|
||||
$vcard_widget = Widget\VCard::getHTML($contact);
|
||||
$groups_widget = '';
|
||||
|
||||
|
@ -433,4 +480,20 @@ class Profile extends BaseModule
|
|||
|
||||
return $contact_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $contact_id Id of the contact with uid != 0
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function updateContactFromProbe(int $contact_id)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the entry in the contact table
|
||||
Contact::updateFromProbe($contact_id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue