Phase 664: groupDmVoiceNoteMaxBytes helper for per-participant quota.
Export groupDmVoiceNoteMaxBytes from voice-note-wire for group DM voice message size limits divided by participant count. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -682,7 +682,8 @@ const {
|
||||
VOICE_NOTE_MAX_BYTES,
|
||||
validateVoiceNoteCreatePayload,
|
||||
normalizeWaveformPeaks,
|
||||
buildVoiceNoteCreatePayload
|
||||
buildVoiceNoteCreatePayload,
|
||||
groupDmVoiceNoteMaxBytes
|
||||
} = require('./voice-note-wire')
|
||||
module.exports = {
|
||||
isBenignSwarmError,
|
||||
@@ -782,5 +783,6 @@ module.exports = {
|
||||
VOICE_NOTE_MAX_BYTES,
|
||||
validateVoiceNoteCreatePayload,
|
||||
normalizeWaveformPeaks,
|
||||
buildVoiceNoteCreatePayload
|
||||
buildVoiceNoteCreatePayload,
|
||||
groupDmVoiceNoteMaxBytes
|
||||
}
|
||||
|
||||
+13
-1
@@ -81,11 +81,23 @@ function buildVoiceNoteCreatePayload (row) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Per-participant byte cap for group DMs (P664-13).
|
||||
* @param {number} participantCount
|
||||
* @param {number} [globalMax]
|
||||
*/
|
||||
function groupDmVoiceNoteMaxBytes (participantCount, globalMax = VOICE_NOTE_MAX_BYTES) {
|
||||
const n = Math.max(1, Math.floor(Number(participantCount) || 1))
|
||||
const floor = 256 * 1024
|
||||
return Math.max(floor, Math.floor(Number(globalMax) / n))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
VOICE_NOTE_MIME_DEFAULT,
|
||||
VOICE_NOTE_MAX_DURATION_MS,
|
||||
VOICE_NOTE_MAX_BYTES,
|
||||
validateVoiceNoteCreatePayload,
|
||||
normalizeWaveformPeaks,
|
||||
buildVoiceNoteCreatePayload
|
||||
buildVoiceNoteCreatePayload,
|
||||
groupDmVoiceNoteMaxBytes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user