Skip to content

Commit

Permalink
finish relay main stroy
Browse files Browse the repository at this point in the history
  • Loading branch information
mattholy committed Jan 21, 2024
1 parent 00adc3d commit 4c4c31c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions service/backend/app/api/activitypub/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ async def relay(
activity: activitypub_model.Activity,
actor: dict = Depends(verify_actor)
):
if activity.context != 'https://www.w3.org/ns/activitystreams':
logger.warning('')
if 'https://www.w3.org/ns/activitystreams' not in activity.context:
logger.warning(f'Remote activity with context: {activity.context}')
raise HTTPException(
detail='Only a "https://www.w3.org/ns/activitystreams" request can be send to this endpoint',
status_code=401
Expand Down
8 changes: 6 additions & 2 deletions service/backend/app/utils/activitypub_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ def __init__(
self.actor, self.wr = get_wand_actor_and_wr()

if self.incoming_activity.type == 'Follow':
logger.info(
f'Receiving Follow request from {self.incoming_activity.actor} with body: {self.incoming_activity}'
)
self.accept()
else:
logger.warning(
f'Received request from {self.incoming_activity.actor} type as {self.incoming_activity.type}, not handled.')
logger.error(
f'Received request from {self.incoming_activity.actor} with type {self.incoming_activity.type}, not handled. Raw body is {self.incoming_activity}'
)

def sign(self, msg: activitypub_model.Activity) -> Tuple[str, dict, HTTPSignatureAuth]:
body = msg.model_dump_json(by_alias=True)
Expand Down
3 changes: 2 additions & 1 deletion service/backend/app/wand_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
host=os.environ.get('WD_REDIS_SERVER', '127.0.0.1'),
port=os.environ.get('WD_REDIS_PORT', '6379'),
password=os.environ.get('WD_REDIS_PWD', None),
max_connections=10
max_connections=10,
decode_responses=True
)
POSTGRES_POOL = create_engine(
f"postgresql://{os.environ.get('WD_POSTGRES_USER', 'wand')}:{os.environ.get('WD_POSTGRES_PWD', 'password_of_wand')}@{os.environ.get('WD_POSTGRES_SERVER', 'localhost')}:{os.environ.get('WD_POSTGRES_PORT', '5432')}/{os.environ.get('WD_POSTGRES_DBNAME', 'wand')}",
Expand Down

0 comments on commit 4c4c31c

Please sign in to comment.