Merge pull request #9098 from annando/issue-9094

Issue 9094: Prevent announces via DFRN
This commit is contained in:
Tobias Diekershoff 2020-08-30 13:51:13 +02:00 committed by GitHub
commit a5be6f9276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -43,6 +43,7 @@ use Friendica\Model\Post\Category;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Model\Verb;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -256,10 +257,11 @@ class DFRN
FROM `item` USE INDEX (`uid_wall_changed`) $sql_post_table FROM `item` USE INDEX (`uid_wall_changed`) $sql_post_table
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`wall` AND `item`.`changed` > '%s' WHERE `item`.`uid` = %d AND `item`.`wall` AND `item`.`changed` > '%s'
AND `item`.`visible` $sql_extra AND `vid` != %d AND `item`.`visible` $sql_extra
ORDER BY `item`.`parent` ".$sort.", `item`.`received` ASC LIMIT 0, 300", ORDER BY `item`.`parent` ".$sort.", `item`.`received` ASC LIMIT 0, 300",
intval($owner_id), intval($owner_id),
DBA::escape($check_date), DBA::escape($check_date),
Verb::getID(Activity::ANNOUNCE),
DBA::escape($sort) DBA::escape($sort)
); );

View file

@ -685,17 +685,17 @@ class Notifier
return false; return false;
} }
// We deliver reshares via AP whenever possible
if (ActivityPub\Transmitter::isAnnounce($item)) {
return true;
}
// For the time being we always deliver forum post via DFRN if possible // For the time being we always deliver forum post via DFRN if possible
// This can be removed possible at the end of 2020 when hopefully most system can process AP forum posts // This can be removed possible at the end of 2020 when hopefully most system can process AP forum posts
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) { if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
return false; return false;
} }
// We deliver reshares via AP whenever possible
if (ActivityPub\Transmitter::isAnnounce($item)) {
return true;
}
// Skip DFRN when the item will be (forcefully) delivered via AP // Skip DFRN when the item will be (forcefully) delivered via AP
if (DI::config()->get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) { if (DI::config()->get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
return true; return true;