@@ -534,7 +534,9 @@ export class FederationImpl<TContextData> implements Federation<TContextData> {
534
534
keys,
535
535
activity : message . activity ,
536
536
activityId : message . activityId ,
537
+ activityType : message . activityType ,
537
538
inbox : new URL ( message . inbox ) ,
539
+ sharedInbox : message . sharedInbox ,
538
540
headers : new Headers ( message . headers ) ,
539
541
tracerProvider : this . tracerProvider ,
540
542
} ) ;
@@ -647,7 +649,12 @@ export class FederationImpl<TContextData> implements Federation<TContextData> {
647
649
}
648
650
try {
649
651
await listener (
650
- context . toInboxContext ( message . identifier , message . activity ) ,
652
+ context . toInboxContext (
653
+ message . identifier ,
654
+ message . activity ,
655
+ activity . id ?. href ,
656
+ getTypeId ( activity ) . href ,
657
+ ) ,
651
658
activity ,
652
659
) ;
653
660
} catch ( error ) {
@@ -1941,12 +1948,14 @@ export class FederationImpl<TContextData> implements Federation<TContextData> {
1941
1948
keys,
1942
1949
activity : jsonLd ,
1943
1950
activityId : activity . id ?. href ,
1951
+ activityType : getTypeId ( activity ) . href ,
1944
1952
inbox : new URL ( inbox ) ,
1953
+ sharedInbox : inboxes [ inbox ] . sharedInbox ,
1945
1954
headers : collectionSync == null ? undefined : new Headers ( {
1946
1955
"Collection-Synchronization" :
1947
1956
await buildCollectionSynchronizationHeader (
1948
1957
collectionSync ,
1949
- inboxes [ inbox ] ,
1958
+ inboxes [ inbox ] . actorIds ,
1950
1959
) ,
1951
1960
} ) ,
1952
1961
tracerProvider : this . tracerProvider ,
@@ -1973,14 +1982,16 @@ export class FederationImpl<TContextData> implements Federation<TContextData> {
1973
1982
keys : keyJwkPairs ,
1974
1983
activity : jsonLd ,
1975
1984
activityId : activity . id ?. href ,
1985
+ activityType : getTypeId ( activity ) . href ,
1976
1986
inbox,
1987
+ sharedInbox : inboxes [ inbox ] . sharedInbox ,
1977
1988
started : new Date ( ) . toISOString ( ) ,
1978
1989
attempt : 0 ,
1979
1990
headers : collectionSync == null ? { } : {
1980
1991
"Collection-Synchronization" :
1981
1992
await buildCollectionSynchronizationHeader (
1982
1993
collectionSync ,
1983
- inboxes [ inbox ] ,
1994
+ inboxes [ inbox ] . actorIds ,
1984
1995
) ,
1985
1996
} ,
1986
1997
} ;
@@ -2301,8 +2312,10 @@ export class ContextImpl<TContextData> implements Context<TContextData> {
2301
2312
toInboxContext (
2302
2313
recipient : string | null ,
2303
2314
activity : unknown ,
2315
+ activityId : string | undefined ,
2316
+ activityType : string ,
2304
2317
) : InboxContextImpl < TContextData > {
2305
- return new InboxContextImpl ( recipient , activity , {
2318
+ return new InboxContextImpl ( recipient , activity , activityId , activityType , {
2306
2319
url : this . url ,
2307
2320
federation : this . federation ,
2308
2321
data : this . data ,
@@ -3028,15 +3041,21 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3028
3041
implements InboxContext < TContextData > {
3029
3042
readonly recipient : string | null ;
3030
3043
readonly activity : unknown ;
3044
+ readonly activityId ?: string ;
3045
+ readonly activityType : string ;
3031
3046
3032
3047
constructor (
3033
3048
recipient : string | null ,
3034
3049
activity : unknown ,
3050
+ activityId : string | undefined ,
3051
+ activityType : string ,
3035
3052
options : ContextOptions < TContextData > ,
3036
3053
) {
3037
3054
super ( options ) ;
3038
3055
this . recipient = recipient ;
3039
3056
this . activity = activity ;
3057
+ this . activityId = activityId ;
3058
+ this . activityType = activityType ;
3040
3059
}
3041
3060
3042
3061
forwardActivity (
@@ -3119,12 +3138,10 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3119
3138
} else {
3120
3139
keys = [ forwarder ] ;
3121
3140
}
3122
- let activityId : string | undefined = undefined ;
3123
3141
if ( ! hasSignature ( this . activity ) ) {
3124
3142
let hasProof : boolean ;
3125
3143
try {
3126
3144
const activity = await Activity . fromJsonLd ( this . activity , this ) ;
3127
- activityId = activity . id ?. href ;
3128
3145
hasProof = await activity . getProof ( ) != null ;
3129
3146
} catch {
3130
3147
hasProof = false ;
@@ -3138,17 +3155,6 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3138
3155
) ;
3139
3156
}
3140
3157
}
3141
- if (
3142
- activityId == null && typeof this . activity === "object" &&
3143
- this . activity != null
3144
- ) {
3145
- activityId =
3146
- "@id" in this . activity && typeof this . activity [ "@id" ] === "string"
3147
- ? this . activity [ "@id" ]
3148
- : "id" in this . activity && typeof this . activity . id === "string"
3149
- ? this . activity . id
3150
- : undefined ;
3151
- }
3152
3158
if ( recipients === "followers" ) {
3153
3159
if ( identifier == null ) {
3154
3160
throw new Error (
@@ -3169,7 +3175,7 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3169
3175
} ) ;
3170
3176
logger . debug ( "Forwarding activity {activityId} to inboxes:\n{inboxes}" , {
3171
3177
inboxes : globalThis . Object . keys ( inboxes ) ,
3172
- activityId,
3178
+ activityId : this . activityId ,
3173
3179
activity : this . activity ,
3174
3180
} ) ;
3175
3181
if ( options ?. immediate || this . federation . outboxQueue == null ) {
@@ -3190,8 +3196,10 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3190
3196
sendActivity ( {
3191
3197
keys,
3192
3198
activity : this . activity ,
3193
- activityId : activityId ,
3199
+ activityId : this . activityId ,
3200
+ activityType : this . activityType ,
3194
3201
inbox : new URL ( inbox ) ,
3202
+ sharedInbox : inboxes [ inbox ] . sharedInbox ,
3195
3203
tracerProvider : this . tracerProvider ,
3196
3204
} ) ,
3197
3205
) ;
@@ -3201,7 +3209,7 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3201
3209
}
3202
3210
logger . debug (
3203
3211
"Enqueuing activity {activityId} to forward later." ,
3204
- { activityId, activity : this . activity } ,
3212
+ { activityId : this . activityId , activity : this . activity } ,
3205
3213
) ;
3206
3214
const keyJwkPairs : SenderKeyJwkPair [ ] = [ ] ;
3207
3215
for ( const { keyId, privateKey } of keys ) {
@@ -3214,8 +3222,10 @@ export class InboxContextImpl<TContextData> extends ContextImpl<TContextData>
3214
3222
id : crypto . randomUUID ( ) ,
3215
3223
keys : keyJwkPairs ,
3216
3224
activity : this . activity ,
3217
- activityId,
3225
+ activityId : this . activityId ,
3226
+ activityType : this . activityType ,
3218
3227
inbox,
3228
+ sharedInbox : inboxes [ inbox ] . sharedInbox ,
3219
3229
started : new Date ( ) . toISOString ( ) ,
3220
3230
attempt : 0 ,
3221
3231
headers : { } ,
0 commit comments