feat(notifications): Phase 675 platform notifications-activity mixin (v0.8.650)

Add notifications-activity.js with gossip dedupe, fanout rate limits,
@everyone/@here and role mention routing, partition heal for inbox and
activity feed, and local notification stubs (poll, scheduled, voice,
stage, boost, friend online). Hook stage speaker and boost level-up flows.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-02 22:36:11 -04:00
co-authored by Cursor
parent f85cf2d1c5
commit 1a3a9aea65
3 changed files with 332 additions and 2 deletions
+35 -2
View File
@@ -1556,7 +1556,9 @@ class PearcordPlatform extends EventEmitter {
const voiceOccHeal = await this._healVoiceOccupancyOnPartition(gid).catch(() => ({ relisted: 0 }))
const pollHeal = await this._healPollVoteVectorsOnPartition(gid).catch(() => ({ relisted: 0 }))
const scheduledHeal = await this._healScheduledQueueOnPartition(gid).catch(() => ({ relisted: 0 }))
return { voiceApplied, emojiSlots, automodReconciled, voiceNoteHeal, attachmentHeal, embedHeal, reactionHeal, stickerHeal, pinHeal, searchHeal, threadHeal, memberHeal, voiceOccHeal, pollHeal, scheduledHeal }
const notificationHeal = await this._healNotificationInboxOnPartition(gid).catch(() => ({ relisted: 0 }))
const activityHeal = await this._healActivityFeedWatermarkOnPartition(gid).catch(() => ({ relisted: 0 }))
return { voiceApplied, emojiSlots, automodReconciled, voiceNoteHeal, attachmentHeal, embedHeal, reactionHeal, stickerHeal, pinHeal, searchHeal, threadHeal, memberHeal, voiceOccHeal, pollHeal, scheduledHeal, notificationHeal, activityHeal }
}
async _healReactionListOnPartition (guildId) {
@@ -11039,7 +11041,9 @@ class PearcordPlatform extends EventEmitter {
: await this.db.find(COLLECTIONS.MEMBERS, { guildId: msg.guildId })
const usersById = await this._usersById(members)
const plain = this._messagePlaintext(msg)
const mentioned = resolveMentionedUserIds(plain, members, usersById)
let mentioned = resolveMentionedUserIds(plain, members, usersById)
const roleMentionUserIds = await this._resolveRoleMentionUserIds(plain, members).catch(() => [])
mentioned = this._expandMentionUserIds(plain, members, usersById, mentioned)
if (mentioned.includes(user.id)) {
const prev = await this.db.get(COLLECTIONS.MENTION_ALERTS, {
userId: user.id,
@@ -11098,6 +11102,7 @@ class PearcordPlatform extends EventEmitter {
channelType: ch?.type || null,
parentChannelName,
mentionedUserIds: mentioned,
roleMentionUserIds,
replyToAuthorId,
members,
usersById
@@ -11120,6 +11125,7 @@ class PearcordPlatform extends EventEmitter {
channelType: ctx.channelType || null,
parentChannelName: ctx.parentChannelName || null,
mentionedUserIds: ctx.mentionedUserIds,
roleMentionUserIds: ctx.roleMentionUserIds || [],
replyToAuthorId: ctx.replyToAuthorId,
activeChannelId: this.activeChannelId,
authorName
@@ -17249,6 +17255,13 @@ class PearcordPlatform extends EventEmitter {
if (targetUserId === user.id && this.voiceMedia) {
await this.setVoiceMute({ muted: false, deafened: false })
}
if (targetUserId === user.id) {
await this.notifyStageSpeakerPromoted?.({
channelId,
guildId: guild.id,
channelName: ch?.name
}).catch(() => {})
}
this.emit('stage', row)
span.end({
spanKind: 'stage.speaker.approve',
@@ -21491,6 +21504,8 @@ class PearcordPlatform extends EventEmitter {
const roles = await this._memberRoles()
if (!roles) throw new Error('not a guild member')
await this._ensureGuildModules()
const prevBoost = await this.boosts.get(this.guild.guild.id).catch(() => null)
const prevLevel = prevBoost?.level || 0
const attribution = {
userId: user.id,
username: user.username,
@@ -21502,6 +21517,13 @@ class PearcordPlatform extends EventEmitter {
amount
)
this._gossipGuildBoostState(row, attribution)
if ((row.level || 0) > prevLevel) {
await this.notifyGuildBoostLevelUp?.({
level: row.level,
guildId: row.guildId,
guildName: this.guild.guild.name
}).catch(() => {})
}
await this._audit('guild.boost.contribute', {
guildId: row.guildId,
targetId: String(row.boostCount),
@@ -21518,12 +21540,21 @@ class PearcordPlatform extends EventEmitter {
throw new Error('no permission to boost guild')
}
await this._ensureGuildModules()
const prevBoost = await this.boosts.get(this.guild.guild.id).catch(() => null)
const prevLevel = prevBoost?.level || 0
const user = this.identity?.user
const attribution = user
? { userId: user.id, username: user.username, displayName: user.displayName }
: null
const row = await this.boosts.addBoost(this.guild.guild.id, amount, attribution)
this._gossipGuildBoostState(row, attribution)
if ((row.level || 0) > prevLevel) {
await this.notifyGuildBoostLevelUp?.({
level: row.level,
guildId: row.guildId,
guildName: this.guild.guild.name
}).catch(() => {})
}
await this._audit('guild.boost', {
guildId: row.guildId,
targetId: String(row.boostCount),
@@ -25920,4 +25951,6 @@ class PearcordPlatform extends EventEmitter {
module.exports = { PearcordPlatform, USER_STATUS }
const { pollSchedulingMixin } = require('./polls-scheduling')
const { notificationsActivityMixin } = require('./notifications-activity')
Object.assign(PearcordPlatform.prototype, pollSchedulingMixin)
Object.assign(PearcordPlatform.prototype, notificationsActivityMixin)