From 02dbab3d17dd4495b30d6caf523d90ce3491dc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Thu, 29 Aug 2019 15:29:17 +0100 Subject: [PATCH] add config toggle for bidirectional-mention-edges --- CHANGELOG.md | 3 +-- backend/config/config.exs | 1 + backend/lib/backend/scheduler.ex | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a619da0..3baf1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add support for logging in via an ActivityPub direct message to the instance admin. +- Added option to hide edges between instances if there are only mentions in one direction (off by default). ### Changed - Edges are no longer shown between instances where one blocks the other (based on the federation list in nodeinfo). -- Edges are only shown between timeline-crawlable instance types (Mastodon, Pleroma, Gab, Misskey, and GNU Social) - if there's a mention in each direction. This is to avoid edges between instances where one blocks the other. ### Deprecated diff --git a/backend/config/config.exs b/backend/config/config.exs index 09836b8..eb1ceae 100644 --- a/backend/config/config.exs +++ b/backend/config/config.exs @@ -68,6 +68,7 @@ config :backend, :crawler, "pleroma.online" ], user_agent: "fediverse.space crawler", + require_bidirectional_mentions: false, admin_phone: System.get_env("ADMIN_PHONE"), twilio_phone: System.get_env("TWILIO_PHONE"), admin_email: System.get_env("ADMIN_EMAIL") diff --git a/backend/lib/backend/scheduler.ex b/backend/lib/backend/scheduler.ex index c58817c..2496803 100644 --- a/backend/lib/backend/scheduler.ex +++ b/backend/lib/backend/scheduler.ex @@ -308,7 +308,7 @@ defmodule Backend.Scheduler do # Returns true if # * there's no federation block in either direction between the two instances - # * there are mentions in both directions + # * there are mentions in both directions (if enabled in configuration) defp is_eligible_interaction?( %{ source_domain: source, @@ -322,8 +322,11 @@ defmodule Backend.Scheduler do ) do mentions_were_seen = mention_count > 0 + # If :require_bidirectional_edges is set to `true` in the config, then an edge is only created if both instances + # have mentioned each other opposite_mention_exists = - if is_timeline_crawlable_type?(source_type) and is_timeline_crawlable_type?(target_type) do + if get_config(:require_bidirectional_mentions) and is_timeline_crawlable_type?(source_type) and + is_timeline_crawlable_type?(target_type) do Map.has_key?(mention_directions, {target, source}) and Map.get(mention_directions, {target, source}) > 0 else