@massalabs/gossip-sdk 0.0.2-dev.20260130132559 → 0.0.2-dev.20260130145448
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.
|
@@ -36,6 +36,12 @@ export declare class AnnouncementService {
|
|
|
36
36
|
}>;
|
|
37
37
|
fetchAndProcessAnnouncements(): Promise<AnnouncementReceptionResult>;
|
|
38
38
|
resendAnnouncements(failedDiscussions: Discussion[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Persist lastBulletinCounter for the current user.
|
|
41
|
+
* Uses put() so the cursor is saved even when no profile row exists yet
|
|
42
|
+
* (e.g. headless bot that never created a profile via app UI).
|
|
43
|
+
*/
|
|
44
|
+
private _upsertLastBulletinCounter;
|
|
39
45
|
private _fetchAnnouncements;
|
|
40
46
|
private _generateTemporaryContactName;
|
|
41
47
|
private _processIncomingAnnouncement;
|
|
@@ -153,9 +153,7 @@ export class AnnouncementService {
|
|
|
153
153
|
}
|
|
154
154
|
if (fetchedCounters.length > 0) {
|
|
155
155
|
const highestCounter = fetchedCounters.reduce((a, b) => Number(a) > Number(b) ? a : b);
|
|
156
|
-
await this.
|
|
157
|
-
lastBulletinCounter: highestCounter,
|
|
158
|
-
});
|
|
156
|
+
await this._upsertLastBulletinCounter(highestCounter);
|
|
159
157
|
log.info('updated lastBulletinCounter', { highestCounter });
|
|
160
158
|
}
|
|
161
159
|
return {
|
|
@@ -194,9 +192,7 @@ export class AnnouncementService {
|
|
|
194
192
|
// If API returned a batch with max <= cursor (same or older page), advance past it
|
|
195
193
|
// so we don't re-fetch the same page forever (e.g. API returning "latest" regardless of after)
|
|
196
194
|
const nextCounter = highestNum <= cursorNum ? String(cursorNum + 1) : highestCounter;
|
|
197
|
-
await this.
|
|
198
|
-
lastBulletinCounter: nextCounter,
|
|
199
|
-
});
|
|
195
|
+
await this._upsertLastBulletinCounter(nextCounter);
|
|
200
196
|
log.info('updated lastBulletinCounter', {
|
|
201
197
|
lastBulletinCounter: nextCounter,
|
|
202
198
|
});
|
|
@@ -311,6 +307,32 @@ export class AnnouncementService {
|
|
|
311
307
|
broken: brokenDiscussions.length,
|
|
312
308
|
});
|
|
313
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Persist lastBulletinCounter for the current user.
|
|
312
|
+
* Uses put() so the cursor is saved even when no profile row exists yet
|
|
313
|
+
* (e.g. headless bot that never created a profile via app UI).
|
|
314
|
+
*/
|
|
315
|
+
async _upsertLastBulletinCounter(nextCounter) {
|
|
316
|
+
const userId = this.session.userIdEncoded;
|
|
317
|
+
const existing = await this.db.userProfile.get(userId);
|
|
318
|
+
if (existing) {
|
|
319
|
+
await this.db.userProfile.update(userId, {
|
|
320
|
+
lastBulletinCounter: nextCounter,
|
|
321
|
+
updatedAt: new Date(),
|
|
322
|
+
});
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
// Minimal profile so cursor persists; headless bots may never create a full profile
|
|
326
|
+
await this.db.userProfile.put({
|
|
327
|
+
userId,
|
|
328
|
+
username: '',
|
|
329
|
+
status: 'offline',
|
|
330
|
+
lastSeen: new Date(),
|
|
331
|
+
createdAt: new Date(),
|
|
332
|
+
updatedAt: new Date(),
|
|
333
|
+
lastBulletinCounter: nextCounter,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
314
336
|
async _fetchAnnouncements(cursor, limit) {
|
|
315
337
|
const fetchLimit = limit ?? this.config.announcements.fetchLimit;
|
|
316
338
|
const log = logger.forMethod('_fetchAnnouncements');
|
package/package.json
CHANGED