Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 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 @@ const supportedNotificationTypes: NotificationType[] = [
'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,20 @@ if (unsupportedEmojiReactionTypes.includes(notification.type) || !supportedNotif
</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">
<!--
@vue-ignore
The type inference failed here (`any`) but since notification type is `severed_relationships`,
we are sure `typeof notification === SeveredRelationshipsNotification` here.
So we can assume the existence of `event` prop.
ref. https://docs.joinmastodon.org/entities/Notification/#relationship_severance_event
-->
<RelationshipSeveranceCard :event="notification.event!" />
</div>
</div>
</template>
</article>
</template>
31 changes: 31 additions & 0 deletions components/notification/RelationshipSeveranceCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
import type { mastodon } from 'masto'

const { event } = defineProps<{
event: mastodon.v1.RelationshipSeveranceEvent
}>()

const { t } = useI18n()

const type = event.type
const from = currentServer
const target = event.targetName
const followers = event.followersCount
const following = event.followingCount
</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">
{{ t("notification.relationship_severance.learn_more") }}
</NuxtLink>
</template>
6 changes: 6 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@
"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.",
"learn_more": "Learn more",
"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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"iso-639-1": "^3.0.0",
"js-yaml": "^4.1.0",
"lru-cache": "^11.0.0",
"masto": "^6.10.1",
"masto": "^6.10.3",
"node-emoji": "^2.1.3",
"nuxt-security": "^2.0.0",
"page-lifecycle": "^0.1.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.