Merge branch 'feat-undo-repost' into 'main'
feat: undo repost See merge request soapbox-pub/ditto!150
This commit is contained in:
commit
bff8c62572
@ -13,7 +13,7 @@ With Ditto, you can create your own social network that is decentralized, custom
|
|||||||
- [x] Log in with any Mastodon app
|
- [x] Log in with any Mastodon app
|
||||||
- [x] Like and comment on posts
|
- [x] Like and comment on posts
|
||||||
- [x] Share posts
|
- [x] Share posts
|
||||||
- [ ] Reposts
|
- [x] Reposts
|
||||||
- [ ] Notifications
|
- [ ] Notifications
|
||||||
- [x] Profiles
|
- [x] Profiles
|
||||||
- [ ] Search
|
- [ ] Search
|
||||||
|
@ -66,6 +66,7 @@ import {
|
|||||||
statusController,
|
statusController,
|
||||||
unbookmarkController,
|
unbookmarkController,
|
||||||
unpinController,
|
unpinController,
|
||||||
|
unreblogStatusController,
|
||||||
zapController,
|
zapController,
|
||||||
} from '@/controllers/api/statuses.ts';
|
} from '@/controllers/api/statuses.ts';
|
||||||
import { streamingController } from '@/controllers/api/streaming.ts';
|
import { streamingController } from '@/controllers/api/streaming.ts';
|
||||||
@ -169,6 +170,7 @@ app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/pin', requirePubkey, pinController)
|
|||||||
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/unpin', requirePubkey, unpinController);
|
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/unpin', requirePubkey, unpinController);
|
||||||
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/zap', requirePubkey, zapController);
|
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/zap', requirePubkey, zapController);
|
||||||
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/reblog', requirePubkey, reblogStatusController);
|
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/reblog', requirePubkey, reblogStatusController);
|
||||||
|
app.post('/api/v1/statuses/:id{[0-9a-f]{64}}/unreblog', requirePubkey, unreblogStatusController);
|
||||||
app.post('/api/v1/statuses', requirePubkey, createStatusController);
|
app.post('/api/v1/statuses', requirePubkey, createStatusController);
|
||||||
app.delete('/api/v1/statuses/:id{[0-9a-f]{64}}', requirePubkey, deleteStatusController);
|
app.delete('/api/v1/statuses/:id{[0-9a-f]{64}}', requirePubkey, deleteStatusController);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { type AppController } from '@/app.ts';
|
import { type AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { getUnattachedMediaByIds } from '@/db/unattached-media.ts';
|
import { getUnattachedMediaByIds } from '@/db/unattached-media.ts';
|
||||||
import { ISO6391, NIP05, nip19, type NostrEvent, z } from '@/deps.ts';
|
import { ISO6391, NIP05, nip19, type NostrEvent, NostrFilter, z } from '@/deps.ts';
|
||||||
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
|
import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts';
|
||||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||||
import { addTag, deleteTag } from '@/tags.ts';
|
import { addTag, deleteTag } from '@/tags.ts';
|
||||||
@ -11,6 +11,7 @@ import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts';
|
|||||||
import { getLnurl } from '@/utils/lnurl.ts';
|
import { getLnurl } from '@/utils/lnurl.ts';
|
||||||
import { nip05Cache } from '@/utils/nip05.ts';
|
import { nip05Cache } from '@/utils/nip05.ts';
|
||||||
import { asyncReplaceAll } from '@/utils/text.ts';
|
import { asyncReplaceAll } from '@/utils/text.ts';
|
||||||
|
import { eventsDB } from '@/storages.ts';
|
||||||
|
|
||||||
const createStatusSchema = z.object({
|
const createStatusSchema = z.object({
|
||||||
in_reply_to_id: z.string().regex(/[0-9a-f]{64}/).nullish(),
|
in_reply_to_id: z.string().regex(/[0-9a-f]{64}/).nullish(),
|
||||||
@ -225,6 +226,28 @@ const reblogStatusController: AppController = async (c) => {
|
|||||||
return c.json(status);
|
return c.json(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** https://docs.joinmastodon.org/methods/statuses/#unreblog */
|
||||||
|
const unreblogStatusController: AppController = async (c) => {
|
||||||
|
const eventId = c.req.param('id');
|
||||||
|
const pubkey = c.get('pubkey') as string;
|
||||||
|
|
||||||
|
const event = await getEvent(eventId, {
|
||||||
|
kind: 1,
|
||||||
|
});
|
||||||
|
if (!event) return c.json({ error: 'Event not found.' }, 404);
|
||||||
|
|
||||||
|
const filters: NostrFilter[] = [{ kinds: [6], authors: [pubkey], '#e': [event.id] }];
|
||||||
|
const [repostedEvent] = await eventsDB.query(filters, { limit: 1 });
|
||||||
|
if (!repostedEvent) return c.json({ error: 'Event not found.' }, 404);
|
||||||
|
|
||||||
|
await createEvent({
|
||||||
|
kind: 5,
|
||||||
|
tags: [['e', repostedEvent.id]],
|
||||||
|
}, c);
|
||||||
|
|
||||||
|
return c.json(await renderStatus(event));
|
||||||
|
};
|
||||||
|
|
||||||
const rebloggedByController: AppController = (c) => {
|
const rebloggedByController: AppController = (c) => {
|
||||||
const id = c.req.param('id');
|
const id = c.req.param('id');
|
||||||
const params = paginationSchema.parse(c.req.query());
|
const params = paginationSchema.parse(c.req.query());
|
||||||
@ -396,5 +419,6 @@ export {
|
|||||||
statusController,
|
statusController,
|
||||||
unbookmarkController,
|
unbookmarkController,
|
||||||
unpinController,
|
unpinController,
|
||||||
|
unreblogStatusController,
|
||||||
zapController,
|
zapController,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user