feat(platform): extend discovery/DM span metadata for Phase 479
Add discovery.join span, discovery.list meshLive/filteredCount, dm.open reusedChannel, and contacts.accept accepted flag. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -39,6 +39,8 @@ Expose a single `EventEmitter` API the UI drives over IPC (`apps/pearcord/index.
|
||||
|
||||
**v0.8.430 (Phase 467):** `voice.leave` span `end` includes `leavingIsStage`; `screen.start` span `end` includes `label`. Bundle: `npm run test:phase467-voice-stage`. See [VOICE.md](../../docs/VOICE.md), [STAGE_CHANNELS.md](../../docs/STAGE_CHANNELS.md).
|
||||
|
||||
**v0.8.442 (Phase 479):** `discovery.list` `meshLive`/`filteredCount`; `discovery.join` on `joinPublicDiscovery`; `dm.open` `reusedChannel`; `contacts.accept` `accepted`. UI discovery compositor. Bundle: `npm run test:phase479-discovery`. See [DISCOVERY.md](../../docs/DISCOVERY.md).
|
||||
|
||||
**v0.8.441 (Phase 478):** `notification.markRead` `wasUnread`/`hadMessageId`; `notification.markAll` `unreadBefore`; `notification.open` `hasMessageId`; `inbox.mark-read` `clearedInboxCount`. UI `syncNotificationPanelsDuringGuildLoading` compositor. Bundle: `npm run test:phase478-notifications`. See [NOTIFICATIONS.md](../../docs/NOTIFICATIONS.md), [INBOX.md](../../docs/INBOX.md).
|
||||
|
||||
**v0.8.440 (Phase 477):** `message.send` `hasMention`/`isSlash`; `message.edit` `priorLength`; `message.delete` `hadAttachments`; `reaction.toggle` `emojiLength`; `pin.message`/`pin.unpin` span start `channelId`. UI `syncMessagingPanelsDuringGuildLoading`. Bundle: `npm run test:phase477-messaging`. See [MESSAGING.md](../../docs/MESSAGING.md), [REACTIONS.md](../../docs/REACTIONS.md).
|
||||
|
||||
@@ -12,7 +12,12 @@ const { PearcordGuild } = require('pearcord-guild')
|
||||
const { PearcordMessage } = require('pearcord-message')
|
||||
const { PearcordPresence } = require('pearcord-presence')
|
||||
const { PearcordInvite } = require('pearcord-invite')
|
||||
const { PearcordDM, DM_GUILD_ID, listDmConversations } = require('pearcord-dm')
|
||||
const {
|
||||
PearcordDM,
|
||||
DM_GUILD_ID,
|
||||
dmChannelId,
|
||||
listDmConversations
|
||||
} = require('pearcord-dm')
|
||||
const { PearcordAttachments } = require('pearcord-attachments')
|
||||
const { PearcordModeration } = require('pearcord-moderation')
|
||||
const { PearcordVoice } = require('pearcord-voice')
|
||||
@@ -921,12 +926,25 @@ class PearcordPlatform extends EventEmitter {
|
||||
const span = this.log.time('dm.open', { peerUserId: peerUserId || null })
|
||||
try {
|
||||
await this._initDmSession()
|
||||
const uid = this.identity?.user?.id
|
||||
const reusedChannel =
|
||||
uid && peerUserId
|
||||
? !!(await this.db.get(COLLECTIONS.CHANNELS, {
|
||||
guildId: DM_GUILD_ID,
|
||||
id: dmChannelId(uid, peerUserId)
|
||||
}))
|
||||
: false
|
||||
const channel = await this.dm.openWithPeer({ peerUserId, peerDisplayName })
|
||||
this.messages.setChannel({ channelId: channel.id, guildId: DM_GUILD_ID })
|
||||
this.activeChannelId = channel.id
|
||||
await this.markChannelRead(channel.id, DM_GUILD_ID)
|
||||
this.emit('dm', channel)
|
||||
span.end({ channelId: channel.id, group: false, peerUserId: peerUserId || null })
|
||||
span.end({
|
||||
channelId: channel.id,
|
||||
group: false,
|
||||
peerUserId: peerUserId || null,
|
||||
reusedChannel
|
||||
})
|
||||
return channel
|
||||
} catch (err) {
|
||||
this.log.error('dm.open error', {
|
||||
@@ -956,7 +974,7 @@ class PearcordPlatform extends EventEmitter {
|
||||
return channel
|
||||
} catch (err) {
|
||||
this.log.error('dm.group error', {
|
||||
err: err?.message || String(err)
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
throw err
|
||||
}
|
||||
@@ -1229,7 +1247,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
try {
|
||||
if (!this.contacts) throw new Error('contacts unavailable')
|
||||
const row = await this.contacts.acceptRequest(peerUserId)
|
||||
span.end({ status: row?.status || null, peerUserId: peerUserId || null })
|
||||
span.end({
|
||||
status: row?.status || null,
|
||||
peerUserId: peerUserId || null,
|
||||
accepted: row?.status === 'friend'
|
||||
})
|
||||
return row
|
||||
} catch (err) {
|
||||
this.log.error('contacts.accept error', {
|
||||
@@ -7434,7 +7456,20 @@ class PearcordPlatform extends EventEmitter {
|
||||
|
||||
async joinPublicDiscovery (inviteCode) {
|
||||
if (!inviteCode) throw new Error('invite code required')
|
||||
return this.joinInvite(inviteCode)
|
||||
const span = this.log.time('discovery.join', {
|
||||
inviteLen: String(inviteCode).length
|
||||
})
|
||||
try {
|
||||
const guild = await this.joinInvite(inviteCode)
|
||||
span.end({ guildId: guild?.id || null, joined: !!guild })
|
||||
return guild
|
||||
} catch (err) {
|
||||
this.log.error('discovery.join error', {
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
span.end()
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async _memberRoles () {
|
||||
@@ -11914,9 +11949,16 @@ class PearcordPlatform extends EventEmitter {
|
||||
if (!light) {
|
||||
const listSpan = this.log.time('discovery.list', {})
|
||||
publicListings = await this.discovery.listPublicListings()
|
||||
const filter = this._discoveryFilter
|
||||
const filteredCount = this.discovery
|
||||
? this.discovery.filterPublicListings(publicListings, filter).length
|
||||
: publicListings.length
|
||||
listSpan.end({
|
||||
count: publicListings.length,
|
||||
filterTag: this._discoveryFilter?.tag || null
|
||||
filterTag: filter?.tag || null,
|
||||
meshLive: (this.discovery?.peers?.size || 0) > 0,
|
||||
fromCache: false,
|
||||
filteredCount
|
||||
})
|
||||
} else {
|
||||
publicListings = await this.discovery.listPublicListings()
|
||||
|
||||
Reference in New Issue
Block a user