Phase 433: DM and contacts error logging for diagnostics.

Log dm.open, dm.group, and contacts request/accept/decline failures
so the dm-errors dev-log filter surfaces actionable inbox issues.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-23 17:53:35 -04:00
co-authored by Cursor
parent 2da13ea78b
commit 23c10599d7
+82 -35
View File
@@ -902,40 +902,63 @@ class PearcordPlatform extends EventEmitter {
}
async openDM ({ peerUserId, peerDisplayName }) {
await this._initDmSession()
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)
return channel
try {
await this._initDmSession()
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)
return channel
} catch (err) {
this.log.error('dm.open error', {
peerUserId,
err: err?.message || String(err)
})
throw err
}
}
async createGroupDM ({ peerUserIds, name }) {
await this._initDmSession()
const channel = await this.dm.openGroup({
peerUserIds: peerUserIds || [],
displayName: name
})
this.dm.gossipGroupUpsert({
...channel,
participantIds: channel.participantIds
})
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)
return channel
try {
await this._initDmSession()
const channel = await this.dm.openGroup({
peerUserIds: peerUserIds || [],
displayName: name
})
this.dm.gossipGroupUpsert({
...channel,
participantIds: channel.participantIds
})
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)
return channel
} catch (err) {
this.log.error('dm.group error', {
err: err?.message || String(err)
})
throw err
}
}
async openGroupDM ({ channelId }) {
await this._initDmSession()
const channel = await this.dm.openChannelById(channelId)
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)
return channel
try {
await this._initDmSession()
const channel = await this.dm.openChannelById(channelId)
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)
return channel
} catch (err) {
this.log.error('dm.open error', {
channelId,
err: err?.message || String(err)
})
throw err
}
}
_ingestPeerCosmetics (payload) {
@@ -1144,19 +1167,43 @@ class PearcordPlatform extends EventEmitter {
}
async sendFriendRequest ({ peerUserId, peerDisplayName }) {
if (!this.contacts) await this._joinContactsMesh()
if (!this.contacts) throw new Error('contacts unavailable')
return this.contacts.sendRequest({ peerUserId, peerDisplayName })
try {
if (!this.contacts) await this._joinContactsMesh()
if (!this.contacts) throw new Error('contacts unavailable')
return await this.contacts.sendRequest({ peerUserId, peerDisplayName })
} catch (err) {
this.log.error('contacts.request error', {
peerUserId,
err: err?.message || String(err)
})
throw err
}
}
async acceptFriendRequest (peerUserId) {
if (!this.contacts) throw new Error('contacts unavailable')
return this.contacts.acceptRequest(peerUserId)
try {
if (!this.contacts) throw new Error('contacts unavailable')
return await this.contacts.acceptRequest(peerUserId)
} catch (err) {
this.log.error('contacts.accept error', {
peerUserId,
err: err?.message || String(err)
})
throw err
}
}
async declineFriendRequest (peerUserId) {
if (!this.contacts) throw new Error('contacts unavailable')
return this.contacts.declineRequest(peerUserId)
try {
if (!this.contacts) throw new Error('contacts unavailable')
return await this.contacts.declineRequest(peerUserId)
} catch (err) {
this.log.error('contacts.decline error', {
peerUserId,
err: err?.message || String(err)
})
throw err
}
}
async removeContact (peerUserId) {