Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add severed_relationships notification type #3134

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/notification/NotificationCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import RelationshipSeveranceCard from '~/components/notification/RelationshipSeveranceCard.vue'

// Add undocumented 'annual_report' type introduced in v4.3
// ref. https://github.com/mastodon/documentation/issues/1211#:~:text=api/v1/annual_reports
Expand All @@ -25,13 +26,15 @@
'update',
'status',
'annual_report',
'severed_relationships',
]

// well-known emoji reactions types Elk does not support yet
const unsupportedEmojiReactionTypes = ['pleroma:emoji_reaction', 'reaction']

if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotificationTypes.includes(notification.type)) {
console.warn(`[DEV] ${t('notification.missing_type')} '${notification.type}' (notification.id: ${notification.id})`)
console.warn(notification)
}
</script>

Expand Down Expand Up @@ -134,5 +137,13 @@
</div>
</div>
</template>
<template v-else-if="notification.type === 'severed_relationships'">
<div flex p4 items-center>
<div i-material-symbols:heart-broken-outline-rounded text-xl me-4 color-red />
<div class="content-rich">
<RelationshipSeveranceCard :event="notification.event!" />

Check failure on line 144 in components/notification/NotificationCard.vue

View workflow job for this annotation

GitHub Actions / ci

Property 'event' does not exist on type 'Notification'.
</div>
</div>
</template>
</article>
</template>
29 changes: 29 additions & 0 deletions components/notification/RelationshipSeveranceCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup lang="ts">
const { event } = defineProps<{
event: object
}>()

const { t } = useI18n()

const type = event.type

Check failure on line 8 in components/notification/RelationshipSeveranceCard.vue

View workflow job for this annotation

GitHub Actions / ci

Property 'type' does not exist on type 'object'.
const from = currentServer
const target = event.targetName

Check failure on line 10 in components/notification/RelationshipSeveranceCard.vue

View workflow job for this annotation

GitHub Actions / ci

Property 'targetName' does not exist on type 'object'.
const followers = event.followersCount

Check failure on line 11 in components/notification/RelationshipSeveranceCard.vue

View workflow job for this annotation

GitHub Actions / ci

Property 'followersCount' does not exist on type 'object'.
const following = event.followingCount

Check failure on line 12 in components/notification/RelationshipSeveranceCard.vue

View workflow job for this annotation

GitHub Actions / ci

Property 'followingCount' does not exist on type 'object'.
</script>

<template>
<p v-if="type === 'account_suspension'">
{{ t('notification.relationship_severance.account_suspension', [from, target]) }}
</p>
<p v-else-if="type === 'domain_block'">
{{ t('notification.relationship_severance.domain_block', { from, target, followers, n: following }) }}
</p>
<p v-else-if="type === 'user_domain_block'">
{{ t("notification.relationship_severance.user_domain_block", { target, followers, n: following }) }}
</p>

<NuxtLink :to="`https://${currentServer}/severed_relationships`" target="_blank">
Learn more
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can mark these words as translatable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixed by fc89b71 (#3134)

</NuxtLink>
</template>
5 changes: 5 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@
"followed_you_count": "{0} people followed you|{0} person followed you|{0} people followed you",
"missing_type": "MISSING notification.type:",
"reblogged_post": "boosted your post",
"relationship_severance": {
"account_suspension": "An admin from {0} has suspended {1}, which means you can no longer receive updates from them or interact with them.",
"domain_block": "An admin from {from} has blocked {target}, including {followers} of your followers and {n} account you follow.|An admin from {from} has blocked {target}, including {followers} of your followers and {n} accounts you follow.",
"user_domain_block": "You have blocked {target}, removing {followers} of your followers and {n} account you follow.|You have blocked {target}, removing {followers} of your followers and {n} accounts you follow."
},
"reported": "{0} reported {1}",
"request_to_follow": "requested to follow you",
"signed_up": "signed up",
Expand Down
Loading