mirror of https://gitlab.com/bashrc2/epicyon
Receiving quote requests
parent
dc760c565b
commit
ed49e3346a
|
@ -12,6 +12,7 @@ __module_group__ = "ActivityPub"
|
||||||
import os
|
import os
|
||||||
from flags import has_group_type
|
from flags import has_group_type
|
||||||
from flags import url_permitted
|
from flags import url_permitted
|
||||||
|
from utils import get_attributed_to
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import has_object_string_object
|
from utils import has_object_string_object
|
||||||
|
@ -86,6 +87,23 @@ def create_reject(federation_list: [],
|
||||||
http_prefix, object_json, 'Reject')
|
http_prefix, object_json, 'Reject')
|
||||||
|
|
||||||
|
|
||||||
|
def _reject_quote_request(message_json: {}) -> None:
|
||||||
|
""" Rejects a QuoteRequest
|
||||||
|
"""
|
||||||
|
actor = None
|
||||||
|
if message_json.get('actor'):
|
||||||
|
actor = message_json['actor']
|
||||||
|
elif message_json.get('instrument'):
|
||||||
|
if isinstance(message_json['instrument'], dict):
|
||||||
|
if message_json['instrument'].get('attributedTo'):
|
||||||
|
instrument_dict = message_json['instrument']
|
||||||
|
actor = get_attributed_to(instrument_dict['attributedTo'])
|
||||||
|
if not actor:
|
||||||
|
return
|
||||||
|
# TODO send back a Reject
|
||||||
|
print('REJECT: QuoteRequest from ' + actor)
|
||||||
|
|
||||||
|
|
||||||
def _accept_follow(base_dir: str, message_json: {},
|
def _accept_follow(base_dir: str, message_json: {},
|
||||||
federation_list: [], debug: bool,
|
federation_list: [], debug: bool,
|
||||||
curr_domain: str,
|
curr_domain: str,
|
||||||
|
@ -248,3 +266,12 @@ def receive_accept_reject(base_dir: str, domain: str, message_json: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Uh, ' + message_json['type'] + ', I guess')
|
print('DEBUG: Uh, ' + message_json['type'] + ', I guess')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def receive_quote_request(message_json: {}) -> bool:
|
||||||
|
"""Receives a QuoteRequest within the POST section of HTTPServer
|
||||||
|
"""
|
||||||
|
if message_json['type'] != 'QuoteRequest':
|
||||||
|
return False
|
||||||
|
_reject_quote_request(message_json)
|
||||||
|
return True
|
||||||
|
|
20
inbox.py
20
inbox.py
|
@ -78,6 +78,7 @@ from pprint import pprint
|
||||||
from cache import cache_svg_images
|
from cache import cache_svg_images
|
||||||
from cache import get_person_pub_key
|
from cache import get_person_pub_key
|
||||||
from acceptreject import receive_accept_reject
|
from acceptreject import receive_accept_reject
|
||||||
|
from acceptreject import receive_quote_request
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
from blocking import is_blocked_nickname
|
from blocking import is_blocked_nickname
|
||||||
from blocking import is_blocked_domain
|
from blocking import is_blocked_domain
|
||||||
|
@ -341,7 +342,8 @@ def inbox_permitted_message(domain: str, message_json: {},
|
||||||
return False
|
return False
|
||||||
|
|
||||||
always_allowed_types = (
|
always_allowed_types = (
|
||||||
'Follow', 'Join', 'Like', 'EmojiReact', 'Delete', 'Announce', 'Move'
|
'Follow', 'Join', 'Like', 'EmojiReact', 'Delete', 'Announce', 'Move',
|
||||||
|
'QuoteRequest'
|
||||||
)
|
)
|
||||||
if message_json['type'] not in always_allowed_types:
|
if message_json['type'] not in always_allowed_types:
|
||||||
if not has_object_dict(message_json):
|
if not has_object_dict(message_json):
|
||||||
|
@ -3638,6 +3640,22 @@ def run_inbox_queue(server,
|
||||||
inbox_start_time = time.time()
|
inbox_start_time = time.time()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if receive_quote_request(queue_json['post']):
|
||||||
|
print('Queue: QuoteRequest received from ' + key_id)
|
||||||
|
if os.path.isfile(queue_filename):
|
||||||
|
try:
|
||||||
|
os.remove(queue_filename)
|
||||||
|
except OSError:
|
||||||
|
print('EX: run_inbox_queue 7 unable to delete ' +
|
||||||
|
str(queue_filename))
|
||||||
|
if len(queue) > 0:
|
||||||
|
queue.pop(0)
|
||||||
|
fitness_performance(inbox_start_time, server.fitness,
|
||||||
|
'INBOX', 'receive_quote_request',
|
||||||
|
debug)
|
||||||
|
inbox_start_time = time.time()
|
||||||
|
continue
|
||||||
|
|
||||||
if receive_move_activity(curr_session, base_dir,
|
if receive_move_activity(curr_session, base_dir,
|
||||||
http_prefix, domain, port,
|
http_prefix, domain, port,
|
||||||
cached_webfingers,
|
cached_webfingers,
|
||||||
|
|
Loading…
Reference in New Issue