Pending contacts part 2: Fix contact deletion / added cron job for repairs
This commit is contained in:
parent
91b0f0465f
commit
f185f6fd3d
|
@ -12,9 +12,11 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\NotificationsManager;
|
use Friendica\Core\NotificationsManager;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Module\Login;
|
use Friendica\Module\Login;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
function notifications_post(App $a)
|
function notifications_post(App $a)
|
||||||
{
|
{
|
||||||
|
@ -46,13 +48,14 @@ function notifications_post(App $a)
|
||||||
|
|
||||||
if ($_POST['submit'] == L10n::t('Discard')) {
|
if ($_POST['submit'] == L10n::t('Discard')) {
|
||||||
DBA::delete('intro', ['id' => $intro_id]);
|
DBA::delete('intro', ['id' => $intro_id]);
|
||||||
|
|
||||||
if (!$fid) {
|
if (!$fid) {
|
||||||
// The check for blocked and pending is in case the friendship was already approved
|
// The check for pending is in case the friendship was already approved
|
||||||
// and we just want to get rid of the now pointless notification
|
// and we just want to get rid of the pending contact
|
||||||
$condition = ['id' => $contact_id, 'uid' => local_user(),
|
$condition = ['id' => $contact_id, 'uid' => local_user(),
|
||||||
'self' => false, 'blocked' => true, 'pending' => true];
|
'self' => false, 'pending' => true, 'rel' => Contact::FOLLOWER];
|
||||||
DBA::delete('contact', $condition);
|
if (DBA::exists('contact', $condition)) {
|
||||||
|
Contact::remove($contact_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$a->internalRedirect('notifications/intros');
|
$a->internalRedirect('notifications/intros');
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Friendica\Network\Probe;
|
||||||
use Friendica\Protocol\PortableContact;
|
use Friendica\Protocol\PortableContact;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
class CronJobs
|
class CronJobs
|
||||||
{
|
{
|
||||||
|
@ -301,6 +302,15 @@ class CronJobs
|
||||||
/// - remove sign entries without item
|
/// - remove sign entries without item
|
||||||
/// - remove children when parent got lost
|
/// - remove children when parent got lost
|
||||||
/// - set contact-id in item when not present
|
/// - set contact-id in item when not present
|
||||||
|
|
||||||
|
// Add intro entries for pending contacts
|
||||||
|
$pending_contacts = DBA::p("SELECT `uid`, `id`, `url`, `network`, `created` FROM `contact`
|
||||||
|
WHERE `pending` AND `rel` = ? AND NOT EXISTS (SELECT `id` FROM `intro` WHERE `contact-id` = `contact`.`id`)", 0); //Contact::FOLLOWER);
|
||||||
|
while ($contact = DBA::fetch($pending_contacts)) {
|
||||||
|
DBA::insert('intro', ['uid' => $contact['uid'], 'contact-id' => $contact['id'], 'blocked' => false,
|
||||||
|
'hash' => Strings::getRandomHex(), 'datetime' => $contact['created']]);
|
||||||
|
}
|
||||||
|
DBA::close($pending_contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue