X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FRelay.php;h=d98fda46d7620289bae4fe4eb1218b6b829689e3;hb=b04809ced4577d75be4316a34e65f2e813c86756;hp=f89dc3999930d48e47ee83044183a2210333454e;hpb=bc58cb9b94e2553fa02a874b6c52ebe50e487833;p=friendica.git diff --git a/src/Protocol/Relay.php b/src/Protocol/Relay.php index f89dc39999..d98fda46d7 100644 --- a/src/Protocol/Relay.php +++ b/src/Protocol/Relay.php @@ -37,9 +37,15 @@ use Friendica\Util\Strings; /** * Base class for relay handling + * @see https://github.com/jaywink/social-relay + * @see https://wiki.diasporafoundation.org/Relay_servers_for_public_posts */ class Relay { + const SCOPE_NONE = ''; + const SCOPE_ALL = 'all'; + const SCOPE_TAGS = 'tags'; + /** * Check if a post is wanted * @@ -55,7 +61,7 @@ class Relay $scope = $config->get('system', 'relay_scope'); - if ($scope == SR_SCOPE_NONE) { + if ($scope == self::SCOPE_NONE) { Logger::info('Server does not accept relay posts - rejected', ['network' => $network, 'url' => $url]); return false; } @@ -74,10 +80,10 @@ class Relay $userTags = []; $denyTags = []; - if ($scope == SR_SCOPE_TAGS) { + if ($scope == self::SCOPE_TAGS) { $server_tags = $config->get('system', 'relay_server_tags'); $tagitems = explode(',', mb_strtolower($server_tags)); - foreach ($tagitems AS $tag) { + foreach ($tagitems as $tag) { $systemTags[] = trim($tag, '# '); } @@ -90,7 +96,7 @@ class Relay $deny_tags = $config->get('system', 'relay_deny_tags'); $tagitems = explode(',', mb_strtolower($deny_tags)); - foreach ($tagitems AS $tag) { + foreach ($tagitems as $tag) { $tag = trim($tag, '# '); $denyTags[] = $tag; } @@ -119,7 +125,7 @@ class Relay } } - if ($scope == SR_SCOPE_ALL) { + if ($scope == self::SCOPE_ALL) { Logger::info('Server accept all posts - accepted', ['network' => $network, 'url' => $url]); return true; } @@ -166,7 +172,7 @@ class Relay $fields['updated'] = DateTimeFormat::utcNow(); Logger::info('Update relay contact', ['server' => $gserver['url'], 'id' => $old['id'], 'fields' => $fields]); - DBA::update('contact', $fields, ['id' => $old['id']], $old); + Contact::update($fields, ['id' => $old['id']], $old); } else { $default = ['created' => DateTimeFormat::utcNow(), 'name' => 'relay', 'nick' => 'relay', 'url' => $gserver['url'],