this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Handle no labels in emitEvent

futur 616372cb da368a20

+13 -2
+13 -2
src/LabelerServer.ts
··· 182 182 } 183 183 if (negate) { 184 184 for (const val of negate) { 185 - const created = await this.createLabel({ 185 + const negated = await this.createLabel({ 186 186 src: this.did, 187 187 uri, 188 188 ...(cid ? { cid } : {}), ··· 190 190 neg: true, 191 191 cts: new Date().toISOString(), 192 192 }); 193 - createdLabels.push(created); 193 + createdLabels.push(negated); 194 194 } 195 195 } 196 196 return createdLabels; ··· 400 400 throw new InvalidRequestError("Unsupported event type"); 401 401 } 402 402 const labelEvent = event as ToolsOzoneModerationDefs.ModEventLabel; 403 + 404 + if (!labelEvent.createLabelVals?.length && !labelEvent.negateLabelVals?.length) { 405 + throw new InvalidRequestError("Must provide at least one label value"); 406 + } 407 + 403 408 const uri = 404 409 subject.$type === "com.atproto.admin.defs#repoRef" 405 410 && typeof subject.did === "string" ··· 423 428 create: labelEvent.createLabelVals, 424 429 negate: labelEvent.negateLabelVals, 425 430 }); 431 + 432 + if (!labels.length || !labels[0]?.id) { 433 + throw new Error( 434 + `No labels were created\nEvent:\n${JSON.stringify(labelEvent, null, 2)}`, 435 + ); 436 + } 426 437 427 438 await res.send( 428 439 {