From 763ec56af938b4b1bed7209362aceb65c63b6abc Mon Sep 17 00:00:00 2001 From: Saif Al Falah Date: Sat, 18 Dec 2021 23:34:34 +0530 Subject: [PATCH] fixing bug --- src/http/post-index/helpers.js | 3 ++- src/http/post-index/index.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/http/post-index/helpers.js b/src/http/post-index/helpers.js index 8c674f2..2946d35 100644 --- a/src/http/post-index/helpers.js +++ b/src/http/post-index/helpers.js @@ -76,7 +76,8 @@ exports.checkIfContainsVideoOrGif = (data) => { !data.hasOwnProperty("extended_entities") || !data.extended_entities.media[0].video_info ) - throw new Error(605); + return false; + else return true; }; exports.getBitrate = (data) => { diff --git a/src/http/post-index/index.js b/src/http/post-index/index.js index c6ab62f..1696997 100644 --- a/src/http/post-index/index.js +++ b/src/http/post-index/index.js @@ -88,13 +88,16 @@ exports.handler = async function http(req) { data = data.data; - // If it is a quoted tweet, we find the data for the tweet quoted - if (data.quoted_status_id) { - data = data.quoted_status; + // If video is not found, we check if it is a quoted tweet + if (!checkIfContainsVideoOrGif(data)) { + if (data.quoted_status_id) { + // If it is a quoted tweet, we find the data for the tweet quoted + data = data.quoted_status; + // Check for the video in the quoted tweet. If we still can't find video, we throw error + if (!checkIfContainsVideoOrGif(data)) throw new Error(605); + } else throw new Error(605); } - checkIfContainsVideoOrGif(data); - // Getting bitrate to calculate the size of the video let bitrates = getBitrate(data);