Skip to content

Commit

Permalink
fix(notifications): associate the corresponding action (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
CapooL authored Nov 26, 2023
1 parent 80bd4ff commit 3bb7f2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions hinghwa-dict-backend/article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def post(self, request) -> JsonResponse:
article.author = user
article.save()
content = f"我创建了文章(id={article.id}),请及时去审核"
sendNotification(article.author, None, content, title="【提醒】文章待审核")
sendNotification(
article.author, None, content, title="【提醒】文章待审核", action_object=article
)
return JsonResponse({"id": article.id}, status=200)

# AT0202 文章内容批量获取
Expand Down Expand Up @@ -162,7 +164,9 @@ def put(self, request, id) -> JsonResponse:
article.visibility = False
article.save()
content = f"我修改了文章(id={article.id}),请及时去审核"
sendNotification(article.author, None, content, title="【提醒】文章待审核")
sendNotification(
article.author, None, content, title="【提醒】文章待审核", action_object=article
)
return JsonResponse({}, status=200)

# AT0102 删除文章
Expand Down Expand Up @@ -197,7 +201,7 @@ def put(self, request, id) -> JsonResponse:
None,
[article.author],
content=content,
target=article,
action_object=article,
title="【通知】文章审核结果",
)
article.save()
Expand Down
1 change: 1 addition & 0 deletions hinghwa-dict-backend/word/application/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,6 @@ def put(self, request, id) -> JsonResponse:
content,
target=application,
title=title,
action_object=application.word,
)
return JsonResponse({"word": feedback}, status=200)
6 changes: 3 additions & 3 deletions hinghwa-dict-backend/word/pronunciation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def delete(request, id):
get_request_user(request),
[pronunciation.contributor],
f"您的语音(id={pronunciation.id}) 已被删除,理由是:\n\t{message}",
target=pronunciation,
action_object=pronunciation,
title=f"【通知】语音{pronunciation.word.word}被删除",
)

Expand Down Expand Up @@ -376,7 +376,7 @@ def post(request, id):
verifier,
[contributor],
content=content + reason,
target=pronunciation,
action_object=pronunciation,
title=f"【通知】语音({pronunciation.word.word})审核结果",
)
return JsonResponse(transaction_info, status=200)
Expand Down Expand Up @@ -406,7 +406,7 @@ def put(request, id):
verifier,
[contributor],
content=content + f",理由是:{message}。",
target=pronunciation,
action_object=pronunciation,
title=f"【通知】语音({pronunciation.word.word})审核结果变更",
)
return JsonResponse(transaction_info, status=200)
Expand Down

0 comments on commit 3bb7f2d

Please sign in to comment.