@rmdes/indiekit-endpoint-activitypub 2.0.17 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +100 -92
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -875,107 +875,115 @@ export default class ActivityPubEndpoint {
|
|
|
875
875
|
_publicationUrl: this._publicationUrl,
|
|
876
876
|
};
|
|
877
877
|
|
|
878
|
-
//
|
|
879
|
-
|
|
880
|
-
|
|
878
|
+
// Create indexes — wrapped in try-catch because collection references
|
|
879
|
+
// may be undefined if MongoDB hasn't finished connecting yet.
|
|
880
|
+
// Indexes are idempotent; they'll be created on next successful startup.
|
|
881
|
+
try {
|
|
882
|
+
// TTL index for activity cleanup (MongoDB handles expiry automatically)
|
|
883
|
+
const retentionDays = this.options.activityRetentionDays;
|
|
884
|
+
if (retentionDays > 0) {
|
|
885
|
+
this._collections.ap_activities.createIndex(
|
|
886
|
+
{ receivedAt: 1 },
|
|
887
|
+
{ expireAfterSeconds: retentionDays * 86_400 },
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// Performance indexes for inbox handlers and batch refollow
|
|
892
|
+
this._collections.ap_followers.createIndex(
|
|
893
|
+
{ actorUrl: 1 },
|
|
894
|
+
{ unique: true, background: true },
|
|
895
|
+
);
|
|
896
|
+
this._collections.ap_following.createIndex(
|
|
897
|
+
{ actorUrl: 1 },
|
|
898
|
+
{ unique: true, background: true },
|
|
899
|
+
);
|
|
900
|
+
this._collections.ap_following.createIndex(
|
|
901
|
+
{ source: 1 },
|
|
902
|
+
{ background: true },
|
|
903
|
+
);
|
|
881
904
|
this._collections.ap_activities.createIndex(
|
|
882
|
-
{
|
|
883
|
-
{
|
|
905
|
+
{ objectUrl: 1 },
|
|
906
|
+
{ background: true },
|
|
907
|
+
);
|
|
908
|
+
this._collections.ap_activities.createIndex(
|
|
909
|
+
{ type: 1, actorUrl: 1, objectUrl: 1 },
|
|
910
|
+
{ background: true },
|
|
884
911
|
);
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// Performance indexes for inbox handlers and batch refollow
|
|
888
|
-
this._collections.ap_followers.createIndex(
|
|
889
|
-
{ actorUrl: 1 },
|
|
890
|
-
{ unique: true, background: true },
|
|
891
|
-
);
|
|
892
|
-
this._collections.ap_following.createIndex(
|
|
893
|
-
{ actorUrl: 1 },
|
|
894
|
-
{ unique: true, background: true },
|
|
895
|
-
);
|
|
896
|
-
this._collections.ap_following.createIndex(
|
|
897
|
-
{ source: 1 },
|
|
898
|
-
{ background: true },
|
|
899
|
-
);
|
|
900
|
-
this._collections.ap_activities.createIndex(
|
|
901
|
-
{ objectUrl: 1 },
|
|
902
|
-
{ background: true },
|
|
903
|
-
);
|
|
904
|
-
this._collections.ap_activities.createIndex(
|
|
905
|
-
{ type: 1, actorUrl: 1, objectUrl: 1 },
|
|
906
|
-
{ background: true },
|
|
907
|
-
);
|
|
908
|
-
|
|
909
|
-
// Reader indexes (timeline, notifications, moderation, interactions)
|
|
910
|
-
this._collections.ap_timeline.createIndex(
|
|
911
|
-
{ uid: 1 },
|
|
912
|
-
{ unique: true, background: true },
|
|
913
|
-
);
|
|
914
|
-
this._collections.ap_timeline.createIndex(
|
|
915
|
-
{ published: -1 },
|
|
916
|
-
{ background: true },
|
|
917
|
-
);
|
|
918
|
-
this._collections.ap_timeline.createIndex(
|
|
919
|
-
{ "author.url": 1 },
|
|
920
|
-
{ background: true },
|
|
921
|
-
);
|
|
922
|
-
this._collections.ap_timeline.createIndex(
|
|
923
|
-
{ type: 1, published: -1 },
|
|
924
|
-
{ background: true },
|
|
925
|
-
);
|
|
926
912
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
913
|
+
// Reader indexes (timeline, notifications, moderation, interactions)
|
|
914
|
+
this._collections.ap_timeline.createIndex(
|
|
915
|
+
{ uid: 1 },
|
|
916
|
+
{ unique: true, background: true },
|
|
917
|
+
);
|
|
918
|
+
this._collections.ap_timeline.createIndex(
|
|
919
|
+
{ published: -1 },
|
|
920
|
+
{ background: true },
|
|
921
|
+
);
|
|
922
|
+
this._collections.ap_timeline.createIndex(
|
|
923
|
+
{ "author.url": 1 },
|
|
924
|
+
{ background: true },
|
|
925
|
+
);
|
|
926
|
+
this._collections.ap_timeline.createIndex(
|
|
927
|
+
{ type: 1, published: -1 },
|
|
928
|
+
{ background: true },
|
|
929
|
+
);
|
|
943
930
|
|
|
944
|
-
// TTL index for notification cleanup
|
|
945
|
-
const notifRetention = this.options.notificationRetentionDays;
|
|
946
|
-
if (notifRetention > 0) {
|
|
947
931
|
this._collections.ap_notifications.createIndex(
|
|
948
|
-
{
|
|
949
|
-
{
|
|
932
|
+
{ uid: 1 },
|
|
933
|
+
{ unique: true, background: true },
|
|
934
|
+
);
|
|
935
|
+
this._collections.ap_notifications.createIndex(
|
|
936
|
+
{ published: -1 },
|
|
937
|
+
{ background: true },
|
|
938
|
+
);
|
|
939
|
+
this._collections.ap_notifications.createIndex(
|
|
940
|
+
{ read: 1 },
|
|
941
|
+
{ background: true },
|
|
942
|
+
);
|
|
943
|
+
this._collections.ap_notifications.createIndex(
|
|
944
|
+
{ type: 1, published: -1 },
|
|
945
|
+
{ background: true },
|
|
950
946
|
);
|
|
951
|
-
}
|
|
952
947
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
this._collections.ap_muted.createIndex(
|
|
962
|
-
{ keyword: 1 },
|
|
963
|
-
{ unique: true, sparse: true, background: true },
|
|
964
|
-
);
|
|
948
|
+
// TTL index for notification cleanup
|
|
949
|
+
const notifRetention = this.options.notificationRetentionDays;
|
|
950
|
+
if (notifRetention > 0) {
|
|
951
|
+
this._collections.ap_notifications.createIndex(
|
|
952
|
+
{ createdAt: 1 },
|
|
953
|
+
{ expireAfterSeconds: notifRetention * 86_400 },
|
|
954
|
+
);
|
|
955
|
+
}
|
|
965
956
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
957
|
+
// Drop non-sparse indexes if they exist (created by earlier versions),
|
|
958
|
+
// then recreate with sparse:true so multiple null values are allowed.
|
|
959
|
+
this._collections.ap_muted.dropIndex("url_1").catch(() => {});
|
|
960
|
+
this._collections.ap_muted.dropIndex("keyword_1").catch(() => {});
|
|
961
|
+
this._collections.ap_muted.createIndex(
|
|
962
|
+
{ url: 1 },
|
|
963
|
+
{ unique: true, sparse: true, background: true },
|
|
964
|
+
);
|
|
965
|
+
this._collections.ap_muted.createIndex(
|
|
966
|
+
{ keyword: 1 },
|
|
967
|
+
{ unique: true, sparse: true, background: true },
|
|
968
|
+
);
|
|
970
969
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
970
|
+
this._collections.ap_blocked.createIndex(
|
|
971
|
+
{ url: 1 },
|
|
972
|
+
{ unique: true, background: true },
|
|
973
|
+
);
|
|
974
|
+
|
|
975
|
+
this._collections.ap_interactions.createIndex(
|
|
976
|
+
{ objectUrl: 1, type: 1 },
|
|
977
|
+
{ unique: true, background: true },
|
|
978
|
+
);
|
|
979
|
+
this._collections.ap_interactions.createIndex(
|
|
980
|
+
{ type: 1 },
|
|
981
|
+
{ background: true },
|
|
982
|
+
);
|
|
983
|
+
} catch {
|
|
984
|
+
// Index creation failed — collections not yet available.
|
|
985
|
+
// Indexes already exist from previous startups; non-fatal.
|
|
986
|
+
}
|
|
979
987
|
|
|
980
988
|
// Seed actor profile from config on first run
|
|
981
989
|
this._seedProfile().catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.18",
|
|
4
4
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|