demokratie-live / human-connection-api-nodejs-client

Human Connection Node.js API Client
Apache License 2.0
5 stars 2 forks source link

🐛 Gateway Timeout when trying to post an invalid ImageUrl #3

Open ulfgebhardt opened 5 years ago

ulfgebhardt commented 5 years ago

image

{
error: "Cannot create post. Error: Gateway Time-out",
succeeded: false
}
import { User, connect } from 'human-connection-api-nodejs-client';
import mongoose from 'mongoose';
import slugify from 'slugify';
import CONSTANTS from '../../../config/constants';
import { getImage } from './subjectGroupToIcon';

async function contributeProcedure({ procedureId, email, password }) {
  connect(CONSTANTS.HC_BACKEND_URL);
  const ProcedureModel = mongoose.model('Procedure');
  if (procedureId && email && password) {
    const procedure = await ProcedureModel.findOne({ procedureId });
    if (procedure) {
      const user = new User({ email, password });
      return user.contribute(
        {
          title: procedure.title,
          content: procedure.abstract,
          contentExcerpt: procedure.abstract,
          type: 'post',
          language: 'de',
          teaserImg: `https://www.democracy-app.de/static/images/sachgebiete/${getImage(
            procedure.subjectGroups[0],
          )}_1920.jpg`,
        },
        {
          slug: slugify(procedure.title, { lower: true }),
          resolveSlugs: {
            categories: ['democracy-politics'],
            // organization: CONSTANTS.HC_ORGANIZATION_SLUG,
          },
        },
      );
    }
    throw Error('No procedure found.');
  } else {
    throw Error('Please provide procedureId, email and password.');
  }
}

See: https://github.com/demokratie-live/democracy-server/blob/hc_webhook/src/express/webhooks/socialmedia/humanconnection.js

This error occurs when the URL to the teaserImage is invalid ?!

ulfgebhardt commented 5 years ago

The request of the Image returned the Error - a more accurate Error message would be appricated