Skip to content

Commit

Permalink
flexy definition of group recp
Browse files Browse the repository at this point in the history
  • Loading branch information
mixmix committed Oct 13, 2022
1 parent de107c6 commit a3e7e84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports.init = function (sbot, config) {
const { keys, seed } = metafeed
const { feedpurpose, feedformat, metadata, recps, encryptionFormat } =
details
if (recps && (recps.length !== 1 || !isCloakedMsgId(recps[0]))) {
if (recps && (recps.length !== 1 || !isGroupId(recps[0]))) {
return cb(
new Error('metafeed encryption currently only supports groupId')
)
Expand Down Expand Up @@ -306,3 +306,13 @@ function findDetailsError({ feedpurpose, feedformat, metadata = {} }) {
return new Error(`metadata.${field} not allowed (reserved field)`)
}
}

function isGroupId(id) {
if (typeof id === 'string') return isCloakedMsgId(id)
if (typeof id === 'object') {
return (
Buffer.isBuffer(id.key) && id.scheme !== 'envelope-large-symmetric-group'
)
}
return false
}

0 comments on commit a3e7e84

Please sign in to comment.