fix: update_blacklist.py now uses pythonseer
parent
0665774fa3
commit
3a54a74443
|
@ -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/
|
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
|
# Badges
|
||||||
|
|
||||||
You can retrieve and display a badge for your fediverse domain by requesting a .svg for it on a special endpoint
|
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
|
```markdown
|
||||||
[![](http://fediseer.com/api/v1/badges/endorsements/lemmy.dbzer0.com.svg)](https://fediseer.com/api/v1/endorsements/lemmy.dbzer0.com)`
|
[![](http://fediseer.com/api/v1/badges/endorsements/lemmy.dbzer0.com.svg)](https://fediseer.com/api/v1/endorsements/lemmy.dbzer0.com)`
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
requests
|
requests
|
||||||
pythorhead
|
pythorhead
|
||||||
|
pythonseer
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from pythorhead import Lemmy
|
from pythorhead import Lemmy
|
||||||
|
from pythonseer import Fediseer
|
||||||
|
from pythonseer.types import FormatType
|
||||||
|
|
||||||
# Your own instance's domain
|
# Your own instance's domain
|
||||||
LEMMY_DOMAIN = "lemmy.dbzer0.com"
|
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
|
# Extra domains you can block. You can just delete the contents if you want to only block suspicious domains
|
||||||
blacklist = {
|
blacklist = {
|
||||||
"truthsocial.com",
|
"truthsocial.com",
|
||||||
"exploding-heads.com",
|
"threads.net",
|
||||||
"lemmygrad.ml",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,11 +23,18 @@ lemmy = Lemmy(f"https://{LEMMY_DOMAIN}")
|
||||||
if lemmy.log_in(USERNAME, PASSWORD) is False:
|
if lemmy.log_in(USERNAME, PASSWORD) is False:
|
||||||
raise Exception("Could not log in to lemmy")
|
raise Exception("Could not log in to lemmy")
|
||||||
|
|
||||||
|
fediseer = Fediseer()
|
||||||
print("Fetching suspicions")
|
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()
|
sus = fediseer.suspicions.get(
|
||||||
defed = blacklist | set(sus["domains"])
|
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
|
# 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
|
# So we retrieve it from the existing site, to set the same value
|
||||||
site = lemmy.site.get()
|
site = lemmy.site.get()
|
||||||
application_question = None
|
application_question = None
|
||||||
|
@ -42,4 +50,4 @@ else:
|
||||||
ret = lemmy.site.edit(
|
ret = lemmy.site.edit(
|
||||||
blocked_instances=list(defed),
|
blocked_instances=list(defed),
|
||||||
)
|
)
|
||||||
print("Edit Successful")
|
print("Edit Successful")
|
||||||
|
|
|
@ -127,7 +127,7 @@ class WhitelistDomain(Resource):
|
||||||
requestor = user.username
|
requestor = user.username
|
||||||
instance_to_reset = database.find_instance_by_account(f"@{self.args.regenerate_key}@{domain}")
|
instance_to_reset = database.find_instance_by_account(f"@{self.args.regenerate_key}@{domain}")
|
||||||
if instance != instance_to_reset and user.username != "fediseer":
|
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
|
instance = instance_to_reset
|
||||||
user = database.find_user_by_account(f"@{self.args.regenerate_key}@{domain}")
|
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)
|
new_key = activitypub_pm.pm_new_api_key(domain, self.args.regenerate_key, instance.software, requestor=requestor)
|
||||||
|
|
|
@ -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
|
[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.
|
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/)
|
[Full API Documentation](/api/)
|
||||||
|
|
||||||
|
## Libraries
|
||||||
|
|
||||||
|
* [Pythonseer](https://github.com/db0/pythonseer) (Python)
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
* [Fediverse Community](https://lemmy.dbzer0.com/c/fediseer)
|
* [Fediverse Community](https://lemmy.dbzer0.com/c/fediseer)
|
||||||
|
|
Loading…
Reference in New Issue