fix: update_blacklist.py now uses pythonseer

pull/17/head
kthouky 2023-08-09 16:20:10 +02:00
parent 0665774fa3
commit 3a54a74443
5 changed files with 26 additions and 9 deletions

View File

@ -8,6 +8,10 @@ The currently running instance is on https://fediseer.com
See devlog: https://dbzer0.com/blog/overseer-a-fediverse-chain-of-trust/
# Libraries
We provide a Python library to interact programmatically with the fediseer api: [Pythonseer](https://github.com/db0/pythonseer)
# Badges
You can retrieve and display a badge for your fediverse domain by requesting a .svg for it on a special endpoint
@ -26,4 +30,4 @@ Example: [![](http://fediseer.com/api/v1/badges/endorsements/lemmy.dbzer0.com.sv
```markdown
[![](http://fediseer.com/api/v1/badges/endorsements/lemmy.dbzer0.com.svg)](https://fediseer.com/api/v1/endorsements/lemmy.dbzer0.com)`
```
```

View File

@ -1,2 +1,3 @@
requests
pythorhead
pythonseer

View File

@ -1,6 +1,8 @@
import requests
from pythorhead import Lemmy
from pythonseer import Fediseer
from pythonseer.types import FormatType
# Your own instance's domain
LEMMY_DOMAIN = "lemmy.dbzer0.com"
@ -13,8 +15,7 @@ MONTHLY_ACTIVITY_SUSPICION = 500
# Extra domains you can block. You can just delete the contents if you want to only block suspicious domains
blacklist = {
"truthsocial.com",
"exploding-heads.com",
"lemmygrad.ml",
"threads.net",
}
@ -22,11 +23,18 @@ lemmy = Lemmy(f"https://{LEMMY_DOMAIN}")
if lemmy.log_in(USERNAME, PASSWORD) is False:
raise Exception("Could not log in to lemmy")
fediseer = Fediseer()
print("Fetching suspicions")
sus = requests.get(f"https://fediseer.com/api/v1/instances?activity_suspicion={ACTIVITY_SUSPICION}&active_suspicion={MONTHLY_ACTIVITY_SUSPICION}&domains=true", timeout=5).json()
defed = blacklist | set(sus["domains"])
sus = fediseer.suspicions.get(
activity_suspicion=ACTIVITY_SUSPICION,
active_suspicion=MONTHLY_ACTIVITY_SUSPICION,
format=FormatType.LIST
)
print("Fetching censures")
censures = fediseer.censure.get_given(LEMMY_DOMAIN, FormatType.LIST)
defed = blacklist | set(censures["domains"]) | set(sus["domains"])
# I need to retrieve the site info because it seems if "RequireApplication" is set
# We need to always re-set the application_question.
# We need to always re-set the application_question.
# So we retrieve it from the existing site, to set the same value
site = lemmy.site.get()
application_question = None
@ -42,4 +50,4 @@ else:
ret = lemmy.site.edit(
blocked_instances=list(defed),
)
print("Edit Successful")
print("Edit Successful")

View File

@ -127,7 +127,7 @@ class WhitelistDomain(Resource):
requestor = user.username
instance_to_reset = database.find_instance_by_account(f"@{self.args.regenerate_key}@{domain}")
if instance != instance_to_reset and user.username != "fediseer":
raise e.BadRequest("Only other admins or the fediseer can request API key reset for others.")
raise e.BadRequest("Only other admins of the same instance or the fediseer can request API key reset for others.")
instance = instance_to_reset
user = database.find_user_by_account(f"@{self.args.regenerate_key}@{domain}")
new_key = activitypub_pm.pm_new_api_key(domain, self.args.regenerate_key, instance.software, requestor=requestor)

View File

@ -4,7 +4,7 @@ This is a [FOSS service](https://github.com/db0/fediseer) to help Fediverse inst
[What is Fediseer](https://dbzer0.com/blog/overseer-a-fediverse-chain-of-trust/) devlog
## Scope
## Scope
This Fediseer is focused around anti-spam verification. We make no judgement on the content of the guaranteed communities other than they have been verified to not be fake spam instances and are making a good effort to block spam accounts.
@ -14,6 +14,10 @@ However using the endorsement system, you can create a further customized whitel
[Full API Documentation](/api/)
## Libraries
* [Pythonseer](https://github.com/db0/pythonseer) (Python)
## Community
* [Fediverse Community](https://lemmy.dbzer0.com/c/fediseer)