Issue 10926: Transmit pending events to accepted contacts
This commit is contained in:
parent
0b312ae9b3
commit
cc6192df02
2 changed files with 45 additions and 8 deletions
|
@ -27,6 +27,7 @@ use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
|
@ -46,6 +47,7 @@ use Friendica\Protocol\Relay;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\JsonLD;
|
use Friendica\Util\JsonLD;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
use Friendica\Worker\Delivery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityPub Processor Protocol class
|
* ActivityPub Processor Protocol class
|
||||||
|
@ -480,8 +482,8 @@ class Processor
|
||||||
/**
|
/**
|
||||||
* Fetch the Uri-Id of a post for the "featured" collection
|
* Fetch the Uri-Id of a post for the "featured" collection
|
||||||
*
|
*
|
||||||
* @param array $activity
|
* @param array $activity
|
||||||
* @return null|int
|
* @return null|int
|
||||||
*/
|
*/
|
||||||
private static function getUriIdForFeaturedCollection(array $activity)
|
private static function getUriIdForFeaturedCollection(array $activity)
|
||||||
{
|
{
|
||||||
|
@ -519,7 +521,7 @@ class Processor
|
||||||
/**
|
/**
|
||||||
* Add a post to the "Featured" collection
|
* Add a post to the "Featured" collection
|
||||||
*
|
*
|
||||||
* @param array $activity
|
* @param array $activity
|
||||||
*/
|
*/
|
||||||
public static function addToFeaturedCollection(array $activity)
|
public static function addToFeaturedCollection(array $activity)
|
||||||
{
|
{
|
||||||
|
@ -536,7 +538,7 @@ class Processor
|
||||||
/**
|
/**
|
||||||
* Remove a post to the "Featured" collection
|
* Remove a post to the "Featured" collection
|
||||||
*
|
*
|
||||||
* @param array $activity
|
* @param array $activity
|
||||||
*/
|
*/
|
||||||
public static function removeFromFeaturedCollection(array $activity)
|
public static function removeFromFeaturedCollection(array $activity)
|
||||||
{
|
{
|
||||||
|
@ -1025,8 +1027,8 @@ class Processor
|
||||||
/**
|
/**
|
||||||
* Fetch featured posts from a contact with the given url
|
* Fetch featured posts from a contact with the given url
|
||||||
*
|
*
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function fetchFeaturedPosts(string $url)
|
public static function fetchFeaturedPosts(string $url)
|
||||||
{
|
{
|
||||||
|
@ -1277,6 +1279,10 @@ class Processor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($result && DI::config()->get('system', 'transmit_pending_events') && ($owner['contact-type'] == Contact::TYPE_COMMUNITY)) {
|
||||||
|
self::transmitPendingEvents($cid, $owner['uid']);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
Contact::update(['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||||
}
|
}
|
||||||
|
@ -1284,6 +1290,33 @@ class Processor
|
||||||
Logger::notice('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
|
Logger::notice('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmit pending events to the new follower
|
||||||
|
*
|
||||||
|
* @param integer $cid
|
||||||
|
* @param integer $uid
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private static function transmitPendingEvents(int $cid, int $uid)
|
||||||
|
{
|
||||||
|
$account = DBA::selectFirst('account-user-view', ['ap-inbox', 'ap-sharedinbox'], ['id' => $cid]);
|
||||||
|
$inbox = $account['ap-sharedinbox'] ?: $account['ap-inbox'];
|
||||||
|
|
||||||
|
$events = DBA::select('event', ['id'], ["`uid` = ? AND `start` > ? AND `type` != ?", $uid, DateTimeFormat::utcNow(), 'birthday']);
|
||||||
|
while ($event = DBA::fetch($events)) {
|
||||||
|
$post = Post::selectFirst(['id', 'uri-id', 'created'], ['event-id' => $event['id']]);
|
||||||
|
if (empty($post)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (DI::config()->get('system', 'bulk_delivery')) {
|
||||||
|
Post\Delivery::add($post['uri-id'], $uid, $inbox, $post['created'], Delivery::POST, [$cid]);
|
||||||
|
Worker::add(PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
|
||||||
|
} else {
|
||||||
|
Worker::add(PRIORITY_HIGH, 'APDelivery', Delivery::POST, $post['id'], $inbox, $uid, [$cid], $post['uri-id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the given profile
|
* Update the given profile
|
||||||
*
|
*
|
||||||
|
@ -1342,7 +1375,7 @@ class Processor
|
||||||
|
|
||||||
$uid = User::getIdForURL($activity['object_id']);
|
$uid = User::getIdForURL($activity['object_id']);
|
||||||
if (empty($uid)) {
|
if (empty($uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact\User::setIsBlocked($cid, $uid, true);
|
Contact\User::setIsBlocked($cid, $uid, true);
|
||||||
|
@ -1365,7 +1398,7 @@ class Processor
|
||||||
|
|
||||||
$uid = User::getIdForURL($activity['object_object']);
|
$uid = User::getIdForURL($activity['object_object']);
|
||||||
if (empty($uid)) {
|
if (empty($uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact\User::setIsBlocked($cid, $uid, false);
|
Contact\User::setIsBlocked($cid, $uid, false);
|
||||||
|
|
|
@ -557,6 +557,10 @@ return [
|
||||||
// Maximum number of posts that a user can send per month with the API. 0 to disable monthly throttling.
|
// Maximum number of posts that a user can send per month with the API. 0 to disable monthly throttling.
|
||||||
'throttle_limit_month' => 0,
|
'throttle_limit_month' => 0,
|
||||||
|
|
||||||
|
// transmit_pending_events (Boolean)
|
||||||
|
// Transmit pending events upon accepted contact request for forums
|
||||||
|
'transmit_pending_events' => false,
|
||||||
|
|
||||||
// update_active_contacts (Boolean)
|
// update_active_contacts (Boolean)
|
||||||
// When activated, only public contacts will be activated regularly that are used for example in items or tags.
|
// When activated, only public contacts will be activated regularly that are used for example in items or tags.
|
||||||
'update_active_contacts' => false,
|
'update_active_contacts' => false,
|
||||||
|
|
Loading…
Reference in a new issue