manual sync mastodon follow info
This commit is contained in:
parent
8d8c69343c
commit
71755183c0
3 changed files with 33 additions and 2 deletions
|
@ -160,6 +160,28 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-section-wrapper">
|
||||
<div class="tools-section-wrapper">
|
||||
<div class="import-panel">
|
||||
<h5 class="import-panel__label">{% trans 'Mastodon/Pleroma社交关系数据' %}</h5>
|
||||
<div class="import-panel__body">
|
||||
<form action="{% url 'users:sync_mastodon' %}" method="POST" enctype="multipart/form-data" >
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="import-panel__button" value="{% trans '同步' %}" id="uploadBtn" /> 上次更新时间 {{ user.mastodon_last_refresh }}
|
||||
<div>
|
||||
为了正确展示短评和评论,NeoDB会缓存你的关注、屏蔽和静音列表。如果你刚刚更新过帐户的上锁状态、增减过关注、静音或屏蔽,希望立即生效,可以点击这里立刻更新;这类信息也会每天自动同步。
|
||||
</div>
|
||||
</form>
|
||||
<!-- <form action="{% url 'users:export_reviews' %}" method="POST" enctype="multipart/form-data" >
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="import-panel__button" value="{% trans '导出评论' %}" id="uploadBtn"
|
||||
>
|
||||
</form> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid__aside grid__aside--reverse-order grid__aside--tablet-column">
|
||||
|
|
|
@ -9,6 +9,7 @@ urlpatterns = [
|
|||
path('data/', data, name='data'),
|
||||
path('data/export_reviews', export_reviews, name='export_reviews'),
|
||||
path('data/export_marks', export_marks, name='export_marks'),
|
||||
path('data/sync_mastodon', sync_mastodon, name='sync_mastodon'),
|
||||
path('preferences/', preferences, name='preferences'),
|
||||
path('logout/', logout, name='logout'),
|
||||
path('delete/', delete, name='delete'),
|
||||
|
|
|
@ -838,8 +838,9 @@ def manage_report(request):
|
|||
|
||||
# Utils
|
||||
########################################
|
||||
def refresh_mastodon_data_task(user, token):
|
||||
user.mastodon_token = token
|
||||
def refresh_mastodon_data_task(user, token=None):
|
||||
if token:
|
||||
user.mastodon_token = token
|
||||
if user.refresh_mastodon_data():
|
||||
user.save()
|
||||
print(f"{user} mastodon data refreshed")
|
||||
|
@ -901,3 +902,10 @@ def export_marks(request):
|
|||
response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
|
||||
response['Content-Disposition'] = 'attachment;filename="marks.xlsx"'
|
||||
return response
|
||||
|
||||
|
||||
@login_required
|
||||
def sync_mastodon(request):
|
||||
if request.method == 'POST':
|
||||
django_rq.get_queue('mastodon').enqueue(refresh_mastodon_data_task, request.user)
|
||||
return redirect(reverse("users:data"))
|
||||
|
|
Loading…
Add table
Reference in a new issue