Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 5x 5x 5x 3x 3x 3x 2x 1x 1x 1x | /**
* DELETE /v1/entities/{entityId}/comment-blocks/{userId}
* DELETE /v1/store/{packId}/comment-blocks/{userId}
*
* Lets a blocked user comment on the entity or pack again. Only its managers
* and platform admins may. Idempotent: unblocking somebody who is not blocked
* succeeds.
*
* @implements UC-COMMENT-007.1, UC-STORE-009.1
*/
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb')
const { DynamoDBDocumentClient, DeleteCommand } = require('@aws-sdk/lib-dynamodb')
const { resolveManagerContext, errorResponse, CORS_HEADERS } = require('../utils/commentAccess')
const client = new DynamoDBClient({})
const docClient = DynamoDBDocumentClient.from(client)
exports.handler = async (event) => {
try {
const context = await resolveManagerContext(docClient, event)
if (context.response) return context.response
const { blocksKey } = context
const targetUserId = event.pathParameters?.userId
if (!targetUserId) return errorResponse(400, 'Missing userId')
await docClient.send(
new DeleteCommand({
TableName: process.env.COMMENT_BLOCKS_TABLE_NAME,
Key: { entityId: blocksKey, userId: targetUserId }
})
)
return { statusCode: 204, headers: CORS_HEADERS, body: '' }
} catch (error) {
console.error('[comments/unblock] Exception:', error.message, error.stack)
return errorResponse(500, 'Failed to unblock user')
}
}
|