mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2025-03-04 00:33:58 +00:00
skip missing optional values in old config
This commit is contained in:
parent
760718b5dc
commit
f741017ef1
1 changed files with 17 additions and 13 deletions
|
@ -238,7 +238,7 @@ def cli_convert(ctx: click.Context, old_config: str) -> None:
|
||||||
with db.session(True) as conn:
|
with db.session(True) as conn:
|
||||||
conn.put_config("private-key", database["private-key"])
|
conn.put_config("private-key", database["private-key"])
|
||||||
conn.put_config("note", config["note"])
|
conn.put_config("note", config["note"])
|
||||||
conn.put_config("whitelist-enabled", config["whitelist_enabled"])
|
conn.put_config("whitelist-enabled", config.get("whitelist-enabled", False))
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
database["relay-list"].values(),
|
database["relay-list"].values(),
|
||||||
|
@ -246,25 +246,29 @@ def cli_convert(ctx: click.Context, old_config: str) -> None:
|
||||||
width = 0
|
width = 0
|
||||||
) as inboxes:
|
) as inboxes:
|
||||||
for inbox in inboxes:
|
for inbox in inboxes:
|
||||||
if inbox["software"] in {"akkoma", "pleroma"}:
|
if inbox.get("domain") is None:
|
||||||
actor = f"https://{inbox["domain"]}/relay"
|
inbox["domain"] = urlparse(inbox["inbox"]).netloc
|
||||||
|
|
||||||
elif inbox["software"] == "mastodon":
|
match inbox.get("software"):
|
||||||
actor = f"https://{inbox["domain"]}/actor"
|
case "akkoma" | "pleroma":
|
||||||
|
inbox["actor"] = f"https://{inbox["domain"]}/relay"
|
||||||
|
|
||||||
else:
|
case "mastodon":
|
||||||
actor = None
|
inbox["actor"] = f"https://{inbox["domain"]}/actor"
|
||||||
|
|
||||||
|
case _:
|
||||||
|
inbox["actor"] = None
|
||||||
|
|
||||||
conn.put_inbox(
|
conn.put_inbox(
|
||||||
inbox["domain"],
|
inbox["domain"],
|
||||||
inbox["inbox"],
|
inbox["inbox"],
|
||||||
actor = actor,
|
actor = inbox["actor"],
|
||||||
followid = inbox["followid"],
|
followid = inbox.get("followid"),
|
||||||
software = inbox["software"]
|
software = inbox.get("software")
|
||||||
)
|
)
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
config["blocked_software"],
|
config.get("blocked_software", []),
|
||||||
label = "Banned software".ljust(15),
|
label = "Banned software".ljust(15),
|
||||||
width = 0
|
width = 0
|
||||||
) as banned_software:
|
) as banned_software:
|
||||||
|
@ -276,7 +280,7 @@ def cli_convert(ctx: click.Context, old_config: str) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
config["blocked_instances"],
|
config.get("blocked_instances", []),
|
||||||
label = "Banned domains".ljust(15),
|
label = "Banned domains".ljust(15),
|
||||||
width = 0
|
width = 0
|
||||||
) as banned_software:
|
) as banned_software:
|
||||||
|
@ -285,7 +289,7 @@ def cli_convert(ctx: click.Context, old_config: str) -> None:
|
||||||
conn.put_domain_ban(domain)
|
conn.put_domain_ban(domain)
|
||||||
|
|
||||||
with click.progressbar(
|
with click.progressbar(
|
||||||
config["whitelist"],
|
config.get("whitelist", []),
|
||||||
label = "Whitelist".ljust(15),
|
label = "Whitelist".ljust(15),
|
||||||
width = 0
|
width = 0
|
||||||
) as whitelist:
|
) as whitelist:
|
||||||
|
|
Loading…
Reference in a new issue