1 # Fedi API Block - An aggregator for fetching blocking data from fediverse nodes
2 # Copyright (C) 2023 Free Software Foundation
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published
6 # by the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 from fba.helpers import tidyup
20 from fba.helpers import version
22 logging.basicConfig(level=logging.INFO)
23 logger = logging.getLogger(__name__)
25 def alias(software: str) -> str:
26 logger.debug("software='%s'- CALLED!", software)
27 if not isinstance(software, str) and software is not None:
28 raise ValueError(f"software[]='{type(software)}' is not type 'str'")
30 logger.debug("software='%s'- BEFORE!", software)
31 software = tidyup.domain(software)
32 logger.debug("software='%s'- AFTER!", software)
34 if software in ["akkoma", "rebased", "akkounfucked", "ched"]:
35 logger.debug("Setting pleroma: software='%s'", software)
37 elif software in ["hometown", "ecko"] or "mastodon" in software:
38 logger.debug("Setting mastodon: software='%s'", software)
40 elif software in ["slipfox calckey", "calckey", "groundpolis", "foundkey", "cherrypick", "meisskey", "magnetar", "keybump", "dolphin", "calckey social"]:
41 logger.debug("Setting misskey: software='%s'", software)
43 elif software in ["runtube.re", "islameye"]:
44 logger.debug("Setting peertube: software='%s'", software)
46 elif software in ["nextcloud social", "nextcloudpi", "storage share"]:
47 logger.debug("Setting nextcloud: software='%s'", software)
48 software = "nextcloud"
49 elif software.find("/") > 0:
50 logger.warning("Spliting of slash: software='%s'", software)
51 software = software.split("/")[-1]
52 elif software.find("|") > 0:
53 logger.warning("Spliting of pipe: software='%s'", software)
54 software = software.split("|")[0]
55 elif "powered by" in software:
56 logger.debug("software='%s' has 'powered by' in it", software)
57 software = version.strip_powered_by(software)
59 if isinstance(software, str) and " by " in software:
60 logger.debug("software='%s' has ' by ' in it", software)
61 software = version.strip_until(software, " by ")
62 elif isinstance(software, str) and " - " in software:
63 logger.debug("software='%s' has ' - ' in it", software)
64 software = version.strip_until(software, " - ")
65 elif isinstance(software, str) and " see " in software:
66 logger.debug("software='%s' has ' see ' in it", software)
67 software = version.strip_until(software, " see ")
69 logger.debug("software['%s']='%s'", type(software), software)
71 logger.warning("tidyup.domain() left no software name behind: software='%s'", software)
74 logger.debug("software='%s' is being cleaned up further ...")
75 software = software.rstrip("!")
77 logger.debug("software[%s]='%s' - EXIT!", type(software), software)