29 lines
754 B
Python
29 lines
754 B
Python
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({})
|