From 7b65a10bd8b4eecaae4ba1710825f16cd25d6e6f Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Sat, 26 Nov 2022 23:08:13 -0700 Subject: [PATCH] Remove dead migration code that was fucking me over --- .../src/python/relay/database.py | 46 +++---------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/projects/activitypub_relay/src/python/relay/database.py b/projects/activitypub_relay/src/python/relay/database.py index 16cd2a0..7b05dea 100644 --- a/projects/activitypub_relay/src/python/relay/database.py +++ b/projects/activitypub_relay/src/python/relay/database.py @@ -45,54 +45,22 @@ class RelayDatabase(dict): self["private-key"] = self.PRIVKEY.exportKey("PEM").decode("utf-8") def load(self): - new_db = True + with self.config.db.open() as fd: + data = json.load(fd) - try: - with self.config.db.open() as fd: - data = json.load(fd) - - self["version"] = data.get("version", None) - self["private-key"] = data.get("private-key") - - if self["version"] == None: - self["version"] = 1 - - if "actorKeys" in data: - self["private-key"] = data["actorKeys"]["privateKey"] - - for item in data.get("relay-list", []): - domain = urlparse(item).hostname - self["relay-list"][domain] = {"inbox": item, "followid": None} - - else: - self["relay-list"] = data.get("relay-list", {}) - - for domain in self["relay-list"].keys(): - if self.config.is_banned(domain) or ( - self.config.whitelist_enabled - and not self.config.is_whitelisted(domain) - ): - self.del_inbox(domain) - - new_db = False - - except FileNotFoundError: - pass - - except json.decoder.JSONDecodeError as e: - if self.config.db.stat().st_size > 0: - raise e from None + self["version"] = data.get("version", 1) + self["private-key"] = data.get("private-key") + self["relay-list"] = data.get("relay-list", {}) + self["follow-requests"] = data.get("follow-requests") if not self.privkey: logging.info("No actor keys present, generating 4096-bit RSA keypair.") self.generate_key() + self.save() else: self.PRIVKEY = RSA.importKey(self.privkey) - self.save() - return not new_db - def save(self): with self.config.db.open("w") as fd: json.dump(self, fd, indent=4)