diff --git a/packages/pl-api/lib/entities/notification.ts b/packages/pl-api/lib/entities/notification.ts index 41d3cda7d..2942a118f 100644 --- a/packages/pl-api/lib/entities/notification.ts +++ b/packages/pl-api/lib/entities/notification.ts @@ -24,8 +24,14 @@ const accountNotificationSchema = baseNotificationSchema.extend({ type: z.enum(['follow', 'follow_request', 'admin.sign_up', 'bite']), }); +const mentionNotificationSchema = baseNotificationSchema.extend({ + type: z.literal('mention'), + subtype: z.enum(['reply']).nullable().catch(null), + status: statusSchema, +}); + const statusNotificationSchema = baseNotificationSchema.extend({ - type: z.enum(['mention', 'status', 'reblog', 'favourite', 'poll', 'update', 'event_reminder']), + type: z.enum(['status', 'reblog', 'favourite', 'poll', 'update', 'event_reminder']), status: statusSchema, }); @@ -77,6 +83,7 @@ const notificationSchema: z.ZodType = z.preprocess((notification: : notification.type?.replace(/^pleroma:/, ''), }), z.discriminatedUnion('type', [ accountNotificationSchema, + mentionNotificationSchema, statusNotificationSchema, reportNotificationSchema, severedRelationshipNotificationSchema, @@ -89,6 +96,7 @@ const notificationSchema: z.ZodType = z.preprocess((notification: type Notification = z.infer< | typeof accountNotificationSchema +| typeof mentionNotificationSchema | typeof statusNotificationSchema | typeof reportNotificationSchema | typeof severedRelationshipNotificationSchema diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index 3ddd38a64..13ae3acc5 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "0.0.31", + "version": "0.0.32", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/fork/packages/pl-api", "repository": { diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index c58d284f3..96461d79c 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -134,7 +134,7 @@ "multiselect-react-dropdown": "^2.0.25", "object-to-formdata": "^4.5.1", "path-browserify": "^1.0.1", - "pl-api": "^0.0.31", + "pl-api": "^0.0.32", "postcss": "^8.4.29", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/features/notifications/components/notification.tsx b/packages/pl-fe/src/features/notifications/components/notification.tsx index 18c3be475..59d84ce2f 100644 --- a/packages/pl-fe/src/features/notifications/components/notification.tsx +++ b/packages/pl-fe/src/features/notifications/components/notification.tsx @@ -40,7 +40,7 @@ const buildLink = (account: Pick): JSX.El ); -const icons: Partial> = { +const icons: Partial> = { follow: require('@tabler/icons/outline/user-plus.svg'), follow_request: require('@tabler/icons/outline/user-plus.svg'), mention: require('@tabler/icons/outline/at.svg'), @@ -56,9 +56,10 @@ const icons: Partial> = { participation_request: require('@tabler/icons/outline/calendar-event.svg'), participation_accepted: require('@tabler/icons/outline/calendar-event.svg'), bite: require('@tabler/icons/outline/pacman.svg'), + reply: require('@tabler/icons/outline/corner-up-left.svg'), }; -const messages: Record = defineMessages({ +const messages: Record = defineMessages({ follow: { id: 'notification.follow', defaultMessage: '{name} followed you', @@ -135,11 +136,15 @@ const messages: Record = defineMessages({ id: 'notification.bite', defaultMessage: '{name} has bit you', }, + reply: { + id: 'notification.reply', + defaultMessage: '{name} replied to your post', + }, }); const buildMessage = ( intl: IntlShape, - type: NotificationType, + type: NotificationType | 'reply', accounts: Array>, targetName: string, instanceTitle: string, @@ -292,7 +297,7 @@ const Notification: React.FC = (props) => { } else if (icons[type]) { return ( ); @@ -362,7 +367,7 @@ const Notification: React.FC = (props) => { const targetName = notification.type === 'move' ? notification.target.acct : ''; const message: React.ReactNode = account && typeof account === 'object' - ? buildMessage(intl, type, accounts, targetName, instance.title) + ? buildMessage(intl, type === 'mention' ? notification.subtype || type : type, accounts, targetName, instance.title) : null; const ariaLabel = ( diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 1b00fb81f..1e4c9c573 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1124,6 +1124,7 @@ "notification.pleroma:participation_request": "{name} wants to join your event", "notification.poll": "A poll you have voted in has ended", "notification.reblog": "{name} reposted your post", + "notification.reply": "{name} replied to your post", "notification.severed_relationships": "Lost connections with {name}", "notification.status": "{name} just posted", "notification.update": "{name} edited a post you interacted with", diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index 04decf55b..4add4b439 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -8240,10 +8240,10 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" -pl-api@^0.0.31: - version "0.0.31" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.31.tgz#63720a2620c304e461cf758f566809b78d4ce080" - integrity sha512-L0d7LveBpas9Et9tRePuCfcSb3nzEgbNTyVXbivV7Je+jwGCXnhXo7O7VMl+EnjjJKW+wlqfSer7Y+Db9UCXAw== +pl-api@^0.0.32: + version "0.0.32" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.32.tgz#d6d86342c99c740bdb4e99a67ef249caede7390a" + integrity sha512-uIh98+/5Z9CVoP5b77+tH2ETsSeLKmSXR0vmH7vkxQdjssrv139puy7jv7aYKnbOj2uqm3IDTCyYzI4q0KNFBQ== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"