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 | 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 3x 2x 1x 1x | /**
* GET /v1/moderation/me
*
* The caller's moderation standing: review points (spent to publish, earned by
* voting), reputation and vote counters. Reputation is informative — it blocks
* nothing.
*
* @implements UC-MOD-005.1, UC-MOD-009.1
*/
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb')
const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb')
const { authenticateModerator, errorResponse, jsonResponse } = require('../utils/moderation/access')
const { getStats } = require('../utils/moderation/engine')
const itemComment = require('../utils/moderation/subjects/itemComment')
const client = new DynamoDBClient({})
const docClient = DynamoDBDocumentClient.from(client)
exports.handler = async (event) => {
try {
const caller = await authenticateModerator(event)
if (caller.response) return caller.response
const stats = await getStats(docClient, caller.auth.userId)
return jsonResponse(200, {
...stats,
quota: { required: itemComment.quotaCost, have: stats.reviewPoints }
})
} catch (error) {
console.error('[moderation/me] Exception:', error.message, error.stack)
return errorResponse(500, 'Failed to load moderation stats')
}
}
|