0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added deleted post indicator to ActivityPub (#22392)

ref AP-839

- When a reply to a deleted post is opened there's no indication that
the post has been deleted

---------

Co-authored-by: Michael Barrett <mike@ghost.org>
This commit is contained in:
Peter Zimon 2025-03-06 09:52:12 +01:00 committed by GitHub
parent 65fcb947aa
commit c6364dd638
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 44 additions and 9 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@tryghost/admin-x-activitypub",
"version": "0.4.7",
"version": "0.4.8",
"license": "MIT",
"repository": {
"type": "git",

View file

@ -77,8 +77,9 @@ export interface GetAccountFollowsResponse {
}
export enum PostType {
Note = 0,
Article = 1,
Note = 2,
Tombstone = 2
}
export interface Post {

View file

@ -17,6 +17,7 @@ import {useThreadForUser} from '@hooks/use-activity-pub-queries';
import APAvatar from '../global/APAvatar';
import APReplyBox from '../global/APReplyBox';
import DeletedFeedItem from './DeletedFeedItem';
import TableOfContents, {TOCItem} from './TableOfContents';
import getReadingTime from '../../utils/get-reading-time';
import {useDebounce} from 'use-debounce';
@ -867,7 +868,9 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
<div className={`mx-auto px-8 pb-10 pt-5`} style={{maxWidth: currentMaxWidth}}>
{threadParents.map((item) => {
return (
<>
item.object.type === 'Tombstone' ? (
<DeletedFeedItem last={false} />
) : (
<FeedItem
actor={item.actor}
allowDelete={false}
@ -885,7 +888,7 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
setIsFocused(true);
}}
/>
</>
)
);
})}
@ -942,6 +945,9 @@ const ArticleModal: React.FC<ArticleModalProps> = ({
</div>
</div>
)}
{object.type === 'Tombstone' && (
<DeletedFeedItem last={true} />
)}
<div ref={replyBoxRef}>
<APReplyBox

View file

@ -0,0 +1,20 @@
import React from 'react';
import {LucideIcon} from '@tryghost/shade';
interface DeletedFeedItemProps {
last?: boolean;
}
const DeletedFeedItem: React.FC<DeletedFeedItemProps> = ({last}) => {
return (
<div className='relative py-5'>
<div className='flex h-10 grow items-center gap-2 rounded-lg border border-gray-200 p-2 px-[10px] text-center text-sm text-gray-600'>
<LucideIcon.Trash size={16} strokeWidth={1.25} />
This post has been deleted
</div>
{!last && <div className="absolute bottom-0 left-[18px] top-[62px] z-0 mb-[-13px] w-[2px] rounded-sm bg-gray-200"></div>}
</div>
);
};
export default DeletedFeedItem;

View file

@ -597,6 +597,7 @@ export function useThreadForUser(handle: string, id: string) {
const threadQuery = useQuery({
queryKey,
refetchOnMount: 'always',
async queryFn() {
const siteUrl = await getSiteUrl();
const api = createActivityPubAPI(handle, siteUrl);

View file

@ -77,12 +77,12 @@ export function mapPostToActivity(post: Post): Activity {
};
}
// If the post is an article, then the object type is: "Article"
// otherwise, we use "Note" as the object type
let objectType: 'Article' | 'Note' = 'Note';
let objectType: 'Article' | 'Note' | 'Tombstone' = 'Note';
if (post.type === PostType.Article) {
objectType = 'Article';
} else if (post.type === PostType.Tombstone) {
objectType = 'Tombstone';
}
const object = {

View file

@ -286,7 +286,7 @@ const Notifications: React.FC<NotificationsProps> = () => {
switch (group.type) {
case ACTIVITY_TYPE.CREATE:
NiceModal.show(ArticleModal, {
activityId: group.id,
activityId: group.object.id,
object: group.object,
actor: group.actors[0],
focusReplies: true,

View file

@ -102,6 +102,13 @@ describe('mapPostToActivity', function () {
type: PostType.Note
}).object.type
).toBe('Note');
expect(
mapPostToActivity({
...post,
type: PostType.Tombstone
}).object.type
).toBe('Tombstone');
});
test('it sets the correct object', function () {

View file

@ -9,7 +9,7 @@ export type FollowItem = {
export type ObjectProperties = {
'@context': string | (string | object)[];
type: 'Article' | 'Link' | 'Note';
type: 'Article' | 'Link' | 'Note' | 'Tombstone';
name: string;
content: string | null;
url?: string | undefined;