From 725600da8f92a223f10a4a9a1ff874c5eff1534f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Wed, 6 Mar 2019 22:55:47 +0900 Subject: [PATCH] Enhance poll (#4409) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Start working * WIP: Enhance poll * Fix bug * Use `name` in voting note refs: https://github.com/syuilo/misskey/issues/4407#issuecomment-469057296 * Fix style * Refactor Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> * WIP: Update poll editor * Fix bug * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r * Fix typo * Better design * Beautify poll editor * Fix UI * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r262217524 * Add debug logging * Fix bug * Log deliver * fix vote * Update ap/show refs: https://github.com/syuilo/misskey/pull/4409#issuecomment-469652386 * Update poll view * Maybe done * Add tests * Fix path * Fix test * Fix test * Fix test * Fix expired check on AP * Update note.ts * Squashed commit of the following: commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Squashed commit of the following: commit ae696b1ed12568b27c27367ac5a77035c97c9a1f Author: mei23 Date: Wed Mar 6 06:11:17 2019 +0900 fix commit b735e354e7a9e64534c4f17d04ecbc65fb735c21 Author: mei23 Date: Wed Mar 6 06:08:33 2019 +0900 messge commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Fix typo * Update vote.ts * Update vote.ts * Update poll-editor.vue * Update tslint.json * Fix layout * Add note * Fix bug * Rename text key * 投票するときに投稿として扱わないように (#4425) * wip * 形式をMastodonと合わせた * Bye something * Use - instead of ~ * Redundancy * Yes! * Refactor * Use moment instead of Date * Fix indent * Refactor if (votes.length) は必要なさそう * Clean up * Bye Date * Clean * Fix timer is not displayed * Fix リモートから無期限pollにvoteできない * Fix vote actor --- locales/de-DE.yml | 2 +- locales/en-US.yml | 2 +- locales/es-ES.yml | 2 +- locales/fr-FR.yml | 2 +- locales/ja-JP.yml | 21 ++++- locales/ja-KS.yml | 2 +- locales/ko-KR.yml | 2 +- locales/nl-NL.yml | 2 +- locales/pl-PL.yml | 2 +- locales/zh-CN.yml | 2 +- .../common/views/components/poll-editor.vue | 90 +++++++++++++++++- .../app/common/views/components/poll.vue | 49 +++++++--- .../app/common/views/components/ui/input.vue | 3 + .../desktop/views/components/post-form.vue | 7 +- .../app/mobile/views/components/post-form.vue | 5 +- src/models/note.ts | 26 +++++- src/models/poll-vote.ts | 3 +- src/queue/processors/http/deliver.ts | 5 + .../activitypub/kernel/announce/index.ts | 4 + src/remote/activitypub/kernel/create/index.ts | 6 +- src/remote/activitypub/kernel/delete/index.ts | 4 + src/remote/activitypub/models/note.ts | 49 +++++++--- src/remote/activitypub/models/question.ts | 41 ++++++--- src/remote/activitypub/renderer/note.ts | 29 +++++- src/remote/activitypub/renderer/question.ts | 18 ++-- src/remote/activitypub/renderer/vote.ts | 22 +++++ src/remote/activitypub/type.ts | 4 + src/server/api/endpoints/ap/show.ts | 2 +- src/server/api/endpoints/notes/create.ts | 24 ++++- src/server/api/endpoints/notes/polls/vote.ts | 44 ++++++--- src/services/note/create.ts | 17 ++++ src/services/note/polls/vote.ts | 7 +- test/api.ts | 91 +++++++++++++++++++ tslint.json | 2 + 34 files changed, 505 insertions(+), 86 deletions(-) create mode 100644 src/remote/activitypub/renderer/vote.ts diff --git a/locales/de-DE.yml b/locales/de-DE.yml index 353ff56fd..807c68be6 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -270,7 +270,7 @@ common/views/components/note-menu.vue: common/views/components/poll.vue: vote-to: "Stimme für '{}'" vote-count: "{} Stimmen" - total-users: "{} Nutzer haben abgestimmt" + total-votes: "{} Nutzer haben abgestimmt" vote: "Abstimmen" show-result: "Zeige Ergebnis" voted: "Abgestimmt" diff --git a/locales/en-US.yml b/locales/en-US.yml index e6c081ff0..a00fc8dcf 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -489,7 +489,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "Vote for '{}'" vote-count: "{} votes" - total-users: "{} users voted" + total-votes: "{} users voted" vote: "Vote" show-result: "Show results" voted: "Voted" diff --git a/locales/es-ES.yml b/locales/es-ES.yml index 0dd1ea773..3d3975284 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -303,7 +303,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "'{}' para votar" vote-count: "{} votos" - total-users: "{} usuario(s) que ha(n) votado" + total-votes: "{} usuario(s) que ha(n) votado" vote: "Vota" show-result: "Mostrar resultados" voted: "Votado" diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index 8ce34dfd8..542684d28 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -383,7 +383,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "Voter pour '{}'" vote-count: "{} votes" - total-users: "{} utilisateur·rice·s ont voté" + total-votes: "{} utilisateur·rice·s ont voté" vote: "Vote" show-result: "Montrer les résultats" voted: "Voté" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 2a63d142a..83441af8f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -527,10 +527,15 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "「{}」に投票する" vote-count: "{}票" - total-users: "{}人が投票" + total-votes: "計{}票" vote: "投票する" show-result: "結果を見る" voted: "投票済み" + closed: "終了済み" + remaining-days: "終了まであと{d}日{h}時間" + remaining-hours: "終了まであと{h}時間{m}分" + remaining-minutes: "終了まであと{m}分{s}秒" + remaining-seconds: "終了まであと{s}秒" common/views/components/poll-editor.vue: no-only-one-choice: "アンケートには、選択肢が最低2つ必要です" @@ -538,6 +543,20 @@ common/views/components/poll-editor.vue: remove: "この選択肢を削除" add: "+選択肢を追加" destroy: "アンケートを破棄" + multiple: "複数回答可" + expiration: "期限" + infinite: "無期限" + at: "日時指定" + after: "経過指定" + no-more: "これ以上追加できません" + deadline-date: "期日" + deadline-time: "時間" + interval: "期間" + unit: "単位" + second: "秒" + minute: "分" + hour: "時間" + day: "日" common/views/components/reaction-picker.vue: choose-reaction: "リアクションを選択" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index dbf8629c9..214c4657f 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -344,7 +344,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "「{}」に投票や!" vote-count: "{}票" - total-users: "{}人が投票" + total-votes: "{}人が投票" vote: "投票するで" show-result: "結果を見よか" voted: "投票済みや" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 6627e664f..b976945e4 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -489,7 +489,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "\"{}\"에 투표하기" vote-count: "{}표" - total-users: "{}명이 투표" + total-votes: "{}명이 투표" vote: "투표하기" show-result: "결과 보기" voted: "투표함" diff --git a/locales/nl-NL.yml b/locales/nl-NL.yml index bd64792f6..c39a4d66a 100644 --- a/locales/nl-NL.yml +++ b/locales/nl-NL.yml @@ -131,7 +131,7 @@ common/views/components/note-menu.vue: common/views/components/poll.vue: vote-to: "Stemmen op '{}'" vote-count: "{} stemmen" - total-users: "{} gebruikers hebben gestemd" + total-votes: "{} gebruikers hebben gestemd" vote: "Stemmen" show-result: "Resultaten tonen" voted: "Gestemd" diff --git a/locales/pl-PL.yml b/locales/pl-PL.yml index af1a80133..affe08d0d 100644 --- a/locales/pl-PL.yml +++ b/locales/pl-PL.yml @@ -346,7 +346,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "Zagłosuj na '{}'" vote-count: "{} głosów" - total-users: "{} głosujących" + total-votes: "{} głosujących" vote: "Zagłosuj" show-result: "Pokaż wyniki" voted: "Zagłosowano" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 9f04b51d3..9a199b1c1 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -489,7 +489,7 @@ common/views/components/user-menu.vue: common/views/components/poll.vue: vote-to: "为\"{}\"投票" vote-count: "{}票" - total-users: "{} 人投票" + total-votes: "{} 人投票" vote: "投票" show-result: "显示结果" voted: "已投票" diff --git a/src/client/app/common/views/components/poll-editor.vue b/src/client/app/common/views/components/poll-editor.vue index d6f30f380..88d7311f5 100644 --- a/src/client/app/common/views/components/poll-editor.vue +++ b/src/client/app/common/views/components/poll-editor.vue @@ -12,21 +12,54 @@ + +
+ {{ $t('multiple') }} +
+ + + + + + +
+ {{ $t('deadline-date') }} + {{ $t('deadline-time') }} +
+
+ {{ $t('interval') }} + + + + + + + +
+
+