forked from forks/microblog.pub
Tweak the UI (make it use the new user API) and bugfixes
This commit is contained in:
parent
ef5b32a33c
commit
7db48800a2
5 changed files with 20 additions and 42 deletions
|
@ -182,7 +182,7 @@ class BaseActivity(object):
|
||||||
valid_kwargs = {}
|
valid_kwargs = {}
|
||||||
for k, v in kwargs.items():
|
for k, v in kwargs.items():
|
||||||
if v is None:
|
if v is None:
|
||||||
break
|
continue
|
||||||
valid_kwargs[k] = v
|
valid_kwargs[k] = v
|
||||||
self._data.update(**valid_kwargs)
|
self._data.update(**valid_kwargs)
|
||||||
|
|
||||||
|
|
49
app.py
49
app.py
|
@ -75,13 +75,15 @@ app.config.update(
|
||||||
)
|
)
|
||||||
csrf = CSRFProtect(app)
|
csrf = CSRFProtect(app)
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Hook up Flask logging with gunicorn
|
# Hook up Flask logging with gunicorn
|
||||||
gunicorn_logger = logging.getLogger('gunicorn.error')
|
# gunicorn_logger = logging.getLogger('gunicorn.error')
|
||||||
root_logger = logging.getLogger()
|
# root_logger = logging.getLogger()
|
||||||
root_logger.handlers = gunicorn_logger.handlers
|
# root_logger.handlers = gunicorn_logger.handlers
|
||||||
root_logger.setLevel(gunicorn_logger.level)
|
# root_logger.setLevel(gunicorn_logger.level)
|
||||||
|
|
||||||
SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey)
|
SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey)
|
||||||
|
|
||||||
|
@ -460,6 +462,7 @@ def nodeinfo():
|
||||||
'usage': {'users': {'total': 1}, 'localPosts': DB.outbox.count()},
|
'usage': {'users': {'total': 1}, 'localPosts': DB.outbox.count()},
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'sourceCode': 'https://github.com/tsileo/microblog.pub',
|
'sourceCode': 'https://github.com/tsileo/microblog.pub',
|
||||||
|
'nodeName': f'@{USERNAME}@{DOMAIN}',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -482,11 +485,11 @@ def wellknown_nodeinfo():
|
||||||
def wellknown_webfinger():
|
def wellknown_webfinger():
|
||||||
"""Enable WebFinger support, required for Mastodon interopability."""
|
"""Enable WebFinger support, required for Mastodon interopability."""
|
||||||
resource = request.args.get('resource')
|
resource = request.args.get('resource')
|
||||||
if resource not in ["acct:"+USERNAME+"@"+DOMAIN, ID]:
|
if resource not in [f'acct:{USERNAME}@{DOMAIN}', ID]:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
out = {
|
out = {
|
||||||
"subject": "acct:"+USERNAME+"@"+DOMAIN,
|
"subject": f'acct:{USERNAME}@{DOMAIN}',
|
||||||
"aliases": [ID],
|
"aliases": [ID],
|
||||||
"links": [
|
"links": [
|
||||||
{"rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": BASE_URL},
|
{"rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": BASE_URL},
|
||||||
|
@ -690,36 +693,9 @@ def admin():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/new', methods=['GET', 'POST'])
|
@app.route('/new', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def new():
|
def new():
|
||||||
if request.method == 'POST':
|
|
||||||
reply = None
|
|
||||||
if request.form.get('reply'):
|
|
||||||
reply = activitypub.parse_activity(OBJECT_SERVICE.get(request.form.get('reply')))
|
|
||||||
source = request.form.get('content')
|
|
||||||
content, tags = parse_markdown(source)
|
|
||||||
to = request.form.get('to')
|
|
||||||
cc = [ID+'/followers']
|
|
||||||
if reply:
|
|
||||||
cc.append(reply.attributedTo)
|
|
||||||
for tag in tags:
|
|
||||||
if tag['type'] == 'Mention':
|
|
||||||
cc.append(tag['href'])
|
|
||||||
|
|
||||||
note = activitypub.Note(
|
|
||||||
cc=cc,
|
|
||||||
to=[to if to else config.AS_PUBLIC],
|
|
||||||
content=content, # TODO(tsileo): handle markdown
|
|
||||||
tag=tags,
|
|
||||||
source={'mediaType': 'text/markdown', 'content': source},
|
|
||||||
inReplyTo=reply.id if reply else None
|
|
||||||
)
|
|
||||||
|
|
||||||
create = note.build_create()
|
|
||||||
print(create.to_dict())
|
|
||||||
create.post_to_outbox()
|
|
||||||
|
|
||||||
reply_id = None
|
reply_id = None
|
||||||
content = ''
|
content = ''
|
||||||
if request.args.get('reply'):
|
if request.args.get('reply'):
|
||||||
|
@ -804,8 +780,9 @@ def _user_api_get_note(from_outbox: bool = False):
|
||||||
|
|
||||||
|
|
||||||
def _user_api_response(**kwargs):
|
def _user_api_response(**kwargs):
|
||||||
if request.args.get('redirect'):
|
_redirect = _user_api_arg('redirect')
|
||||||
return redirect(request.args.get('redirect'))
|
if _redirect:
|
||||||
|
return redirect(_redirect)
|
||||||
|
|
||||||
resp = flask_jsonify(**kwargs)
|
resp = flask_jsonify(**kwargs)
|
||||||
resp.status_code = 201
|
resp.status_code = 201
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version: '2'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
celery:
|
celery:
|
||||||
image: microblogpub:latest
|
image: microblogpub:latest
|
||||||
|
@ -7,7 +7,7 @@ services:
|
||||||
- rabbitmq
|
- rabbitmq
|
||||||
command: 'celery worker -l info -A tasks'
|
command: 'celery worker -l info -A tasks'
|
||||||
environment:
|
environment:
|
||||||
- MICROBLOGPUB_AMQP_BORKER=pyamqp://guest@rabbitmq//
|
- MICROBLOGPUB_AMQP_BROKER=pyamqp://guest@rabbitmq//
|
||||||
- MICROBLOGPUB_MONGODB_HOST=mongo:27017
|
- MICROBLOGPUB_MONGODB_HOST=mongo:27017
|
||||||
mongo:
|
mongo:
|
||||||
image: "mongo:latest"
|
image: "mongo:latest"
|
||||||
|
|
1
tasks.py
1
tasks.py
|
@ -19,7 +19,6 @@ from utils.linked_data_sig import generate_signature
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
app = Celery('tasks', broker=os.getenv('MICROBLOGPUB_AMQP_BROKER', 'pyamqp://guest@localhost//'))
|
app = Celery('tasks', broker=os.getenv('MICROBLOGPUB_AMQP_BROKER', 'pyamqp://guest@localhost//'))
|
||||||
# app = Celery('tasks', broker='pyamqp://guest@rabbitmq//')
|
|
||||||
SigAuth = HTTPSigAuth(ID+'#main-key', KEY.privkey)
|
SigAuth = HTTPSigAuth(ID+'#main-key', KEY.privkey)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
<div id="container">
|
<div id="container">
|
||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
<div id="new">
|
<div id="new">
|
||||||
<form action="" method="POST">
|
<form action="/api/new_note" method="POST">
|
||||||
|
<input type="hidden" name="redirect" value="/">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
{% if reply %}<input type="hidden" name="reply" value="{{reply}}">{% endif %}
|
||||||
<textarea name="content" rows="10" cols="50" autofocus="autofocus">{{ content }}</textarea>
|
<textarea name="content" rows="10" cols="50" autofocus="autofocus">{{ content }}</textarea>
|
||||||
<div style="margin-top:20px;">
|
<div style="margin-top:20px;">
|
||||||
|
|
Loading…
Reference in a new issue