Make Vona a Python module
This commit is contained in:
28
vona/policy/__init__.py
Normal file
28
vona/policy/__init__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from flask import jsonify, Blueprint, request
|
||||
|
||||
policy = Blueprint("policy", __name__)
|
||||
|
||||
matrix_org = [
|
||||
"dendrite.matrix.org",
|
||||
"beta.matrix.org",
|
||||
"matrix.org",
|
||||
"element.io",
|
||||
"t2bot.io",
|
||||
"t2l.io"
|
||||
]
|
||||
|
||||
|
||||
@policy.route("/_matrix/policy/unstable/org.matrix.msc4284/event/<eventId>/check", methods=["POST"])
|
||||
@policy.route("/_matrix/policy/v1/event/<eventId>/check", methods=["POST"])
|
||||
async def check_event(eventId):
|
||||
if request.get_json()["origin"] in matrix_org:
|
||||
return jsonify({"recommendation": "spam"})
|
||||
|
||||
return jsonify({"recommendation": "ok"})
|
||||
|
||||
|
||||
@policy.route("/_matrix/policy/unstable/org.matrix.msc4284/sign", methods=["POST"])
|
||||
@policy.route("/_matrix/policy/v1/sign", methods=["POST"])
|
||||
async def sign_event():
|
||||
# NOTE: trolled
|
||||
return jsonify({})
|
||||
Reference in New Issue
Block a user