Skip to content

Commit 818f824

Browse files
committed
Improved the performance of recipients gathering during sending activities
1 parent 462569f commit 818f824

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.env
22
assets/
33
fedify-hollo-*.tgz
4+
*.jsonl
45
node_modules/

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ To be released.
2121
- Added `LOG_FILE` environment variable to specify the file path to write
2222
structured logs. The logs are written in JSON Lines format.
2323

24+
- Improved the performance of recipients gathering during sending activities.
25+
2426
[#65]: https://github.com/dahlia/hollo/issues/65
2527

2628

log.jsonl

-1
This file was deleted.

src/federation/index.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ federation
180180
const owner = await db.query.accountOwners.findFirst({
181181
where: eq(accountOwners.handle, identifier),
182182
});
183-
if (owner == null || cursor == null) return null;
184-
const offset = Number.parseInt(cursor);
183+
if (owner == null) return null;
184+
const offset = cursor == null ? undefined : Number.parseInt(cursor);
185185
if (!Number.isInteger(offset)) return null;
186186
const followers = await db.query.accounts.findMany({
187187
where: and(
@@ -203,17 +203,19 @@ federation
203203
),
204204
offset,
205205
orderBy: accounts.id,
206-
limit: 41,
206+
limit: offset == null ? undefined : 41,
207207
});
208+
const items = offset == null ? followers : followers.slice(0, 40);
208209
return {
209-
items: followers.slice(0, 40).map((f) => ({
210+
items: items.map((f) => ({
210211
id: new URL(f.iri),
211212
inboxId: new URL(f.inboxUrl),
212213
endpoints: {
213214
sharedInbox: f.sharedInboxUrl ? new URL(f.sharedInboxUrl) : null,
214215
},
215216
})),
216-
nextCursor: followers.length > 40 ? `${offset + 40}` : null,
217+
nextCursor:
218+
offset != null && followers.length > 40 ? `${offset + 40}` : null,
217219
};
218220
},
219221
)

0 commit comments

Comments
 (0)