makeomatic/ms-files

View on GitHub
src/custom/cappasity-tag-file.js

Summary

Maintainability
A
0 mins
Test Coverage
async function tagFile(fileData) {
  const { amqp, config: { process: processConfig } } = this;
  // new owner format
  const { files, owner, bucket, uploadId } = fileData;
  const file = files.find((f) => f.type === 'c-preview');

  if (file === undefined) {
    return false;
  }

  await amqp.publish(
    `${processConfig.prefix}.${processConfig.postfix.annotate}`,
    { filename: file.filename, username: owner, bucket, uploadId }
  );

  return true;
}

module.exports = tagFile;