From b5672cee7ef536da1286510b318ec7b73da7e46d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 17 Oct 2023 16:41:31 +0200 Subject: [PATCH] WIP Signed-off-by: Thomas Citharel --- js/package.json | 6 +- js/src/App.vue | 11 +- js/src/apollo/utils.ts | 5 + .../components/Account/ActorAutoComplete.vue | 77 + js/src/components/Account/ActorCard.vue | 4 + .../components/Account/ActorInline.story.vue | 2 +- js/src/components/Account/ActorInline.vue | 8 +- .../Account/PopoverActorCard.story.vue | 2 +- .../Conversations/ConversationListItem.vue | 160 ++ .../Conversations/EventConversations.vue | 69 + .../Conversations/NewConversation.vue | 137 ++ .../Discussion/DiscussionComment.vue | 94 +- js/src/components/Editor/Mention.ts | 27 +- .../Event/FullAddressAutoComplete.vue | 75 +- js/src/components/Group/GroupCard.story.vue | 4 +- js/src/components/Local/CloseEvents.vue | 4 +- js/src/components/NavBar.vue | 86 +- .../Participation/NewPrivateMessage.vue | 109 + js/src/components/Report/ReportModal.vue | 4 +- js/src/components/TextEditor.vue | 8 +- js/src/composition/apollo/members.ts | 46 + js/src/composition/apollo/tags.ts | 22 +- js/src/graphql/comment.ts | 1 + js/src/graphql/conversations.ts | 166 ++ js/src/graphql/event.ts | 46 + js/src/graphql/report.ts | 6 + js/src/graphql/search.ts | 28 + js/src/graphql/user.ts | 18 + js/src/i18n/en_US.json | 17 +- js/src/i18n/fr_FR.json | 209 +- js/src/router/conversation.ts | 33 + js/src/router/index.ts | 2 + js/src/router/name.ts | 2 + js/src/types/actor/person.model.ts | 4 + js/src/types/comment.model.ts | 2 + js/src/types/conversation.ts | 17 + js/src/types/current-user.model.ts | 2 + js/src/types/event.model.ts | 4 + js/src/utils/auth.ts | 20 +- js/src/utils/identity.ts | 35 +- js/src/views/Admin/InstanceView.vue | 2 +- .../Conversations/ConversationListView.vue | 94 + .../views/Conversations/ConversationView.vue | 527 +++++ js/src/views/Event/ParticipantsView.vue | 4 + js/src/views/Group/GroupView.vue | 38 +- js/src/views/Moderation/ReportView.vue | 101 +- js/src/views/Settings/NotificationsView.vue | 14 +- js/src/views/User/LoginView.vue | 2 + js/src/views/User/ProviderValidation.vue | 25 +- js/src/vue-apollo.ts | 29 +- js/yarn.lock | 1881 +++++++++-------- lib/federation/activity_pub/actions/create.ex | 37 +- lib/federation/activity_pub/audience.ex | 5 + lib/federation/activity_pub/fetcher.ex | 2 +- lib/federation/activity_pub/transmogrifier.ex | 32 +- .../activity_pub/types/conversation.ex | 207 ++ lib/federation/activity_pub/utils.ex | 6 +- .../activity_stream/converter/comment.ex | 41 +- .../activity_stream/converter/conversation.ex | 68 + lib/federation/web_finger/web_finger.ex | 5 +- lib/graphql/api/comments.ex | 19 +- lib/graphql/api/events.ex | 8 +- lib/graphql/api/search.ex | 6 +- lib/graphql/authorization.ex | 2 + lib/graphql/resolvers/conversation.ex | 269 +++ lib/graphql/resolvers/participant.ex | 57 + lib/graphql/schema.ex | 4 + lib/graphql/schema/actors/person.ex | 32 +- lib/graphql/schema/conversation.ex | 132 ++ lib/graphql/schema/discussions/comment.ex | 2 + lib/graphql/schema/event.ex | 14 +- lib/graphql/schema/events/participant.ex | 29 + lib/graphql/schema/user.ex | 15 +- lib/mobilizon/activities/activities.ex | 18 +- lib/mobilizon/actors/actor.ex | 6 + lib/mobilizon/conversations/conversation.ex | 57 + .../conversations/conversation_participant.ex | 40 + .../conversations/conversation_view.ex | 22 + lib/mobilizon/conversations/conversations.ex | 344 +++ lib/mobilizon/discussions/comment.ex | 12 +- lib/mobilizon/discussions/discussions.ex | 28 +- lib/mobilizon/events/event.ex | 2 + lib/mobilizon/events/events.ex | 15 + lib/mobilizon/mentions/mention.ex | 4 +- lib/mobilizon/reports/reports.ex | 9 +- lib/service/activity/conversation.ex | 90 + lib/service/activity/renderer/conversation.ex | 73 + lib/service/activity/renderer/renderer.ex | 26 +- lib/service/notifier/email.ex | 6 + lib/service/notifier/filter.ex | 4 + lib/service/notifier/push.ex | 1 + .../workers/legacy_notifier_builder.ex | 18 +- lib/web/auth/context.ex | 2 +- lib/web/cache/activity_pub.ex | 20 +- lib/web/cache/cache.ex | 5 + lib/web/channels/graphql_socket.ex | 17 +- lib/web/controllers/page_controller.ex | 6 + lib/web/router.ex | 2 + .../_conversation_activity_item.html.heex | 20 + .../_conversation_activity_item.text.eex | 11 + .../email/email_direct_activity.html.heex | 4 + .../email/email_direct_activity.text.eex | 2 +- ...20230920071502_add_actor_conversations.exs | 37 + .../transmogrifier/create_test.exs | 107 + test/graphql/resolvers/conversation_test.exs | 78 + test/mobilizon/conversations_test.exs | 86 + test/service/activity/conversation_test.exs | 70 + test/support/factory.ex | 16 + 108 files changed, 5221 insertions(+), 1318 deletions(-) create mode 100644 js/src/components/Account/ActorAutoComplete.vue create mode 100644 js/src/components/Conversations/ConversationListItem.vue create mode 100644 js/src/components/Conversations/EventConversations.vue create mode 100644 js/src/components/Conversations/NewConversation.vue create mode 100644 js/src/components/Participation/NewPrivateMessage.vue create mode 100644 js/src/composition/apollo/members.ts create mode 100644 js/src/graphql/conversations.ts create mode 100644 js/src/router/conversation.ts create mode 100644 js/src/types/conversation.ts create mode 100644 js/src/views/Conversations/ConversationListView.vue create mode 100644 js/src/views/Conversations/ConversationView.vue create mode 100644 lib/federation/activity_pub/types/conversation.ex create mode 100644 lib/federation/activity_stream/converter/conversation.ex create mode 100644 lib/graphql/resolvers/conversation.ex create mode 100644 lib/graphql/schema/conversation.ex create mode 100644 lib/mobilizon/conversations/conversation.ex create mode 100644 lib/mobilizon/conversations/conversation_participant.ex create mode 100644 lib/mobilizon/conversations/conversation_view.ex create mode 100644 lib/mobilizon/conversations/conversations.ex create mode 100644 lib/service/activity/conversation.ex create mode 100644 lib/service/activity/renderer/conversation.ex create mode 100644 lib/web/templates/email/activity/_conversation_activity_item.html.heex create mode 100644 lib/web/templates/email/activity/_conversation_activity_item.text.eex create mode 100644 priv/repo/migrations/20230920071502_add_actor_conversations.exs create mode 100644 test/federation/activity_pub/transmogrifier/create_test.exs create mode 100644 test/graphql/resolvers/conversation_test.exs create mode 100644 test/mobilizon/conversations_test.exs create mode 100644 test/service/activity/conversation_test.exs diff --git a/js/package.json b/js/package.json index 662bcfa0d..b9d10a365 100644 --- a/js/package.json +++ b/js/package.json @@ -27,7 +27,7 @@ "@absinthe/socket": "^0.2.1", "@absinthe/socket-apollo-link": "^0.2.1", "@apollo/client": "^3.3.16", - "@oruga-ui/oruga-next": "^0.6.0", + "@oruga-ui/oruga-next": "^0.7.0", "@sentry/tracing": "^7.1", "@sentry/vue": "^7.1", "@tiptap/core": "^2.0.0-beta.41", @@ -114,7 +114,7 @@ "@vitest/coverage-v8": "^0.34.1", "@vitest/ui": "^0.34.1", "@vue/eslint-config-prettier": "^8.0.0", - "@vue/eslint-config-typescript": "^11.0.0", + "@vue/eslint-config-typescript": "^12.0.0", "@vue/test-utils": "^2.0.2", "eslint": "^8.21.0", "eslint-config-prettier": "^9.0.0", @@ -131,7 +131,7 @@ "prettier-eslint": "^15.0.1", "rollup-plugin-visualizer": "^5.7.1", "sass": "^1.34.1", - "typescript": "~5.1.3", + "typescript": "~5.2.2", "vite": "^4.0.4", "vite-plugin-pwa": "^0.16.4", "vitest": "^0.34.1", diff --git a/js/src/App.vue b/js/src/App.vue index 6f9ca4315..846962227 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -138,6 +138,7 @@ interval.value = window.setInterval(async () => { }, 60000) as unknown as number; onBeforeMount(async () => { + console.debug("Before mount App"); if (initializeCurrentUser()) { try { await initializeCurrentActor(); @@ -150,6 +151,8 @@ onBeforeMount(async () => { userAlreadyActivated: "true", }, }); + } else { + throw err; } } } @@ -202,20 +205,24 @@ onUnmounted(() => { const { mutate: updateCurrentUser } = useMutation(UPDATE_CURRENT_USER_CLIENT); const initializeCurrentUser = () => { + console.debug("Initializing current user"); const userId = localStorage.getItem(AUTH_USER_ID); const userEmail = localStorage.getItem(AUTH_USER_EMAIL); const accessToken = localStorage.getItem(AUTH_ACCESS_TOKEN); const role = localStorage.getItem(AUTH_USER_ROLE); if (userId && userEmail && accessToken && role) { - updateCurrentUser({ + const userData = { id: userId, email: userEmail, isLoggedIn: true, role, - }); + }; + updateCurrentUser(userData); + console.debug("Initialized current user", userData); return true; } + console.debug("Failed to initialize current user"); return false; }; diff --git a/js/src/apollo/utils.ts b/js/src/apollo/utils.ts index 0ac78d0ee..3d025527b 100644 --- a/js/src/apollo/utils.ts +++ b/js/src/apollo/utils.ts @@ -45,6 +45,11 @@ export const typePolicies: TypePolicies = { comments: paginatedLimitPagination(), }, }, + Conversation: { + fields: { + comments: paginatedLimitPagination(), + }, + }, Group: { fields: { organizedEvents: paginatedLimitPagination([ diff --git a/js/src/components/Account/ActorAutoComplete.vue b/js/src/components/Account/ActorAutoComplete.vue new file mode 100644 index 000000000..b95c37055 --- /dev/null +++ b/js/src/components/Account/ActorAutoComplete.vue @@ -0,0 +1,77 @@ + + + diff --git a/js/src/components/Account/ActorCard.vue b/js/src/components/Account/ActorCard.vue index 7d93e6fab..c4d49710d 100644 --- a/js/src/components/Account/ActorCard.vue +++ b/js/src/components/Account/ActorCard.vue @@ -39,6 +39,9 @@ v-html="actor.summary" /> +
+ +
+
+ + + +
+ + {{ t("There's no conversations yet") }} + + + + + diff --git a/js/src/components/Conversations/NewConversation.vue b/js/src/components/Conversations/NewConversation.vue new file mode 100644 index 000000000..4895dea28 --- /dev/null +++ b/js/src/components/Conversations/NewConversation.vue @@ -0,0 +1,137 @@ + + + diff --git a/js/src/components/Discussion/DiscussionComment.vue b/js/src/components/Discussion/DiscussionComment.vue index 5339615ba..a7d75bae8 100644 --- a/js/src/components/Discussion/DiscussionComment.vue +++ b/js/src/components/Discussion/DiscussionComment.vue @@ -1,5 +1,7 @@