File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { setResponseHeader } from "h3" ;
22import { addClient , removeClient } from "../sse" ;
33
4- export default defineEventHandler ( async ( event ) => {
4+ export default defineEventHandler ( ( event ) => {
55 setResponseHeader ( event , "Content-Type" , "text/event-stream" ) ;
66 setResponseHeader ( event , "Cache-Control" , "no-cache" ) ;
77 setResponseHeader ( event , "Connection" , "keep-alive" ) ;
Original file line number Diff line number Diff line change 11import { Create , Note } from "@fedify/vocab" ;
2- import { readBody , sendRedirect , toWebRequest } from "h3" ;
3- import federation from "../federation" ;
4- import { postStore } from "../store" ;
2+ import {
3+ defineEventHandler ,
4+ readBody ,
5+ sendRedirect ,
6+ toWebRequest ,
7+ } from "@nuxt/nitro-server/h3" ;
8+ import federation from "../federation.ts" ;
9+ import { postStore } from "../store.ts" ;
510
611export default defineEventHandler ( async ( event ) => {
712 const body = await readBody ( event ) ;
@@ -29,7 +34,7 @@ export default defineEventHandler(async (event) => {
2934 { identifier } ,
3035 "followers" ,
3136 new Create ( {
32- id : new URL ( "#activity" , attribution ) ,
37+ id : new URL ( `#create/ ${ id } ` , attribution ) ,
3338 object : note ,
3439 actors : note ?. attributionIds ,
3540 tos : note ?. toIds ,
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ import {
1515 type Recipient ,
1616 Undo ,
1717} from "@fedify/vocab" ;
18- import { broadcastEvent } from "./sse" ;
19- import { keyPairsStore , postStore , relationStore } from "./store" ;
18+ import { broadcastEvent } from "./sse.ts " ;
19+ import { keyPairsStore , postStore , relationStore } from "./store.ts " ;
2020
2121const federation = createFederation < void > ( {
2222 kv : new MemoryKvStore ( ) ,
@@ -96,18 +96,15 @@ federation
9696 } )
9797 . on ( Undo , async ( context , undo ) => {
9898 const activity = await undo . getObject ( context ) ;
99- if ( activity instanceof Follow ) {
100- if ( activity . id == null ) {
101- return ;
102- }
103- if ( undo . actorId == null ) {
104- return ;
105- }
106- relationStore . delete ( undo . actorId . href ) ;
107- broadcastEvent ( ) ;
108- } else {
99+ if ( ! ( activity instanceof Follow ) ) {
109100 console . debug ( undo ) ;
101+ return ;
110102 }
103+ if ( activity . id == null || undo . actorId == null ) return ;
104+ const demoActorUri = context . getActorUri ( IDENTIFIER ) ;
105+ if ( activity . objectId ?. href !== demoActorUri . href ) return ;
106+ relationStore . delete ( undo . actorId . href ) ;
107+ broadcastEvent ( ) ;
111108 } ) ;
112109
113110federation . setObjectDispatcher (
You can’t perform that action at this time.
0 commit comments