kopia lustrzana https://github.com/snarfed/bridgy-fed
misc hub setup, testing live
rodzic
f85ab9ef41
commit
318ba554d5
|
@ -1,3 +1,5 @@
|
||||||
|
*_token
|
||||||
|
*_jwt
|
||||||
.coverage
|
.coverage
|
||||||
/.well-known/acme-challenge/
|
/.well-known/acme-challenge/
|
||||||
datastore.dat*
|
datastore.dat*
|
||||||
|
|
|
@ -29,7 +29,6 @@ from common import (
|
||||||
USER_AGENT,
|
USER_AGENT,
|
||||||
)
|
)
|
||||||
import flask_app
|
import flask_app
|
||||||
import hub
|
|
||||||
from models import Object, PROTOCOLS, Target, User
|
from models import Object, PROTOCOLS, Target, User
|
||||||
from protocol import Protocol
|
from protocol import Protocol
|
||||||
|
|
||||||
|
@ -299,7 +298,7 @@ class ATProto(User, Protocol):
|
||||||
return bluesky.from_as1(obj.as1), {'Content-Type': 'application/json'}
|
return bluesky.from_as1(obj.as1), {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
|
||||||
@hub.app.get('/_ah/queue/atproto-poll-notifs')
|
# URL route is registered in hub.py
|
||||||
def poll_notifications():
|
def poll_notifications():
|
||||||
"""Fetches and enqueueus new activities from the AppView for our users.
|
"""Fetches and enqueueus new activities from the AppView for our users.
|
||||||
|
|
||||||
|
|
20
hub.py
20
hub.py
|
@ -4,6 +4,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from threading import Timer
|
||||||
|
|
||||||
import arroba.server
|
import arroba.server
|
||||||
from arroba.datastore_storage import DatastoreStorage
|
from arroba.datastore_storage import DatastoreStorage
|
||||||
|
@ -11,6 +12,7 @@ from arroba.util import service_jwt
|
||||||
from arroba import xrpc_sync
|
from arroba import xrpc_sync
|
||||||
from flask import Flask, request
|
from flask import Flask, request
|
||||||
import google.cloud.logging
|
import google.cloud.logging
|
||||||
|
import lexrpc.client
|
||||||
import lexrpc.server
|
import lexrpc.server
|
||||||
import lexrpc.flask_server
|
import lexrpc.flask_server
|
||||||
from oauth_dropins.webutil import (
|
from oauth_dropins.webutil import (
|
||||||
|
@ -59,10 +61,13 @@ def health_check():
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# XRPC server
|
# XRPC server, other URL routes
|
||||||
#
|
#
|
||||||
lexrpc.flask_server.init_flask(arroba.server.server, app)
|
lexrpc.flask_server.init_flask(arroba.server.server, app)
|
||||||
|
|
||||||
|
app.add_url_rule('/_ah/queue/atproto-poll-notifs',
|
||||||
|
view_func=atproto.poll_notifications,
|
||||||
|
methods=['POST'])
|
||||||
|
|
||||||
@app.post('/_ah/queue/atproto-commit')
|
@app.post('/_ah/queue/atproto-commit')
|
||||||
def atproto_commit():
|
def atproto_commit():
|
||||||
|
@ -72,3 +77,16 @@ def atproto_commit():
|
||||||
"""
|
"""
|
||||||
xrpc_sync.send_new_commits()
|
xrpc_sync.send_new_commits()
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
||||||
|
|
||||||
|
# send requestCrawl to BGS
|
||||||
|
# delay because we're not up and serving XRPCs at this point yet. not sure why not.
|
||||||
|
if 'GAE_INSTANCE' in os.environ: # prod
|
||||||
|
def request_crawl():
|
||||||
|
bgs = lexrpc.client.Client(f'https://{os.environ["BGS_HOST"]}',
|
||||||
|
headers={'User-Agent': USER_AGENT})
|
||||||
|
resp = bgs.com.atproto.sync.requestCrawl({'hostname': os.environ['PDS_HOST']})
|
||||||
|
logger.info(resp)
|
||||||
|
|
||||||
|
Timer(15, request_crawl).start()
|
||||||
|
logger.info('Will send BGS requestCrawl in 15s')
|
||||||
|
|
8
hub.yaml
8
hub.yaml
|
@ -9,10 +9,12 @@ env: flex
|
||||||
runtime: python
|
runtime: python
|
||||||
runtime_config:
|
runtime_config:
|
||||||
operating_system: ubuntu22
|
operating_system: ubuntu22
|
||||||
runtime_version: "3.10"
|
runtime_version: "3.11"
|
||||||
|
|
||||||
network:
|
# can't do this because Bluesky BGS needs to be able to connect externally over
|
||||||
instance_ip_mode: internal
|
# websocket for subscribeRepos
|
||||||
|
# network:
|
||||||
|
# instance_ip_mode: internal
|
||||||
|
|
||||||
# need only one instance so that new commits can be delivered to subscribeRepos
|
# need only one instance so that new commits can be delivered to subscribeRepos
|
||||||
# subscribers in memory
|
# subscribers in memory
|
||||||
|
|
|
@ -478,7 +478,7 @@ class ATProtoTest(TestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
client = app.test_client()
|
client = app.test_client()
|
||||||
resp = client.get('/_ah/queue/atproto-poll-notifs')
|
resp = client.post('/_ah/queue/atproto-poll-notifs')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
|
||||||
expected_list_notifs = call(
|
expected_list_notifs = call(
|
||||||
|
|
Ładowanie…
Reference in New Issue