Publish events through pipeline
This commit is contained in:
parent
85345bc157
commit
0158a6979e
|
@ -2,11 +2,13 @@ import { type AppController } from '@/app.ts';
|
|||
import { type Filter, findReplyTag, z } from '@/deps.ts';
|
||||
import { publish } from '@/client.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { getAuthor, getFollows } from '@/queries.ts';
|
||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { signEvent } from '@/sign.ts';
|
||||
import { toAccount, toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||
import { buildLinkHeader, eventDateComparator, lookupAccount, nostrNow, paginationSchema, parseBody } from '@/utils.ts';
|
||||
import pipe from 'https://deno.land/x/ramda@v0.27.2/source/pipe.js';
|
||||
|
||||
const createAccountController: AppController = (c) => {
|
||||
return c.json({ error: 'Please log in with Nostr.' }, 405);
|
||||
|
@ -167,7 +169,13 @@ const updateCredentialsController: AppController = async (c) => {
|
|||
created_at: nostrNow(),
|
||||
}, c);
|
||||
|
||||
publish(event);
|
||||
try {
|
||||
await pipeline.handleEvent(event);
|
||||
} catch (e) {
|
||||
if (e instanceof pipeline.RelayError) {
|
||||
return c.json({ error: e.message }, 422);
|
||||
}
|
||||
}
|
||||
|
||||
const account = await toAccount(event);
|
||||
return c.json(account);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { type AppController } from '@/app.ts';
|
||||
import { publish } from '@/client.ts';
|
||||
import { ISO6391, Kind, z } from '@/deps.ts';
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { getAncestors, getDescendants, getEvent } from '@/queries.ts';
|
||||
import { signEvent } from '@/sign.ts';
|
||||
import { toStatus } from '@/transformers/nostr-to-mastoapi.ts';
|
||||
|
@ -77,7 +78,13 @@ const createStatusController: AppController = async (c) => {
|
|||
created_at: nostrNow(),
|
||||
}, c);
|
||||
|
||||
publish(event);
|
||||
try {
|
||||
await pipeline.handleEvent(event);
|
||||
} catch (e) {
|
||||
if (e instanceof pipeline.RelayError) {
|
||||
return c.json({ error: e.message }, 422);
|
||||
}
|
||||
}
|
||||
|
||||
return c.json(await toStatus(event));
|
||||
} else {
|
||||
|
@ -118,7 +125,13 @@ const favouriteController: AppController = async (c) => {
|
|||
created_at: nostrNow(),
|
||||
}, c);
|
||||
|
||||
publish(event);
|
||||
try {
|
||||
await pipeline.handleEvent(event);
|
||||
} catch (e) {
|
||||
if (e instanceof pipeline.RelayError) {
|
||||
return c.json({ error: e.message }, 422);
|
||||
}
|
||||
}
|
||||
|
||||
const status = await toStatus(target);
|
||||
|
||||
|
|
Loading…
Reference in New Issue