1
0
Fork 0

Better support for "audience" / simplified Lemmy processing

This commit is contained in:
Michael 2023-06-15 22:04:28 +00:00
commit 6d911a8f39
9 changed files with 133 additions and 103 deletions

View file

@ -119,6 +119,11 @@ class APContact
return [];
}
if (!Network::isValidHttpUrl($url) && !filter_var($url, FILTER_VALIDATE_EMAIL)) {
Logger::info('Invalid URL', ['url' => $url]);
return [];
}
$fetched_contact = [];
if (empty($update)) {

View file

@ -2773,7 +2773,7 @@ class Contact
}
$update = false;
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?: $ret['alias']);
$guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?? $ret['alias']);
// make sure to not overwrite existing values with blank entries except some technical fields
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];

View file

@ -2210,8 +2210,6 @@ class Item
*/
private static function tagDeliver(int $uid, int $item_id): bool
{
$mention = false;
$owner = User::getOwnerDataById($uid);
if (!DBA::isResult($owner)) {
Logger::warning('User not found, quitting here.', ['uid' => $uid]);
@ -3664,6 +3662,7 @@ class Item
/**
* Does the given uri-id belongs to a post that is sent as starting post to a group?
* This does not apply to posts that are sent only in parallel to a group.
*
* @param int $uri_id
*
@ -3671,7 +3670,13 @@ class Item
*/
public static function isGroupPost(int $uri_id): bool
{
foreach (Tag::getByURIId($uri_id, [Tag::EXCLUSIVE_MENTION]) as $tag) {
if (Post::exists(['private' => Item::PUBLIC, 'uri-id' => $uri_id])) {
return false;
}
foreach (Tag::getByURIId($uri_id, [Tag::EXCLUSIVE_MENTION, Tag::AUDIENCE]) as $tag) {
// @todo Possibly check for a public audience in the future, see https://socialhub.activitypub.rocks/t/fep-1b12-group-federation/2724
// and https://codeberg.org/fediverse/fep/src/branch/main/feps/fep-1b12.md
if (DBA::exists('contact', ['uid' => 0, 'nurl' => Strings::normaliseLink($tag['url']), 'contact-type' => Contact::TYPE_COMMUNITY])) {
return true;
}

View file

@ -487,7 +487,7 @@ class Tag
*
* @return boolean
*/
public static function isMentioned(int $uriId, string $url, array $type = [self::MENTION, self::EXCLUSIVE_MENTION]): bool
public static function isMentioned(int $uriId, string $url, array $type = [self::MENTION, self::EXCLUSIVE_MENTION, self::AUDIENCE]): bool
{
$tags = self::getByURIId($uriId, $type);
foreach ($tags as $tag) {