prevent (un)follows from users
This commit is contained in:
parent
ed066d94af
commit
2c287d301f
|
@ -26,6 +26,11 @@ async def handle_relay(request, s):
|
||||||
logging.verbose(f'already relayed {request.message.objectid}')
|
logging.verbose(f'already relayed {request.message.objectid}')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if request.message.get('to') != ['https://www.w3.org/ns/activitystreams#Public']:
|
||||||
|
logging.verbose('Message was not public')
|
||||||
|
logging.verbose(request.message.get('to'))
|
||||||
|
return
|
||||||
|
|
||||||
message = Message.new_announce(
|
message = Message.new_announce(
|
||||||
host = request.config.host,
|
host = request.config.host,
|
||||||
object = request.message.objectid
|
object = request.message.objectid
|
||||||
|
@ -68,17 +73,17 @@ async def handle_follow(request, s):
|
||||||
## reject if the actor isn't whitelisted while the whiltelist is enabled
|
## reject if the actor isn't whitelisted while the whiltelist is enabled
|
||||||
if s.get_config('whitelist') and not s.get_whitelist(request.actor.domain):
|
if s.get_config('whitelist') and not s.get_whitelist(request.actor.domain):
|
||||||
logging.verbose(f'Rejected actor for not being in the whitelist: {request.actor.id}')
|
logging.verbose(f'Rejected actor for not being in the whitelist: {request.actor.id}')
|
||||||
accept = False
|
approve = False
|
||||||
|
|
||||||
## reject if software used by actor is banned
|
## reject if software used by actor is banned
|
||||||
if s.get_banned_software(software):
|
if s.get_ban('software', software):
|
||||||
logging.verbose(f'Rejected follow from actor for using specific software: actor={request.actor.id}, software={software}')
|
logging.verbose(f'Rejected follow from actor for using specific software: actor={request.actor.id}, software={software}')
|
||||||
accept = False
|
approve = False
|
||||||
|
|
||||||
## reject if the actor is not an instance actor
|
## reject if the actor is not an instance actor
|
||||||
if person_check(request.actor, software):
|
if person_check(request.actor, software):
|
||||||
logging.verbose(f'Non-application actor tried to follow: {request.actor.id}')
|
logging.verbose(f'Non-application actor tried to follow: {request.actor.id}')
|
||||||
accept = False
|
approve = False
|
||||||
|
|
||||||
if approve:
|
if approve:
|
||||||
if not request.instance:
|
if not request.instance:
|
||||||
|
@ -101,11 +106,12 @@ async def handle_follow(request, s):
|
||||||
followid = request.message.id
|
followid = request.message.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Doesn't seem to work now
|
||||||
request.app.push_message(
|
request.app.push_message(
|
||||||
request.actor.shared_inbox,
|
request.actor.inbox,
|
||||||
Message.new_response(
|
Message.new_response(
|
||||||
host = request.config.host,
|
host = request.config.host,
|
||||||
actor = request.actor.id,
|
actor = request.message.actorid,
|
||||||
followid = request.message.id,
|
followid = request.message.id,
|
||||||
accept = approve
|
accept = approve
|
||||||
)
|
)
|
||||||
|
@ -136,16 +142,27 @@ async def handle_undo(request, s):
|
||||||
if request.message.object.type != 'Follow':
|
if request.message.object.type != 'Follow':
|
||||||
return await handle_forward(request)
|
return await handle_forward(request)
|
||||||
|
|
||||||
s.delete('instances', id=request.instance.id)
|
instance_follow = request.instance.followid
|
||||||
|
message_follow = request.message.object.id
|
||||||
|
|
||||||
request.app.push_message(
|
if person_check(request.actor, request.instance.software):
|
||||||
request.actor.shared_inbox,
|
return logging.verbose(f'Non-application actor tried to unfollow: {request.actor.id}')
|
||||||
Message.new_unfollow(
|
|
||||||
host = request.config.host,
|
if instance_follow and instance_follow != message_follow:
|
||||||
actor = request.actor.id,
|
return logging.verbose(f'Followid does not match: {instance_follow}, {message_follow}')
|
||||||
follow = request.message
|
|
||||||
|
s.delete('instances', id=request.instance.id)
|
||||||
|
logging.verbose(f'Removed inbox: {request.instance.inbox}')
|
||||||
|
|
||||||
|
if request.instance.software != 'mastodon':
|
||||||
|
request.app.push_message(
|
||||||
|
request.actor.shared_inbox,
|
||||||
|
Message.new_unfollow(
|
||||||
|
host = request.config.host,
|
||||||
|
actor = request.actor.id,
|
||||||
|
follow = request.message
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
processors = {
|
processors = {
|
||||||
|
@ -166,12 +183,14 @@ async def run_processor(request):
|
||||||
new_data = {}
|
new_data = {}
|
||||||
|
|
||||||
if request.instance and not request.instance.software:
|
if request.instance and not request.instance.software:
|
||||||
|
logging.verbose(f'Fetching nodeinfo for instance: {request.instance.domain}')
|
||||||
nodeinfo = await request.app.client.fetch_nodeinfo(request.instance.domain)
|
nodeinfo = await request.app.client.fetch_nodeinfo(request.instance.domain)
|
||||||
|
|
||||||
if nodeinfo:
|
if nodeinfo:
|
||||||
new_data['software'] = nodeinfo.sw_name
|
new_data['software'] = nodeinfo.sw_name
|
||||||
|
|
||||||
if not request.instance.actor:
|
if not request.instance.actor:
|
||||||
|
logging.verbose(f'Fetching actor for instance: {request.instance.domain}')
|
||||||
new_data['actor'] = request.signature.keyid.split('#', 1)[0]
|
new_data['actor'] = request.signature.keyid.split('#', 1)[0]
|
||||||
|
|
||||||
if not request.instance.actor_data:
|
if not request.instance.actor_data:
|
||||||
|
|
Loading…
Reference in a new issue