@yrpri/api 9.0.101 → 9.0.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +11 -1
- package/active-citizen/llms/baseChatBot.js +8 -75
- package/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
- package/active-citizen/llms/imageGeneration/collectionImageGenerator.js +6 -0
- package/agents/assistants/agentAssistant.js +3 -2
- package/agents/assistants/baseAssistant.js +7 -30
- package/agents/assistants/baseAssistantWithVoice.js +3 -3
- package/agents/assistants/voiceAssistant.js +2 -2
- package/agents/controllers/agentProductController.js +2 -1
- package/agents/controllers/agentSubscriptionController.js +20 -11
- package/agents/controllers/assistantsController.js +171 -127
- package/agents/controllers/policySynthAgents.js +33 -12
- package/agents/managers/newAiModelSetup.js +96 -0
- package/agents/managers/subscriptionManager.js +2 -2
- package/app.js +12 -12
- package/authorization.cjs +4 -0
- package/controllers/allOurIdeas.js +2 -1
- package/controllers/communities.cjs +47 -1
- package/controllers/groups.cjs +67 -4
- package/controllers/index.cjs +7 -7
- package/controllers/nonSpa.cjs +1 -1
- package/dist/active-citizen/controllers/activities.cjs +174 -0
- package/dist/active-citizen/controllers/news_feeds.cjs +96 -0
- package/dist/active-citizen/controllers/notifications.cjs +243 -0
- package/dist/active-citizen/controllers/recommendations.cjs +280 -0
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +204 -0
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +66 -0
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +38 -0
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +334 -0
- package/dist/active-citizen/engine/analytics/importer.js +308 -0
- package/dist/active-citizen/engine/analytics/manager.cjs +377 -0
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +500 -0
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +194 -0
- package/dist/active-citizen/engine/analytics/utils.cjs +369 -0
- package/dist/active-citizen/engine/marketing/campaign.cjs +90 -0
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +313 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +239 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +211 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +120 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +114 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +101 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +84 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +15 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +133 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +185 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +184 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +170 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +109 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +140 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +279 -0
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +386 -0
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +49 -0
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +68 -0
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +288 -0
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +33 -0
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +56 -0
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +106 -0
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +344 -0
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +810 -0
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +15 -0
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +362 -0
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +268 -0
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +439 -0
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +569 -0
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +233 -0
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +118 -0
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +41 -0
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +148 -0
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +54 -0
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +31 -0
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +471 -0
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +212 -0
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +153 -0
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +80 -0
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +157 -0
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +139 -0
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +212 -0
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +83 -0
- package/dist/active-citizen/engine/reports/commonUtils.js +75 -0
- package/dist/active-citizen/engine/reports/common_utils.cjs +740 -0
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +596 -0
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +232 -0
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +277 -0
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +718 -0
- package/dist/active-citizen/llms/baseChatBot.js +183 -0
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +109 -0
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +84 -0
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +49 -0
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +64 -0
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +107 -0
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +110 -0
- package/dist/active-citizen/llms/llmTranslation.js +472 -0
- package/dist/active-citizen/models/ac_activity.cjs +216 -0
- package/dist/active-citizen/models/ac_background_job.cjs +109 -0
- package/dist/active-citizen/models/ac_campaign.cjs +97 -0
- package/dist/active-citizen/models/ac_client_activity.cjs +23 -0
- package/dist/active-citizen/models/ac_delayed_notification.cjs +43 -0
- package/dist/active-citizen/models/ac_following.cjs +43 -0
- package/dist/active-citizen/models/ac_list.cjs +68 -0
- package/dist/active-citizen/models/ac_list_users.cjs +19 -0
- package/dist/active-citizen/models/ac_mute.cjs +27 -0
- package/dist/active-citizen/models/ac_news_feed_item.cjs +57 -0
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +59 -0
- package/dist/active-citizen/models/ac_notification.cjs +292 -0
- package/dist/active-citizen/models/ac_translation_cache.cjs +750 -0
- package/dist/active-citizen/models/ac_watching.cjs +31 -0
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +13 -0
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +63 -0
- package/dist/active-citizen/scripts/kue_status.js +31 -0
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +24 -0
- package/dist/active-citizen/scripts/translation_clear_language.js +117 -0
- package/dist/active-citizen/scripts/translation_delete.js +27 -0
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +180 -0
- package/dist/active-citizen/scripts/translation_update.js +28 -0
- package/dist/active-citizen/scripts/translations_list.js +27 -0
- package/{active-citizen/utils/airbrake.js → dist/active-citizen/utils/airbrake.cjs} +1 -1
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +21 -0
- package/dist/active-citizen/utils/i18n.cjs +3 -0
- package/dist/active-citizen/utils/logger.cjs +25 -0
- package/dist/active-citizen/utils/redisConnection.cjs +29 -0
- package/dist/active-citizen/utils/to_json.cjs +9 -0
- package/dist/active-citizen/utils/translation_cloning.cjs +171 -0
- package/dist/active-citizen/utils/translation_helpers.cjs +534 -0
- package/dist/active-citizen/utils/truncate_text.cjs +21 -0
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +253 -0
- package/dist/active-citizen/utils/updateLocaleFolders.js +34 -0
- package/dist/active-citizen/workers/activity.cjs +189 -0
- package/dist/active-citizen/workers/anonymizations.cjs +734 -0
- package/dist/active-citizen/workers/bulk_status_update.cjs +458 -0
- package/dist/active-citizen/workers/delayed_jobs.cjs +244 -0
- package/dist/active-citizen/workers/deletions.cjs +1911 -0
- package/dist/active-citizen/workers/email.cjs +9 -0
- package/dist/active-citizen/workers/fraud_management.cjs +109 -0
- package/dist/active-citizen/workers/generativeAi.js +56 -0
- package/dist/active-citizen/workers/main.cjs +89 -0
- package/dist/active-citizen/workers/marketing.cjs +25 -0
- package/dist/active-citizen/workers/moderation.cjs +73 -0
- package/dist/active-citizen/workers/notification_delivery.cjs +368 -0
- package/dist/active-citizen/workers/notification_news_feed.cjs +142 -0
- package/dist/active-citizen/workers/queue.cjs +99 -0
- package/dist/active-citizen/workers/recount.cjs +74 -0
- package/dist/active-citizen/workers/reports.cjs +42 -0
- package/dist/active-citizen/workers/similarities.cjs +21 -0
- package/dist/active-citizen/workers/speech_to_text.cjs +482 -0
- package/dist/agents/assistants/agentAssistant.js +88 -0
- package/dist/agents/assistants/baseAssistant.js +888 -0
- package/dist/agents/assistants/baseAssistantWithVoice.js +150 -0
- package/dist/agents/assistants/modes/agentDirectConnection.js +84 -0
- package/dist/agents/assistants/modes/agentSelectionMode.js +44 -0
- package/dist/agents/assistants/modes/baseAssistantMode.js +54 -0
- package/dist/agents/assistants/modes/tools/agentTools.js +447 -0
- package/dist/agents/assistants/modes/tools/baseTools.js +58 -0
- package/dist/agents/assistants/modes/tools/loginTools.js +156 -0
- package/dist/agents/assistants/modes/tools/models/agents.js +146 -0
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +332 -0
- package/dist/agents/assistants/modes/tools/models/users.js +11 -0
- package/dist/agents/assistants/modes/tools/navigationTools.js +166 -0
- package/{agents/assistants/modes/tools/workflowConversationTools.js → dist/agents/assistants/modes/tools/subscriptionTools.js} +1 -4
- package/{agents/assistants/modes/tools/workflowTools.js → dist/agents/assistants/modes/tools/workflowConverstationTools.js} +1 -1
- package/dist/agents/assistants/voiceAssistant.js +619 -0
- package/dist/agents/controllers/agentProductController.js +103 -0
- package/dist/agents/controllers/agentSubscriptionController.js +261 -0
- package/dist/agents/controllers/assistantsController.js +511 -0
- package/dist/agents/controllers/policySynthAgents.js +395 -0
- package/{agents → dist/agents/managers}/agentProductManager.js +2 -2
- package/dist/agents/managers/emailInvitesManager.js +55 -0
- package/dist/agents/managers/emailTemplateRenderer.js +362 -0
- package/dist/agents/managers/newAiModelSetup.js +650 -0
- package/dist/agents/managers/notificationAgentQueueManager.js +510 -0
- package/dist/agents/managers/subscriptionManager.js +535 -0
- package/dist/agents/managers/workflowConversationManager.js +79 -0
- package/dist/agents/models/agentProduct.js +116 -0
- package/dist/agents/models/agentProductBoosterPurchase.js +58 -0
- package/dist/agents/models/agentProductBundle.js +68 -0
- package/dist/agents/models/agentProductRun.js +52 -0
- package/dist/agents/models/discount.js +88 -0
- package/dist/agents/models/subscription.js +79 -0
- package/dist/agents/models/subscriptionPlan.js +46 -0
- package/dist/agents/models/subscriptionUser.js +27 -0
- package/dist/agents/models/testData/createEvolyAgentProduct.js +477 -0
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +230 -0
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +233 -0
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +230 -0
- package/{agents/models/workflowConverstation.js → dist/agents/models/workflowConversation.js} +1 -1
- package/{agents/tools/updateTemplateWorkflow.js → dist/agents/tools/setTemplateWorkflowCommunityId.js} +1 -0
- package/dist/app.js +943 -0
- package/dist/authorization.cjs +1860 -0
- package/dist/bot_control.js +1930 -0
- package/dist/config/config.cjs +14 -0
- package/dist/config/config.js +14 -0
- package/dist/controllers/allOurIdeas.js +696 -0
- package/dist/controllers/audios.cjs +100 -0
- package/dist/controllers/bulkStatusUpdates.cjs +202 -0
- package/dist/controllers/categories.cjs +199 -0
- package/dist/controllers/communities.cjs +2996 -0
- package/dist/controllers/domains.cjs +1341 -0
- package/dist/controllers/externalIds.cjs +223 -0
- package/dist/controllers/groups.cjs +4309 -0
- package/dist/controllers/images.cjs +499 -0
- package/dist/controllers/index.cjs +449 -0
- package/dist/controllers/legacyPages.cjs +35 -0
- package/dist/controllers/legacyPosts.cjs +56 -0
- package/dist/controllers/legacyUsers.cjs +36 -0
- package/dist/controllers/nonSpa.cjs +574 -0
- package/dist/controllers/organizations.cjs +250 -0
- package/dist/controllers/points.cjs +1137 -0
- package/dist/controllers/posts.cjs +2036 -0
- package/dist/controllers/ratings.cjs +234 -0
- package/dist/controllers/users.cjs +2255 -0
- package/dist/controllers/videos.cjs +226 -0
- package/dist/deleteUnwantedDeclerations.cjs +55 -0
- package/dist/migrations/agentAuditLogs.cjs +46 -0
- package/dist/migrations/agentClasses.cjs +60 -0
- package/dist/migrations/agentConnectorClasses.cjs +61 -0
- package/dist/migrations/agentConnectors.cjs +50 -0
- package/dist/migrations/agentEvals.cjs +45 -0
- package/dist/migrations/agentRegistries.cjs +40 -0
- package/dist/migrations/agents.cjs +54 -0
- package/dist/migrations/aiModels.cjs +49 -0
- package/dist/migrations/apiUsage.cjs +47 -0
- package/dist/migrations/apis.cjs +49 -0
- package/dist/migrations/groupPrivateData.cjs +30 -0
- package/dist/migrations/modelUsage.cjs +60 -0
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +23 -0
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +360 -0
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +29 -0
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +43 -0
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +24 -0
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +29 -0
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +22 -0
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +23 -0
- package/{migrations/200824_create_embeddings_and_org_update.cjs → dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js} +6 -3
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +43 -0
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +36 -0
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +41 -0
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +88 -0
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +33 -0
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +38 -0
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +19 -0
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +19 -0
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +127 -0
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +68 -0
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +63 -0
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +14 -0
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +71 -0
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +12 -0
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +46 -0
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +46 -0
- package/dist/migrations/privateAccessStore.cjs +55 -0
- package/dist/migrations/zzz_associations.cjs +154 -0
- package/dist/migrations/zzzzz_create_agent_runs.cjs +606 -0
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +11 -0
- package/dist/migrations/zzzzzzz_create_trees.cjs +81 -0
- package/dist/models/audio.cjs +430 -0
- package/dist/models/bulk_status_update.cjs +58 -0
- package/dist/models/campaign.cjs +78 -0
- package/dist/models/category.cjs +94 -0
- package/dist/models/community.cjs +337 -0
- package/dist/models/domain.cjs +486 -0
- package/dist/models/endorsement.cjs +39 -0
- package/dist/models/general_data_store.cjs +20 -0
- package/dist/models/group.cjs +728 -0
- package/dist/models/image.cjs +579 -0
- package/dist/models/index.cjs +186 -0
- package/dist/models/invite.cjs +48 -0
- package/dist/models/iso_country.cjs +16 -0
- package/dist/models/organization.cjs +122 -0
- package/dist/models/page.cjs +273 -0
- package/dist/models/point.cjs +622 -0
- package/dist/models/point_quality.cjs +39 -0
- package/dist/models/point_revision.cjs +47 -0
- package/dist/models/post.cjs +680 -0
- package/dist/models/post_revision.cjs +38 -0
- package/dist/models/post_status_change.cjs +35 -0
- package/dist/models/promotion.cjs +34 -0
- package/dist/models/rating.cjs +51 -0
- package/dist/models/relationship.cjs +19 -0
- package/dist/models/request_to_join.cjs +20 -0
- package/dist/models/user.cjs +604 -0
- package/dist/models/user_legacy_password.cjs +13 -0
- package/dist/models/video.cjs +1137 -0
- package/dist/publish.js +40 -0
- package/dist/repack.js +53 -0
- package/dist/scripts/addRatingUsersToGroup.js +51 -0
- package/dist/scripts/addUserToOrganization.js +71 -0
- package/dist/scripts/analyseRatingsForCommunity.js +150 -0
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +28 -0
- package/dist/scripts/analyzeEndorsementsByCountry.js +70 -0
- package/dist/scripts/analyzePostsForCommunity.js +185 -0
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +14 -0
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +110 -0
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +116 -0
- package/{scripts/bulkStatusUpdates/performUpdateForGroup.js → dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs} +1 -2
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +141 -0
- package/dist/scripts/change/changeVideoAspectTo.js +34 -0
- package/dist/scripts/change/setUseNewVersion.cjs +22 -0
- package/dist/scripts/changeCommunityGroupcount.js +30 -0
- package/dist/scripts/changeCommunityPostCount.js +30 -0
- package/dist/scripts/changeGroupPostCount.js +30 -0
- package/dist/scripts/changeLanguage.js +50 -0
- package/dist/scripts/changeOfficalStatus.js +30 -0
- package/{scripts/cleanups/deleteAnonNotifications.js → dist/scripts/cleanups/deleteAnonNotifications.cjs} +1 -1
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +62 -0
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +72 -0
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +43 -0
- package/dist/scripts/clearAllEndorsementInGroup.js +50 -0
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +129 -0
- package/dist/scripts/cloning/cloneFromUrlScript.js +65 -0
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +140 -0
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +140 -0
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +131 -0
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +173 -0
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +18 -0
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +17 -0
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +17 -0
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +26 -0
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +205 -0
- package/dist/scripts/cloning/copyPostToGroupOld.js +397 -0
- package/dist/scripts/cloning/copyPostVideosFromURL.js +236 -0
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +17 -0
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +131 -0
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +139 -0
- package/dist/scripts/cloning/setAdminsFromURL.js +161 -0
- package/dist/scripts/cloning/setExternalIdsFromURL.js +129 -0
- package/dist/scripts/countCommunity.js +291 -0
- package/dist/scripts/countCommunityUsers.js +152 -0
- package/dist/scripts/countDelayedNotifications.js +18 -0
- package/dist/scripts/countGroup.js +246 -0
- package/dist/scripts/countStuff.js +67 -0
- package/dist/scripts/countUniqueVotersInAGroup.js +48 -0
- package/dist/scripts/createInvitesAndShow.js +75 -0
- package/dist/scripts/database/sync_database.js +14 -0
- package/dist/scripts/database/sync_dev_database.js +17 -0
- package/dist/scripts/debugNotifications.js +58 -0
- package/dist/scripts/deleteAllNewsFeeds.js +10 -0
- package/dist/scripts/deleteCategory.js +13 -0
- package/dist/scripts/deleteOldAppActivities.js +40 -0
- package/dist/scripts/deletePostContactDataForCommunity.js +53 -0
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +1026 -0
- package/dist/scripts/displayAuthorForPost.js +16 -0
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +183 -0
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +208 -0
- package/dist/scripts/exportAllStatusChanges.js +36 -0
- package/dist/scripts/exportClientAcitivity.js +36 -0
- package/dist/scripts/exportEndorsementsForCommunity.js +79 -0
- package/dist/scripts/exportPointQualitiesForCommunity.js +84 -0
- package/dist/scripts/exportPostsAndPointsForCommunity.js +147 -0
- package/dist/scripts/exportPostsDataSetForDomain.js +244 -0
- package/dist/scripts/exportPostsForGroup.js +173 -0
- package/dist/scripts/exportRatingsForPost.js +15 -0
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +123 -0
- package/dist/scripts/exportUsersForCommunity.js +24 -0
- package/dist/scripts/exportUsersForDomain.js +24 -0
- package/dist/scripts/exportUsersForGroup.js +24 -0
- package/dist/scripts/exports/ratingDistribution.js +71 -0
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +56 -0
- package/dist/scripts/findUnusedClientImports.js +56 -0
- package/dist/scripts/fixAllPostPointCounts.js +22 -0
- package/dist/scripts/fixAnonNotificationsSettings.js +48 -0
- package/dist/scripts/fixCountKopavogur.js +9 -0
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +190 -0
- package/dist/scripts/fixExternalUserId.js +24 -0
- package/dist/scripts/fixGroupAccess.js +16 -0
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +49 -0
- package/dist/scripts/fixNotificationSettings.js +39 -0
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +64 -0
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +49 -0
- package/dist/scripts/gallery/exportGalleryData.js +40 -0
- package/dist/scripts/gallery/importGalleryForCommunity.js +168 -0
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +55 -0
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +58 -0
- package/dist/scripts/genderAnalysis.js +63 -0
- package/dist/scripts/genderAnalysisByStatus.js +62 -0
- package/dist/scripts/importAllLocalesFromLocalFolders.js +55 -0
- package/dist/scripts/importDomain.js +1652 -0
- package/dist/scripts/keys/addOidcToDomain.cjs +61 -0
- package/dist/scripts/landUseGame/export3Ddata.js +162 -0
- package/dist/scripts/listLanguagesForGroup.js +54 -0
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +27 -0
- package/dist/scripts/makeRecursiveMapData.js +103 -0
- package/dist/scripts/mapping/community_map_csv.js +145 -0
- package/dist/scripts/moveCommunityToDomain.js +22 -0
- package/dist/scripts/moveGroupToCommunity.js +23 -0
- package/dist/scripts/movePostToGroup.js +101 -0
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +297 -0
- package/dist/scripts/oldMovePostToGroup.js +153 -0
- package/dist/scripts/processCsvForPdfUrls.js +37 -0
- package/dist/scripts/processCsvForTranslationAndToxicity.js +125 -0
- package/dist/scripts/recount/recount_recursive_communities.js +125 -0
- package/dist/scripts/recountALLCommunityGroupCounts.js +37 -0
- package/dist/scripts/recountAll.js +97 -0
- package/dist/scripts/recountCommunitesFromUrl.js +58 -0
- package/dist/scripts/recountCommunity.js +19 -0
- package/dist/scripts/recountGroup.js +218 -0
- package/dist/scripts/recountGroupNoUserChange.js +219 -0
- package/dist/scripts/resetAllEndorsementsForGroup.js +57 -0
- package/dist/scripts/resetEnTranslationForGroup.js +45 -0
- package/dist/scripts/setAdminOnAll.cjs +107 -0
- package/{scripts/change → dist/scripts}/setDomainAdmin.cjs +0 -2
- package/dist/scripts/setDomainLocales.js +33 -0
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +29 -0
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +86 -0
- package/dist/scripts/setMemberOfAll.js +101 -0
- package/dist/scripts/setNewUserForContentOfCommunity.js +189 -0
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +35 -0
- package/dist/scripts/setUserOnAll.js +101 -0
- package/dist/scripts/showCategoryForGroup.js +18 -0
- package/dist/scripts/showOldActivityTypes.js +14 -0
- package/dist/scripts/showPostsMissingCategoryForGroup.js +17 -0
- package/dist/scripts/showStatuses.js +17 -0
- package/dist/scripts/showUniqueVotersInCommunity.js +61 -0
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +66 -0
- package/dist/scripts/simpleExportForGroupsForCommunity.js +46 -0
- package/dist/scripts/simpleExportForPointsForCommunity.js +82 -0
- package/dist/scripts/simpleExportForPostsForCommunity.js +61 -0
- package/dist/scripts/testForEndorsments.js +21 -0
- package/dist/scripts/undeleteGroupAndAllContent.js +151 -0
- package/dist/scripts/undeletePost.js +135 -0
- package/dist/scripts/unlinkSsn.js +23 -0
- package/dist/scripts/updateFromAlthingi.js +303 -0
- package/dist/server.js +3 -0
- package/dist/utils/airbrake.cjs +17 -0
- package/dist/utils/cjsCodeReview.js +99 -0
- package/dist/utils/community_mapping_tools.cjs +124 -0
- package/dist/utils/copy_utils.cjs +1399 -0
- package/dist/utils/docx_utils.cjs +464 -0
- package/dist/utils/export_utils.cjs +491 -0
- package/dist/utils/i18n.cjs +17 -0
- package/dist/utils/is_valid_db_id.cjs +28 -0
- package/dist/utils/logger.cjs +25 -0
- package/dist/utils/loggerTs.js +26 -0
- package/dist/utils/manifest_generator.cjs +104 -0
- package/dist/utils/parse_domain.cjs +16 -0
- package/dist/utils/recount_utils.cjs +415 -0
- package/dist/utils/sharing_parameters.cjs +111 -0
- package/dist/utils/sitemap_generator.cjs +286 -0
- package/dist/utils/to_json.cjs +14 -0
- package/dist/utils/ypLanguages.js +747 -0
- package/dist/webSockets.js +77 -0
- package/package.json +46 -44
- package/server.d.ts +104 -2
- package/utils/copy_utils.cjs +7 -1
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts +0 -21
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts +0 -12
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts.map +0 -1
- package/active-citizen/engine/analytics/export_anon_community_activities.d.ts.map +0 -1
- package/active-citizen/engine/analytics/importer.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/categories_dataset.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/dataset_tools.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/sentiment_dataset.d.ts.map +0 -1
- package/active-citizen/engine/reports/xls_all_our_ideas_export.js +0 -141
- package/active-citizen/llms/baseChatBot.d.ts +0 -51
- package/active-citizen/llms/baseChatBot.d.ts.map +0 -1
- package/active-citizen/llms/collectionImageGenerator.js +0 -357
- package/active-citizen/llms/llmTranslation.d.ts +0 -24
- package/active-citizen/llms/llmTranslation.d.ts.map +0 -1
- package/active-citizen/scripts/fix_old_delayed_notifications.d.ts.map +0 -1
- package/active-citizen/scripts/kue_status.d.ts.map +0 -1
- package/active-citizen/scripts/kue_watch_stuck_jobs.d.ts.map +0 -1
- package/active-citizen/scripts/translation_clear_language.d.ts.map +0 -1
- package/active-citizen/scripts/translation_delete.d.ts.map +0 -1
- package/active-citizen/scripts/translation_replace_text_from_url.d.ts.map +0 -1
- package/active-citizen/scripts/translation_update.d.ts.map +0 -1
- package/active-citizen/scripts/translations_list.d.ts.map +0 -1
- package/active-citizen/utils/airbrake.d.ts.map +0 -1
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts +0 -21
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts.map +0 -1
- package/active-citizen/utils/updateLocaleFolders.d.ts +0 -2
- package/active-citizen/utils/updateLocaleFolders.d.ts.map +0 -1
- package/active-citizen/workers/cloudflare/voiceSession/worker.js +0 -213
- package/active-citizen/workers/generativeAi.d.ts.map +0 -1
- package/agents/assistants/agentAssistantOld.js +0 -863
- package/agents/assistants/modes/agentConfigurationMode.js +0 -63
- package/agents/assistants/modes/agentOperationsMode.js +0 -195
- package/agents/assistants/modes/commonTools.js +0 -58
- package/agents/assistants/modes/directConversationMode.js +0 -14
- package/agents/assistants/modes/toolHandlers/accountHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/commonHandlers.js +0 -57
- package/agents/assistants/modes/toolHandlers/commonTools.js +0 -58
- package/agents/assistants/modes/toolHandlers/loginHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/subscriptionHandlers.js +0 -469
- package/agents/assistants/modes/tools/agentConnectionTools.js +0 -326
- package/agents/assistants/modes/tools/commonHandlers.js +0 -57
- package/agents/assistants/modes/tools/loginHandlers.js +0 -46
- package/agents/assistants/modes/tools/subscriptionHandlers.js +0 -469
- package/agents/controllers/assistantController.js +0 -243
- package/agents/managers/workflowManager.js +0 -76
- package/agents/models/testData/setupConfig.js +0 -140
- package/agents/models/workflow.js +0 -53
- package/agents/subscriptionManager.js +0 -218
- package/app.d.ts +0 -40
- package/app.d.ts.map +0 -1
- package/bot_control.d.ts.map +0 -1
- package/publish.d.ts.map +0 -1
- package/repack.d.ts.map +0 -1
- package/scripts/addRatingUsersToGroup.d.ts.map +0 -1
- package/scripts/addUserToOrganization.d.ts.map +0 -1
- package/scripts/analyseRatingsForCommunity.d.ts.map +0 -1
- package/scripts/analyzeAndFixBrokenPointUsers.d.ts.map +0 -1
- package/scripts/analyzeEndorsementsByCountry.d.ts.map +0 -1
- package/scripts/analyzePostsForCommunity.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/listUpdates.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForGroup.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForStatus.d.ts.map +0 -1
- package/scripts/change/changeVideoAspectTo.d.ts.map +0 -1
- package/scripts/changeCommunityGroupcount.d.ts.map +0 -1
- package/scripts/changeCommunityPostCount.d.ts.map +0 -1
- package/scripts/changeGroupPostCount.d.ts.map +0 -1
- package/scripts/changeLanguage.d.ts.map +0 -1
- package/scripts/changeOfficalStatus.d.ts.map +0 -1
- package/scripts/cleanups/deleteAnonNotifications.d.ts.map +0 -1
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.d.ts.map +0 -1
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.d.ts.map +0 -1
- package/scripts/clearAllEndorsementInGroup.d.ts.map +0 -1
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.d.ts.map +0 -1
- package/scripts/cloning/cloneFromUrlScript.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.d.ts.map +0 -1
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithEverything.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.d.ts.map +0 -1
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostToGroupOld.d.ts.map +0 -1
- package/scripts/cloning/copyPostVideosFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.d.ts.map +0 -1
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/setAdminsFromURL.d.ts.map +0 -1
- package/scripts/cloning/setExternalIdsFromURL.d.ts.map +0 -1
- package/scripts/countCommunity.d.ts.map +0 -1
- package/scripts/countCommunityUsers.d.ts.map +0 -1
- package/scripts/countDelayedNotifications.d.ts.map +0 -1
- package/scripts/countGroup.d.ts.map +0 -1
- package/scripts/countStuff.d.ts.map +0 -1
- package/scripts/countUniqueVotersInAGroup.d.ts.map +0 -1
- package/scripts/createInvitesAndShow.d.ts.map +0 -1
- package/scripts/database/seedTestAiModels.js +0 -64
- package/scripts/database/sync_database.d.ts.map +0 -1
- package/scripts/database/sync_dev_database.d.ts.map +0 -1
- package/scripts/debugNotifications.d.ts.map +0 -1
- package/scripts/deleteAllNewsFeeds.d.ts.map +0 -1
- package/scripts/deleteCategory.d.ts.map +0 -1
- package/scripts/deleteOldAppActivities.d.ts.map +0 -1
- package/scripts/deletePostContactDataForCommunity.d.ts.map +0 -1
- package/scripts/destroy/destroy_all_but_one_domain.d.ts.map +0 -1
- package/scripts/displayAuthorForPost.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.d.ts.map +0 -1
- package/scripts/exportAllStatusChanges.d.ts.map +0 -1
- package/scripts/exportClientAcitivity.d.ts.map +0 -1
- package/scripts/exportEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/exportPointQualitiesForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsAndPointsForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsDataSetForDomain.d.ts.map +0 -1
- package/scripts/exportPostsForGroup.d.ts.map +0 -1
- package/scripts/exportRatingsForPost.d.ts.map +0 -1
- package/scripts/exportUserEndorsementsWithUserAnalysis.d.ts.map +0 -1
- package/scripts/exportUsersForCommunity.d.ts.map +0 -1
- package/scripts/exportUsersForDomain.d.ts.map +0 -1
- package/scripts/exportUsersForGroup.d.ts.map +0 -1
- package/scripts/exports/ratingDistribution.d.ts.map +0 -1
- package/scripts/exports/whoEndorsedWhatByCommunity.d.ts.map +0 -1
- package/scripts/findUnusedClientImports.d.ts.map +0 -1
- package/scripts/fixAllPostPointCounts.d.ts.map +0 -1
- package/scripts/fixAnonNotificationsSettings.d.ts.map +0 -1
- package/scripts/fixCountKopavogur.d.ts.map +0 -1
- package/scripts/fixEndorsementsAfterCopyPostToGroup.d.ts.map +0 -1
- package/scripts/fixExternalUserId.d.ts.map +0 -1
- package/scripts/fixGroupAccess.d.ts.map +0 -1
- package/scripts/fixGroupIdeasAndPointsCount.d.ts.map +0 -1
- package/scripts/fixNotificationSettings.d.ts.map +0 -1
- package/scripts/fixSurveyRadioBakedInSubCodes.d.ts.map +0 -1
- package/scripts/fixWrongUserIdForStatusUpdates.d.ts.map +0 -1
- package/scripts/gallery/exportGalleryData.d.ts.map +0 -1
- package/scripts/gallery/importGalleryForCommunity.d.ts.map +0 -1
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.d.ts.map +0 -1
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.d.ts.map +0 -1
- package/scripts/genderAnalysis.d.ts.map +0 -1
- package/scripts/genderAnalysisByStatus.d.ts.map +0 -1
- package/scripts/importAllLocalesFromLocalFolders.d.ts.map +0 -1
- package/scripts/importDomain.d.ts.map +0 -1
- package/scripts/landUseGame/export3Ddata.d.ts.map +0 -1
- package/scripts/listLanguagesForGroup.d.ts.map +0 -1
- package/scripts/loadTestCreateDummyContentForGroup.d.ts.map +0 -1
- package/scripts/makeRecursiveMapData.d.ts.map +0 -1
- package/scripts/mapping/community_map_csv.d.ts.map +0 -1
- package/scripts/moveCommunityToDomain.d.ts.map +0 -1
- package/scripts/moveGroupToCommunity.d.ts.map +0 -1
- package/scripts/movePostToGroup.d.ts.map +0 -1
- package/scripts/movePostsToGroupsRecountGroupFromUrl.d.ts.map +0 -1
- package/scripts/oldMovePostToGroup.d.ts.map +0 -1
- package/scripts/processCsvForPdfUrls.d.ts.map +0 -1
- package/scripts/processCsvForTranslationAndToxicity.d.ts.map +0 -1
- package/scripts/recount/recount_recursive_communities.d.ts.map +0 -1
- package/scripts/recountALLCommunityGroupCounts.d.ts.map +0 -1
- package/scripts/recountAll.d.ts.map +0 -1
- package/scripts/recountCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/recountCommunity.d.ts.map +0 -1
- package/scripts/recountGroup.d.ts.map +0 -1
- package/scripts/recountGroupNoUserChange.d.ts.map +0 -1
- package/scripts/resetAllEndorsementsForGroup.d.ts.map +0 -1
- package/scripts/resetEnTranslationForGroup.d.ts.map +0 -1
- package/scripts/setDomainLocales.d.ts.map +0 -1
- package/scripts/setLanguageOnGroupCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/setMemberOfAll.d.ts.map +0 -1
- package/scripts/setNewUserForContentOfCommunity.d.ts.map +0 -1
- package/scripts/setOfficialStatusOnAllPostsForCommunity.d.ts.map +0 -1
- package/scripts/setUserOnAll.d.ts.map +0 -1
- package/scripts/showCategoryForGroup.d.ts.map +0 -1
- package/scripts/showOldActivityTypes.d.ts.map +0 -1
- package/scripts/showPostsMissingCategoryForGroup.d.ts.map +0 -1
- package/scripts/showStatuses.d.ts.map +0 -1
- package/scripts/showUniqueVotersInCommunity.d.ts.map +0 -1
- package/scripts/showUserAgentsAndIpsForEmails.d.ts.map +0 -1
- package/scripts/simpleExportForGroupsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPointsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPostsForCommunity.d.ts.map +0 -1
- package/scripts/testForEndorsments.d.ts.map +0 -1
- package/scripts/undeleteGroupAndAllContent.d.ts.map +0 -1
- package/scripts/undeletePost.d.ts.map +0 -1
- package/scripts/unlinkSsn.d.ts.map +0 -1
- package/scripts/updateFromAlthingi.d.ts.map +0 -1
- package/server.d.ts.map +0 -1
- package/utils/copyGroup.js +0 -246
- package/utils/loggerTs.d.ts +0 -4
- package/utils/loggerTs.d.ts.map +0 -1
- package/utils/ypLanguages.d.ts +0 -18
- package/utils/ypLanguages.d.ts.map +0 -1
- /package/{agents/tools/updateCommunityWorkflow.js → dist/active-citizen/llms/imageGeneration/iImageGenerator.js} +0 -0
- /package/{migrations/270724_createUsersAndAdminsForClasses.cjs → dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs} +0 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const async = require("async");
|
|
3
|
+
const log = require("../utils/logger.cjs");
|
|
4
|
+
const aws = require("aws-sdk");
|
|
5
|
+
const _ = require("lodash");
|
|
6
|
+
const queue = require("../active-citizen/workers/queue.cjs");
|
|
7
|
+
let bullVideoQueue;
|
|
8
|
+
if (process.env.USE_YOUR_PRIORITIES_ENCODER) {
|
|
9
|
+
const Queue = require("bull");
|
|
10
|
+
const redisUrl = process.env.REDIS_URL ? process.env.REDIS_URL : undefined;
|
|
11
|
+
bullVideoQueue = new Queue("VideoEncoding", redisUrl);
|
|
12
|
+
}
|
|
13
|
+
module.exports = (sequelize, DataTypes) => {
|
|
14
|
+
const Video = sequelize.define("Video", {
|
|
15
|
+
name: DataTypes.STRING,
|
|
16
|
+
description: DataTypes.TEXT,
|
|
17
|
+
meta: DataTypes.JSONB,
|
|
18
|
+
public_meta: DataTypes.JSONB,
|
|
19
|
+
formats: DataTypes.JSONB,
|
|
20
|
+
views: { type: DataTypes.BIGINT, defaultValue: 0 },
|
|
21
|
+
long_views: { type: DataTypes.BIGINT, defaultValue: 0 },
|
|
22
|
+
user_id: DataTypes.INTEGER,
|
|
23
|
+
viewable: {
|
|
24
|
+
type: DataTypes.BOOLEAN,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
defaultValue: false,
|
|
27
|
+
},
|
|
28
|
+
ip_address: { type: DataTypes.STRING, allowNull: false },
|
|
29
|
+
user_agent: { type: DataTypes.TEXT, allowNull: false },
|
|
30
|
+
deleted: {
|
|
31
|
+
type: DataTypes.BOOLEAN,
|
|
32
|
+
allowNull: false,
|
|
33
|
+
defaultValue: false,
|
|
34
|
+
},
|
|
35
|
+
}, {
|
|
36
|
+
underscored: true,
|
|
37
|
+
timestamps: true,
|
|
38
|
+
createdAt: "created_at",
|
|
39
|
+
updatedAt: "updated_at",
|
|
40
|
+
tableName: "videos",
|
|
41
|
+
defaultScope: {
|
|
42
|
+
where: {
|
|
43
|
+
deleted: false,
|
|
44
|
+
},
|
|
45
|
+
order: [["created_at", "asc"]],
|
|
46
|
+
},
|
|
47
|
+
indexes: [
|
|
48
|
+
{
|
|
49
|
+
fields: ["meta"],
|
|
50
|
+
using: "gin",
|
|
51
|
+
operator: "jsonb_path_ops",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "videos_idx_deleted",
|
|
55
|
+
fields: ["deleted"],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
fields: ["public_meta"],
|
|
59
|
+
using: "gin",
|
|
60
|
+
operator: "jsonb_path_ops",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
fields: ["formats"],
|
|
64
|
+
using: "gin",
|
|
65
|
+
operator: "jsonb_path_ops",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
fields: ["user_id", "viewable", "deleted"],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
fields: ["id", "deleted"],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
fields: ["updated_at", "deleted"],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
fields: ["created_at", "deleted"],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
Video.associate = (models) => {
|
|
82
|
+
Video.belongsTo(models.User, { foreignKey: "user_id" });
|
|
83
|
+
Video.belongsToMany(models.Post, {
|
|
84
|
+
as: "PostVideos",
|
|
85
|
+
through: "PostVideo",
|
|
86
|
+
});
|
|
87
|
+
Video.belongsToMany(models.Image, {
|
|
88
|
+
as: "VideoImages",
|
|
89
|
+
through: "VideoImage",
|
|
90
|
+
});
|
|
91
|
+
Video.belongsToMany(models.Point, {
|
|
92
|
+
as: "PointVideos",
|
|
93
|
+
through: "PointVideo",
|
|
94
|
+
});
|
|
95
|
+
Video.belongsToMany(models.User, {
|
|
96
|
+
as: "UserProfileVideos",
|
|
97
|
+
through: "UserProfileVideo",
|
|
98
|
+
});
|
|
99
|
+
Video.belongsToMany(models.Community, {
|
|
100
|
+
as: "CommunityLogoVideos",
|
|
101
|
+
through: "CommunityLogoVideo",
|
|
102
|
+
});
|
|
103
|
+
Video.belongsToMany(models.Group, {
|
|
104
|
+
as: "GroupLogoVideos",
|
|
105
|
+
through: "GroupLogoVideo",
|
|
106
|
+
});
|
|
107
|
+
Video.belongsToMany(models.Group, {
|
|
108
|
+
as: "GroupHtmlVideos",
|
|
109
|
+
through: "GroupHtmlVideo",
|
|
110
|
+
});
|
|
111
|
+
Video.belongsToMany(models.Domain, {
|
|
112
|
+
as: "DomainLogoVideos",
|
|
113
|
+
through: "DomainLogoVideo",
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
Video.defaultAttributesPublic = ["id", "updated_at", "formats"];
|
|
117
|
+
Video.getRandomFileKey = (id) => {
|
|
118
|
+
const random = Math.random().toString(36).substring(2, 9);
|
|
119
|
+
return random + "_video" + id + ".mp4";
|
|
120
|
+
};
|
|
121
|
+
Video.getFullUrl = (meta) => {
|
|
122
|
+
if (meta) {
|
|
123
|
+
if (process.env.MINIO_ROOT_USER &&
|
|
124
|
+
process.env.NODE_ENV === "development") {
|
|
125
|
+
return meta.endPoint + "/" + meta.publicBucket + "/" + meta.fileKey;
|
|
126
|
+
}
|
|
127
|
+
else if (process.env.MINIO_ROOT_USER) {
|
|
128
|
+
return ("https://" +
|
|
129
|
+
meta.endPoint +
|
|
130
|
+
"/" +
|
|
131
|
+
meta.publicBucket +
|
|
132
|
+
"/" +
|
|
133
|
+
meta.fileKey);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
return ("https://" +
|
|
137
|
+
meta.publicBucket +
|
|
138
|
+
"." +
|
|
139
|
+
meta.endPoint +
|
|
140
|
+
"/" +
|
|
141
|
+
meta.fileKey);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
Video.getThumbnailUrl = (video, number) => {
|
|
146
|
+
const zerofilled = ("00000" + number).slice(-5);
|
|
147
|
+
const fileKey = video.meta.fileKey + "_thumbs-" + video.id + "-" + zerofilled + ".png";
|
|
148
|
+
if (process.env.MINIO_ROOT_USER && process.env.NODE_ENV === "development") {
|
|
149
|
+
return (process.env.S3_ENDPOINT +
|
|
150
|
+
"/" +
|
|
151
|
+
process.env.S3_VIDEO_THUMBNAIL_BUCKET +
|
|
152
|
+
"/" +
|
|
153
|
+
fileKey);
|
|
154
|
+
}
|
|
155
|
+
else if (process.env.MINIO_ROOT_USER) {
|
|
156
|
+
return ("https://" +
|
|
157
|
+
process.env.S3_ENDPOINT +
|
|
158
|
+
"/" +
|
|
159
|
+
process.env.S3_VIDEO_THUMBNAIL_BUCKET +
|
|
160
|
+
"/" +
|
|
161
|
+
fileKey);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return ("https://" +
|
|
165
|
+
video.meta.thumbnailBucket +
|
|
166
|
+
"." +
|
|
167
|
+
video.meta.endPoint +
|
|
168
|
+
"/" +
|
|
169
|
+
fileKey);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
Video.createAndGetSignedUploadUrl = (req, res) => {
|
|
173
|
+
const userId = req.user.id;
|
|
174
|
+
sequelize.models.Video.build({
|
|
175
|
+
user_id: userId,
|
|
176
|
+
user_agent: req.useragent.source,
|
|
177
|
+
ip_address: req.clientIp,
|
|
178
|
+
})
|
|
179
|
+
.save()
|
|
180
|
+
.then((video) => {
|
|
181
|
+
video.getPreSignedUploadUrl({}, (error, presignedUrl) => {
|
|
182
|
+
if (error) {
|
|
183
|
+
log.error("Could not get preSigned URL for video", { error });
|
|
184
|
+
res.sendStatus(500);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
log.info("Got presigned url", { presignedUrl });
|
|
188
|
+
res.send({ presignedUrl, videoId: video.id });
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
})
|
|
192
|
+
.catch((error) => {
|
|
193
|
+
log.error("Could not create video", { error });
|
|
194
|
+
res.sendStatus(500);
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
Video.addToPost = (video, options, callback) => {
|
|
198
|
+
sequelize.models.Post.findOne({
|
|
199
|
+
where: {
|
|
200
|
+
id: options.postId,
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
.then((post) => {
|
|
204
|
+
post.addPostVideo(video).then(() => {
|
|
205
|
+
log.info("Have added video to post", { id: options.postId });
|
|
206
|
+
if (process.env.GOOGLE_TRANSCODING_FLAC_BUCKET &&
|
|
207
|
+
process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON) {
|
|
208
|
+
if (!post.public_data) {
|
|
209
|
+
post.set("public_data", {});
|
|
210
|
+
}
|
|
211
|
+
post.set("public_data.transcript", {});
|
|
212
|
+
post.set("public_data.transcript", { videoId: video.id });
|
|
213
|
+
post.set("public_data.transcript.inProgress", true);
|
|
214
|
+
post.set("public_data.transcript.inProgressDate", new Date());
|
|
215
|
+
const workPackage = {
|
|
216
|
+
browserLanguage: options.browserLanguage,
|
|
217
|
+
appLanguage: options.appLanguage,
|
|
218
|
+
videoId: video.id,
|
|
219
|
+
type: "create-video-transcript",
|
|
220
|
+
};
|
|
221
|
+
queue.add("process-voice-to-text", workPackage, "high");
|
|
222
|
+
post
|
|
223
|
+
.save()
|
|
224
|
+
.then(() => {
|
|
225
|
+
callback();
|
|
226
|
+
})
|
|
227
|
+
.catch((error) => {
|
|
228
|
+
callback(error);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
callback();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
})
|
|
236
|
+
.catch((error) => callback(error));
|
|
237
|
+
};
|
|
238
|
+
Video.addToDomain = (video, id, callback) => {
|
|
239
|
+
sequelize.models.Domain.findOne({
|
|
240
|
+
where: {
|
|
241
|
+
id: id,
|
|
242
|
+
},
|
|
243
|
+
})
|
|
244
|
+
.then((domain) => {
|
|
245
|
+
domain.addDomainLogoVideo(video).then(() => {
|
|
246
|
+
log.info("Have added video to domain", { id });
|
|
247
|
+
callback();
|
|
248
|
+
});
|
|
249
|
+
})
|
|
250
|
+
.catch((error) => callback(error));
|
|
251
|
+
};
|
|
252
|
+
Video.addToCommunity = (video, id, callback) => {
|
|
253
|
+
sequelize.models.Community.findOne({
|
|
254
|
+
where: {
|
|
255
|
+
id: id,
|
|
256
|
+
},
|
|
257
|
+
})
|
|
258
|
+
.then((community) => {
|
|
259
|
+
community.addCommunityLogoVideo(video).then(() => {
|
|
260
|
+
log.info("Have added video to community", { id });
|
|
261
|
+
callback();
|
|
262
|
+
});
|
|
263
|
+
})
|
|
264
|
+
.catch((error) => callback(error));
|
|
265
|
+
};
|
|
266
|
+
Video.addToGroup = (video, id, callback) => {
|
|
267
|
+
sequelize.models.Group.findOne({
|
|
268
|
+
where: {
|
|
269
|
+
id: id,
|
|
270
|
+
},
|
|
271
|
+
})
|
|
272
|
+
.then((group) => {
|
|
273
|
+
group.addGroupLogoVideo(video).then(() => {
|
|
274
|
+
log.info("Have added video to group", { id });
|
|
275
|
+
callback();
|
|
276
|
+
});
|
|
277
|
+
})
|
|
278
|
+
.catch((error) => callback(error));
|
|
279
|
+
};
|
|
280
|
+
Video.addToCollection = (video, options, callback) => {
|
|
281
|
+
if (options.postId) {
|
|
282
|
+
sequelize.models.Video.addToPost(video, options, callback);
|
|
283
|
+
}
|
|
284
|
+
else if (options.groupId) {
|
|
285
|
+
sequelize.models.Video.addToGroup(video, options.groupId, callback);
|
|
286
|
+
}
|
|
287
|
+
else if (options.communityId) {
|
|
288
|
+
sequelize.models.Video.addToCommunity(video, options.communityId, callback);
|
|
289
|
+
}
|
|
290
|
+
else if (options.domainId) {
|
|
291
|
+
sequelize.models.Video.addToDomain(video, options.domainId, callback);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
callback("No collection to add to");
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
Video.setupThumbnailsAfterTranscoding = (video, duration, req, callback) => {
|
|
298
|
+
const interval = 10;
|
|
299
|
+
let frames = [];
|
|
300
|
+
const numberOfFrames = Math.max(1, Math.floor(duration / interval));
|
|
301
|
+
for (let frame = 0; frame < numberOfFrames; frame++) {
|
|
302
|
+
frames.push(sequelize.models.Video.getThumbnailUrl(video, frame + 1));
|
|
303
|
+
}
|
|
304
|
+
async.forEachSeries(frames, (frame, foreachCallback) => {
|
|
305
|
+
sequelize.models.Image.build({
|
|
306
|
+
s3_bucket_name: video.meta.thumbnailBucket,
|
|
307
|
+
user_id: req.user.id,
|
|
308
|
+
user_agent: "AWS Transcoder",
|
|
309
|
+
ip_address: "127.0.0.1",
|
|
310
|
+
formats: JSON.stringify([frame]),
|
|
311
|
+
})
|
|
312
|
+
.save()
|
|
313
|
+
.then((image) => {
|
|
314
|
+
// We add a small delay to make sure the images can be ordered by updated_at
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
video
|
|
317
|
+
.addVideoImage(image)
|
|
318
|
+
.then(() => {
|
|
319
|
+
foreachCallback();
|
|
320
|
+
})
|
|
321
|
+
.catch((error) => {
|
|
322
|
+
foreachCallback(error);
|
|
323
|
+
});
|
|
324
|
+
}, 1);
|
|
325
|
+
})
|
|
326
|
+
.catch((error) => {
|
|
327
|
+
foreachCallback(error);
|
|
328
|
+
});
|
|
329
|
+
}, (error) => {
|
|
330
|
+
callback(error);
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
Video.getTranscodingJobStatus = (video, req, res) => {
|
|
334
|
+
if (process.env.USE_YOUR_PRIORITIES_ENCODER) {
|
|
335
|
+
Video.getYrpriEncoderTranscodingJobStatus(video, req, res);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
const params = {
|
|
339
|
+
Id: req.body.jobId,
|
|
340
|
+
};
|
|
341
|
+
const eltr = new aws.ElasticTranscoder({
|
|
342
|
+
apiVersion: "2012–09–25",
|
|
343
|
+
region: process.env.S3_REGION ? process.env.S3_REGION : "eu-west-1",
|
|
344
|
+
});
|
|
345
|
+
eltr.readJob(params, (error, data) => {
|
|
346
|
+
if (error) {
|
|
347
|
+
log.error("Could not get status of transcoding job", { error });
|
|
348
|
+
res.sendStatus(500);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
const jobStatus = {
|
|
352
|
+
status: data.Job.Status,
|
|
353
|
+
statusDetail: data.Job.StatusDetail,
|
|
354
|
+
};
|
|
355
|
+
if (jobStatus.status === "Complete") {
|
|
356
|
+
const duration = data.Job.Output.Duration;
|
|
357
|
+
sequelize.models.Video.setupThumbnailsAfterTranscoding(video, duration, req, (error) => {
|
|
358
|
+
if (error) {
|
|
359
|
+
log.error("Could not connect image and video", { error });
|
|
360
|
+
res.sendStatus(500);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
res.send({
|
|
364
|
+
...jobStatus,
|
|
365
|
+
...{
|
|
366
|
+
videoUrl: sequelize.models.Video.getFullUrl(video.meta),
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
else if (jobStatus.status === "Error") {
|
|
373
|
+
if (data.Job.Outputs &&
|
|
374
|
+
data.Job.Outputs.length > 1 &&
|
|
375
|
+
data.Job.Outputs[0].Status === "Complete" &&
|
|
376
|
+
data.Job.Outputs[1].Status === "Error") {
|
|
377
|
+
log.info("Transcoding no audio channel found", { data });
|
|
378
|
+
const duration = data.Job.Output.Duration;
|
|
379
|
+
sequelize.models.Video.setupThumbnailsAfterTranscoding(video, duration, req, (error) => {
|
|
380
|
+
if (error) {
|
|
381
|
+
log.error("Could not connect image and video", { error });
|
|
382
|
+
res.sendStatus(500);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
res.send({
|
|
386
|
+
status: "Complete",
|
|
387
|
+
videoUrl: sequelize.models.Video.getFullUrl(video.meta),
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
log.error("Could not transcode video image and video", {
|
|
394
|
+
jobStatus: jobStatus,
|
|
395
|
+
data: data,
|
|
396
|
+
dataJob: data.Job,
|
|
397
|
+
});
|
|
398
|
+
res.sendStatus(500);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
res.send(jobStatus);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
Video.startTranscoding = (video, options, req, res) => {
|
|
409
|
+
if (options.videoPostUploadLimitSec &&
|
|
410
|
+
options.videoPostUploadLimitSec !== "") {
|
|
411
|
+
const postLimitSeconds = parseInt(options.videoPostUploadLimitSec);
|
|
412
|
+
video.set("meta.maxDuration", Math.min(postLimitSeconds, 600));
|
|
413
|
+
}
|
|
414
|
+
else if (options.videoPointUploadLimitSec &&
|
|
415
|
+
options.videoPointUploadLimitSec !== "") {
|
|
416
|
+
const pointLimitSeconds = parseInt(options.videoPointUploadLimitSec);
|
|
417
|
+
video.set("meta.maxDuration", Math.min(pointLimitSeconds, 600));
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
video.set("meta.maxDuration", "600");
|
|
421
|
+
}
|
|
422
|
+
if (!video.public_meta) {
|
|
423
|
+
video.set("public_meta", {});
|
|
424
|
+
}
|
|
425
|
+
if (options.aspect === "portrait") {
|
|
426
|
+
video.set("meta.aspect", "portrait");
|
|
427
|
+
video.set("public_meta.aspect", "portrait");
|
|
428
|
+
}
|
|
429
|
+
else if (options.aspect === "landscape") {
|
|
430
|
+
video.set("meta.aspect", "landscape");
|
|
431
|
+
video.set("public_meta.aspect", "landscape");
|
|
432
|
+
}
|
|
433
|
+
video
|
|
434
|
+
.save()
|
|
435
|
+
.then((video) => {
|
|
436
|
+
sequelize.models.Video.startTranscodingJob(video, (error, data) => {
|
|
437
|
+
if (error) {
|
|
438
|
+
log.error("Could not start transcoding job", { error });
|
|
439
|
+
res.sendStatus(500);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
res.send({ transcodingJobId: data.Job.Id });
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
})
|
|
446
|
+
.catch((error) => {
|
|
447
|
+
log.error("Could not start transcoding job", { error });
|
|
448
|
+
res.sendStatus(500);
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
Video.completeUploadAndAddToPoint = async (req, res, options, callback) => {
|
|
452
|
+
if (req.body.isZiggeo) {
|
|
453
|
+
await Video.addZiggeoVideo(req, res);
|
|
454
|
+
callback();
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
sequelize.models.Video.findOne({
|
|
458
|
+
where: {
|
|
459
|
+
id: options.videoId,
|
|
460
|
+
},
|
|
461
|
+
attributes: sequelize.models.Video.defaultAttributesPublic.concat([
|
|
462
|
+
"user_id",
|
|
463
|
+
"meta",
|
|
464
|
+
]),
|
|
465
|
+
})
|
|
466
|
+
.then((video) => {
|
|
467
|
+
if (video.user_id === req.user.id) {
|
|
468
|
+
video.viewable = true;
|
|
469
|
+
video.createFormats(video);
|
|
470
|
+
video
|
|
471
|
+
.save()
|
|
472
|
+
.then(() => {
|
|
473
|
+
sequelize.models.Point.findOne({
|
|
474
|
+
where: {
|
|
475
|
+
id: options.pointId,
|
|
476
|
+
},
|
|
477
|
+
})
|
|
478
|
+
.then((point) => {
|
|
479
|
+
point.addPointVideo(video).then(() => {
|
|
480
|
+
log.info("Have added video to point", {
|
|
481
|
+
id: options.pointId,
|
|
482
|
+
});
|
|
483
|
+
callback();
|
|
484
|
+
});
|
|
485
|
+
})
|
|
486
|
+
.catch((error) => callback(error));
|
|
487
|
+
})
|
|
488
|
+
.catch((error) => {
|
|
489
|
+
callback(error);
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
callback("Could not get video for wrong user");
|
|
494
|
+
}
|
|
495
|
+
})
|
|
496
|
+
.catch((error) => {
|
|
497
|
+
callback(error);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
Video.addZiggeoVideoToContainer = async (req, video) => {
|
|
502
|
+
return await new Promise(async (resolve, reject) => {
|
|
503
|
+
if (req.params.groupId) {
|
|
504
|
+
const group = await sequelize.models.Group.findOne({
|
|
505
|
+
where: {
|
|
506
|
+
id: req.params.groupId,
|
|
507
|
+
},
|
|
508
|
+
attributes: ["id"],
|
|
509
|
+
});
|
|
510
|
+
if (group) {
|
|
511
|
+
await group.addGroupLogoVideo(video);
|
|
512
|
+
let b = 100;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
reject("Could not find group for Ziggeo video", {
|
|
516
|
+
groupId: req.params.groupId,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
else if (req.params.communityId) {
|
|
521
|
+
const community = await sequelize.models.Community.findOne({
|
|
522
|
+
where: {
|
|
523
|
+
id: req.params.communityId,
|
|
524
|
+
},
|
|
525
|
+
attributes: ["id"],
|
|
526
|
+
});
|
|
527
|
+
if (community) {
|
|
528
|
+
await community.addCommunityLogoVideo(video);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
reject("Could not find community for Ziggeo video", {
|
|
532
|
+
communityId: req.params.communityId,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else if (req.params.domainId) {
|
|
537
|
+
const domain = await sequelize.models.Domain.findOne({
|
|
538
|
+
where: {
|
|
539
|
+
id: req.params.domainId,
|
|
540
|
+
},
|
|
541
|
+
attributes: ["id"],
|
|
542
|
+
});
|
|
543
|
+
if (domain) {
|
|
544
|
+
await domain.addDomainLogoVideo(video);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
reject("Could not find domain for Ziggeo video", {
|
|
548
|
+
domainId: req.params.domainId,
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else if (req.params.postId) {
|
|
553
|
+
const post = await sequelize.models.Post.findOne({
|
|
554
|
+
where: {
|
|
555
|
+
id: req.params.postId,
|
|
556
|
+
},
|
|
557
|
+
attributes: ["id"],
|
|
558
|
+
});
|
|
559
|
+
if (post) {
|
|
560
|
+
await post.addPostVideo(video);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
reject("Could not find post for Ziggeo video", {
|
|
564
|
+
postId: req.params.postId,
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
else if (req.params.pointId) {
|
|
569
|
+
const point = await sequelize.models.Point.findOne({
|
|
570
|
+
where: { id: req.params.pointId },
|
|
571
|
+
attributes: ["id"],
|
|
572
|
+
});
|
|
573
|
+
if (point) {
|
|
574
|
+
await point.addPointVideo(video);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
reject("Could not find point for Ziggeo video", {
|
|
578
|
+
postId: req.params.pointId,
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
console.error("Can't find collection for Ziggeo video");
|
|
584
|
+
}
|
|
585
|
+
resolve();
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
Video.addZiggeoVideo = async (req, res) => {
|
|
589
|
+
return await new Promise(async (resolve, reject) => {
|
|
590
|
+
try {
|
|
591
|
+
const video = await sequelize.models.Video.create({
|
|
592
|
+
user_id: req.user.id,
|
|
593
|
+
user_agent: req.useragent.source,
|
|
594
|
+
ip_address: req.clientIp,
|
|
595
|
+
formats: [req.body.videoId],
|
|
596
|
+
viewable: true,
|
|
597
|
+
public_meta: {
|
|
598
|
+
aspect: req.body.aspect,
|
|
599
|
+
isZiggeo: true,
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
await Video.addZiggeoVideoToContainer(req, video);
|
|
603
|
+
if (!req.params.pointId) {
|
|
604
|
+
res.sendStatus(200);
|
|
605
|
+
}
|
|
606
|
+
resolve();
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
console.error(error);
|
|
610
|
+
res.sendStatus(500);
|
|
611
|
+
reject();
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
Video.removeVideoFromCollection = async (req, res, options) => {
|
|
616
|
+
try {
|
|
617
|
+
const video = await sequelize.models.Video.findOne({
|
|
618
|
+
where: {
|
|
619
|
+
id: req.params.videoId,
|
|
620
|
+
},
|
|
621
|
+
attributes: ["id", "formats", "user_id", "meta"],
|
|
622
|
+
});
|
|
623
|
+
let removed = false;
|
|
624
|
+
if (video) {
|
|
625
|
+
if (req.query.removeByUserIdOnly) {
|
|
626
|
+
if (video.user_id === req.user.id) {
|
|
627
|
+
video.deleted = true;
|
|
628
|
+
await video.save();
|
|
629
|
+
removed = true;
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
log.error("Could not remove video from collection not same user", {
|
|
633
|
+
videoId: req.params.videoId,
|
|
634
|
+
userId: req.user.id,
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
else if (req.params.groupId) {
|
|
639
|
+
const group = await sequelize.models.Group.findOne({
|
|
640
|
+
where: {
|
|
641
|
+
id: req.params.groupId,
|
|
642
|
+
},
|
|
643
|
+
attributes: ["id"],
|
|
644
|
+
});
|
|
645
|
+
if (group) {
|
|
646
|
+
const isVideoInGroup = await sequelize.models.Group.findOne({
|
|
647
|
+
where: { id: req.params.groupId },
|
|
648
|
+
include: [
|
|
649
|
+
{
|
|
650
|
+
model: sequelize.models.Video,
|
|
651
|
+
as: req.query.htmlVideo
|
|
652
|
+
? "GroupHtmlVideos"
|
|
653
|
+
: "GroupLogoVideos",
|
|
654
|
+
where: { id: video.id },
|
|
655
|
+
required: true,
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
});
|
|
659
|
+
if (isVideoInGroup) {
|
|
660
|
+
await group.removeGroupLogoVideo(video);
|
|
661
|
+
removed = true;
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
log.error("Could not find video in group", {
|
|
665
|
+
groupId: req.params.groupId,
|
|
666
|
+
videoId: req.params.videoId,
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
log.error("Could not find group for video", {
|
|
672
|
+
groupId: req.params.groupId,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
else if (req.params.communityId) {
|
|
677
|
+
const community = await sequelize.models.Community.findOne({
|
|
678
|
+
where: {
|
|
679
|
+
id: req.params.communityId,
|
|
680
|
+
},
|
|
681
|
+
attributes: ["id"],
|
|
682
|
+
});
|
|
683
|
+
if (community) {
|
|
684
|
+
const isVideoInCommunity = await sequelize.models.Community.findOne({
|
|
685
|
+
where: { id: req.params.communityId },
|
|
686
|
+
include: [
|
|
687
|
+
{
|
|
688
|
+
model: sequelize.models.Video,
|
|
689
|
+
as: "CommunityLogoVideos",
|
|
690
|
+
where: { id: video.id },
|
|
691
|
+
required: true,
|
|
692
|
+
},
|
|
693
|
+
],
|
|
694
|
+
});
|
|
695
|
+
if (isVideoInCommunity) {
|
|
696
|
+
await community.removeCommunityLogoVideo(video);
|
|
697
|
+
removed = true;
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
log.error("Could not find video in community", {
|
|
701
|
+
communityId: req.params.communityId,
|
|
702
|
+
videoId: req.params.videoId,
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
log.error("Could not find community for video", {
|
|
708
|
+
communityId: req.params.communityId,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else if (req.params.domainId) {
|
|
713
|
+
const domain = await sequelize.models.Domain.findOne({
|
|
714
|
+
where: {
|
|
715
|
+
id: req.params.domainId,
|
|
716
|
+
},
|
|
717
|
+
attributes: ["id"],
|
|
718
|
+
});
|
|
719
|
+
if (domain) {
|
|
720
|
+
const isVideoInDomain = await sequelize.models.Domain.findOne({
|
|
721
|
+
where: { id: req.params.domainId },
|
|
722
|
+
include: [
|
|
723
|
+
{
|
|
724
|
+
model: sequelize.models.Video,
|
|
725
|
+
as: "DomainLogoVideos",
|
|
726
|
+
where: { id: video.id },
|
|
727
|
+
required: true,
|
|
728
|
+
},
|
|
729
|
+
],
|
|
730
|
+
});
|
|
731
|
+
if (isVideoInDomain) {
|
|
732
|
+
await domain.removeDomainLogoVideo(video);
|
|
733
|
+
removed = true;
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
log.error("Could not find video in domain", {
|
|
737
|
+
domainId: req.params.domainId,
|
|
738
|
+
videoId: req.params.videoId,
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
log.error("Could not find domain for video", {
|
|
744
|
+
domainId: req.params.domainId,
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
else if (req.params.postId) {
|
|
749
|
+
const post = await sequelize.models.Post.findOne({
|
|
750
|
+
where: {
|
|
751
|
+
id: req.params.postId,
|
|
752
|
+
},
|
|
753
|
+
attributes: ["id"],
|
|
754
|
+
});
|
|
755
|
+
if (post) {
|
|
756
|
+
const isVideoInPost = await sequelize.models.Post.findOne({
|
|
757
|
+
where: { id: req.params.postId },
|
|
758
|
+
include: [
|
|
759
|
+
{
|
|
760
|
+
model: sequelize.models.Video,
|
|
761
|
+
as: "PostVideos",
|
|
762
|
+
where: { id: video.id },
|
|
763
|
+
required: true,
|
|
764
|
+
},
|
|
765
|
+
],
|
|
766
|
+
});
|
|
767
|
+
if (isVideoInPost) {
|
|
768
|
+
await post.removePostVideo(video);
|
|
769
|
+
removed = true;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
log.error("Could not find video in post", {
|
|
773
|
+
postId: req.params.postId,
|
|
774
|
+
videoId: req.params.videoId,
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
log.error("Could not find post for video", {
|
|
780
|
+
postId: req.params.postId,
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else if (req.params.pointId) {
|
|
785
|
+
const point = await sequelize.models.Point.findOne({
|
|
786
|
+
where: { id: req.params.pointId },
|
|
787
|
+
attributes: ["id"],
|
|
788
|
+
});
|
|
789
|
+
if (point) {
|
|
790
|
+
const isVideoInPoint = await sequelize.models.Point.findOne({
|
|
791
|
+
where: { id: req.params.pointId },
|
|
792
|
+
include: [
|
|
793
|
+
{
|
|
794
|
+
model: sequelize.models.Video,
|
|
795
|
+
as: "PointVideos",
|
|
796
|
+
where: { id: video.id },
|
|
797
|
+
required: true,
|
|
798
|
+
},
|
|
799
|
+
],
|
|
800
|
+
});
|
|
801
|
+
if (isVideoInPoint) {
|
|
802
|
+
await point.removePointVideo(video);
|
|
803
|
+
removed = true;
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
log.error("Could not find video in point", {
|
|
807
|
+
pointId: req.params.pointId,
|
|
808
|
+
videoId: req.params.videoId,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
log.error("Could not find point for video", {
|
|
814
|
+
postId: req.params.pointId,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
log.info("No collection for video");
|
|
820
|
+
}
|
|
821
|
+
if (removed) {
|
|
822
|
+
video.deleted = true;
|
|
823
|
+
await video.save();
|
|
824
|
+
import("../active-citizen/llms/imageGeneration/collectionImageGenerator.js").then(async ({ CollectionImageGenerator }) => {
|
|
825
|
+
try {
|
|
826
|
+
const mediaManager = new CollectionImageGenerator();
|
|
827
|
+
let formats = video.formats;
|
|
828
|
+
if (!formats) {
|
|
829
|
+
formats = [sequelize.models.Video.getFullUrl(video.meta)];
|
|
830
|
+
}
|
|
831
|
+
log.info("foramts", { formats });
|
|
832
|
+
await mediaManager.deleteMediaFormatsUrls(formats);
|
|
833
|
+
console.log("Deleted video", { videoId: req.params.videoId });
|
|
834
|
+
res.sendStatus(200);
|
|
835
|
+
}
|
|
836
|
+
catch (error) {
|
|
837
|
+
console.error("Could not delete video", { error, video });
|
|
838
|
+
res.sendStatus(500);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
log.error("Could not remove video from collection", { options });
|
|
844
|
+
res.sendStatus(404);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
log.error("Could not find video", { videoId: req.params.videoId });
|
|
849
|
+
res.sendStatus(404);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
catch (error) {
|
|
853
|
+
log.error("Could not remove video from collection", { error, options });
|
|
854
|
+
res.sendStatus(500);
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
Video.completeUploadAndAddToCollection = async (req, res, options) => {
|
|
858
|
+
if (req.body.isZiggeo) {
|
|
859
|
+
await Video.addZiggeoVideo(req, res);
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
sequelize.models.Video.findOne({
|
|
863
|
+
where: {
|
|
864
|
+
id: options.videoId,
|
|
865
|
+
},
|
|
866
|
+
attributes: sequelize.models.Video.defaultAttributesPublic.concat([
|
|
867
|
+
"user_id",
|
|
868
|
+
"meta",
|
|
869
|
+
]),
|
|
870
|
+
})
|
|
871
|
+
.then((video) => {
|
|
872
|
+
if (video.user_id === req.user.id) {
|
|
873
|
+
video.viewable = true;
|
|
874
|
+
video.createFormats(video);
|
|
875
|
+
video
|
|
876
|
+
.save()
|
|
877
|
+
.then(() => {
|
|
878
|
+
sequelize.models.Video.addToCollection(video, options, (error) => {
|
|
879
|
+
if (error) {
|
|
880
|
+
log.error("Could not add video to collection", {
|
|
881
|
+
error,
|
|
882
|
+
options,
|
|
883
|
+
});
|
|
884
|
+
res.sendStatus(500);
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
if (options.postId) {
|
|
888
|
+
queue.add("process-moderation", {
|
|
889
|
+
type: "post-review-and-annotate-images",
|
|
890
|
+
postId: options.postId,
|
|
891
|
+
}, "medium", { delay: 20000 });
|
|
892
|
+
}
|
|
893
|
+
else if (options.groupId) {
|
|
894
|
+
queue.add("process-moderation", {
|
|
895
|
+
type: "collection-review-and-annotate-images",
|
|
896
|
+
collectionId: options.groupId,
|
|
897
|
+
collectionType: "group",
|
|
898
|
+
}, "medium", { delay: 2000 });
|
|
899
|
+
}
|
|
900
|
+
else if (options.communityId) {
|
|
901
|
+
queue.add("process-moderation", {
|
|
902
|
+
type: "collection-review-and-annotate-images",
|
|
903
|
+
collectionId: options.communityId,
|
|
904
|
+
collectionType: "community",
|
|
905
|
+
}, "medium", { delay: 2000 });
|
|
906
|
+
}
|
|
907
|
+
if (video.formats && video.formats.length > 0) {
|
|
908
|
+
res.send({
|
|
909
|
+
videoId: options.videoId,
|
|
910
|
+
videoUrl: video.formats[0],
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
res.sendStatus(404);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
})
|
|
919
|
+
.catch((error) => {
|
|
920
|
+
log.error("Could not save video", { error });
|
|
921
|
+
res.sendStatus(500);
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
log.error("Could not get video for wrong user");
|
|
926
|
+
res.sendStatus(401);
|
|
927
|
+
}
|
|
928
|
+
})
|
|
929
|
+
.catch((error) => {
|
|
930
|
+
log.error("Could not get video", { error });
|
|
931
|
+
res.sendStatus(500);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
Video.startTranscodingJob = (video, callback) => {
|
|
936
|
+
if (process.env.USE_YOUR_PRIORITIES_ENCODER) {
|
|
937
|
+
Video.startYrpriEncoderTranscodingJob(video, callback);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
const eltr = new aws.ElasticTranscoder({
|
|
941
|
+
apiVersion: "2012–09–25",
|
|
942
|
+
region: process.env.S3_REGION ? process.env.S3_REGION : "eu-west-1",
|
|
943
|
+
});
|
|
944
|
+
const fileKey = video.meta.fileKey;
|
|
945
|
+
const pipelineId = process.env.AWS_TRANSCODER_PIPELINE_ID;
|
|
946
|
+
let videoPresetId;
|
|
947
|
+
if (video.meta.aspect && video.meta.aspect === "portrait") {
|
|
948
|
+
videoPresetId = process.env.AWS_TRANSCODER_PORTRAIT_PRESET_ID;
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
videoPresetId = process.env.AWS_TRANSCODER_PRESET_ID;
|
|
952
|
+
}
|
|
953
|
+
const params = {
|
|
954
|
+
PipelineId: pipelineId,
|
|
955
|
+
Input: {
|
|
956
|
+
Key: fileKey,
|
|
957
|
+
FrameRate: "auto",
|
|
958
|
+
Resolution: "auto",
|
|
959
|
+
AspectRatio: "auto",
|
|
960
|
+
Interlaced: "auto",
|
|
961
|
+
Container: "auto",
|
|
962
|
+
TimeSpan: {
|
|
963
|
+
Duration: video.meta.maxDuration + ".000",
|
|
964
|
+
},
|
|
965
|
+
},
|
|
966
|
+
Outputs: [
|
|
967
|
+
{
|
|
968
|
+
Key: fileKey,
|
|
969
|
+
ThumbnailPattern: fileKey + "_thumbs-" + video.id + "-{count}",
|
|
970
|
+
Rotate: "auto",
|
|
971
|
+
PresetId: videoPresetId,
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
Key: fileKey.slice(0, fileKey.length - 4) + ".flac",
|
|
975
|
+
PresetId: process.env.AWS_TRANSCODER_FLAC_PRESET_ID,
|
|
976
|
+
},
|
|
977
|
+
],
|
|
978
|
+
};
|
|
979
|
+
log.info("Starting AWS transcoding Job");
|
|
980
|
+
eltr.createJob(params, (error, data) => {
|
|
981
|
+
if (error) {
|
|
982
|
+
log.error("Error creating AWS transcoding job", { error });
|
|
983
|
+
callback(error);
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
callback(null, data);
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
Video.prototype.createFormats = function (video) {
|
|
992
|
+
this.formats = [];
|
|
993
|
+
this.formats.push(sequelize.models.Video.getFullUrl(video.meta));
|
|
994
|
+
};
|
|
995
|
+
Video.prototype.getPreSignedUploadUrl = function (options, callback) {
|
|
996
|
+
const endPoint = process.env.S3_ENDPOINT || "s3.amazonaws.com";
|
|
997
|
+
const accelEndPoint = process.env.S3_ACCELERATED_ENDPOINT ||
|
|
998
|
+
process.env.S3_ENDPOINT ||
|
|
999
|
+
"s3.amazonaws.com";
|
|
1000
|
+
const s3 = new aws.S3({
|
|
1001
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
1002
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
1003
|
+
endpoint: accelEndPoint,
|
|
1004
|
+
useAccelerateEndpoint: process.env.S3_ACCELERATED_ENDPOINT != null,
|
|
1005
|
+
region: process.env.S3_REGION ||
|
|
1006
|
+
(process.env.S3_ENDPOINT || process.env.S3_ACCELERATED_ENDPOINT
|
|
1007
|
+
? null
|
|
1008
|
+
: "us-east-1"),
|
|
1009
|
+
s3ForcePathStyle: process.env.S3_FORCE_PATH_STYLE ? true : false,
|
|
1010
|
+
});
|
|
1011
|
+
const signedUrlExpireSeconds = 60 * 60;
|
|
1012
|
+
const bucketName = process.env.S3_VIDEO_UPLOAD_BUCKET;
|
|
1013
|
+
const publicBucket = process.env.S3_VIDEO_PUBLIC_BUCKET;
|
|
1014
|
+
const thumbnailBucket = process.env.S3_VIDEO_THUMBNAIL_BUCKET;
|
|
1015
|
+
const contentType = "video/mp4";
|
|
1016
|
+
const a = this.id;
|
|
1017
|
+
const fileKey = sequelize.models.Video.getRandomFileKey(this.id);
|
|
1018
|
+
const s3Params = {
|
|
1019
|
+
Bucket: bucketName,
|
|
1020
|
+
Key: fileKey,
|
|
1021
|
+
Expires: signedUrlExpireSeconds,
|
|
1022
|
+
ACL: process.env.S3_FORCE_PATH_STYLE
|
|
1023
|
+
? undefined
|
|
1024
|
+
: "bucket-owner-full-control",
|
|
1025
|
+
ContentType: contentType,
|
|
1026
|
+
};
|
|
1027
|
+
s3.getSignedUrl("putObject", s3Params, (error, url) => {
|
|
1028
|
+
if (error) {
|
|
1029
|
+
log.error("Error getting presigned url from AWS S3", { error });
|
|
1030
|
+
callback(error);
|
|
1031
|
+
}
|
|
1032
|
+
else {
|
|
1033
|
+
let meta = {
|
|
1034
|
+
bucketName,
|
|
1035
|
+
publicBucket,
|
|
1036
|
+
endPoint,
|
|
1037
|
+
accelEndPoint,
|
|
1038
|
+
thumbnailBucket,
|
|
1039
|
+
maxDuration: options.maxDuration,
|
|
1040
|
+
fileKey,
|
|
1041
|
+
contentType,
|
|
1042
|
+
uploadUrl: url,
|
|
1043
|
+
};
|
|
1044
|
+
if (this.meta)
|
|
1045
|
+
meta = _.merge(this.meta, meta);
|
|
1046
|
+
this.set("meta", meta);
|
|
1047
|
+
log.info("Presigned URL:", { url, meta });
|
|
1048
|
+
log.info("Saving video metadata");
|
|
1049
|
+
this.save()
|
|
1050
|
+
.then(() => {
|
|
1051
|
+
callback(null, url);
|
|
1052
|
+
})
|
|
1053
|
+
.catch((error) => {
|
|
1054
|
+
callback(error);
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
};
|
|
1059
|
+
// Using Your Priorities Encoder
|
|
1060
|
+
Video.startYrpriEncoderTranscodingJob = (video, callback) => {
|
|
1061
|
+
if (video && video.meta) {
|
|
1062
|
+
const fileKey = video.meta.fileKey;
|
|
1063
|
+
let jobPackage = {
|
|
1064
|
+
portrait: video.meta.aspect && video.meta.aspect === "portrait",
|
|
1065
|
+
fileKey,
|
|
1066
|
+
duration: video.meta.maxDuration + ".000",
|
|
1067
|
+
thumbnailPattern: fileKey + "_thumbs-" + video.id + "-{count}",
|
|
1068
|
+
flacFilename: fileKey.slice(0, fileKey.length - 4) + ".flac",
|
|
1069
|
+
};
|
|
1070
|
+
sequelize.models.AcBackgroundJob.createJob(jobPackage, {}, async (error, jobId) => {
|
|
1071
|
+
log.info("Starting YRPRI transcoding Job");
|
|
1072
|
+
if (error) {
|
|
1073
|
+
log.error("Error creating YRPRI transcoding job", { error });
|
|
1074
|
+
callback(error);
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
jobPackage = _.merge(jobPackage, {
|
|
1078
|
+
acBackgroundJobId: jobId,
|
|
1079
|
+
});
|
|
1080
|
+
await bullVideoQueue.add(jobPackage);
|
|
1081
|
+
callback(null, { Job: { Id: jobId } });
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
callback("No video or video meta");
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
Video.getYrpriEncoderTranscodingJobStatus = (video, req, res) => {
|
|
1090
|
+
sequelize.models.AcBackgroundJob.findOne({
|
|
1091
|
+
where: {
|
|
1092
|
+
id: req.body.jobId,
|
|
1093
|
+
},
|
|
1094
|
+
})
|
|
1095
|
+
.then((job) => {
|
|
1096
|
+
if (job) {
|
|
1097
|
+
const jobStatus = { status: job.data.status, statusDetail: "" };
|
|
1098
|
+
if (job.data.status === "Complete") {
|
|
1099
|
+
const duration = job.data.finalDuration;
|
|
1100
|
+
sequelize.models.Video.setupThumbnailsAfterTranscoding(video, duration, req, (error) => {
|
|
1101
|
+
if (error) {
|
|
1102
|
+
log.error("Could not connect image and video", { error });
|
|
1103
|
+
res.sendStatus(500);
|
|
1104
|
+
}
|
|
1105
|
+
else {
|
|
1106
|
+
res.send({
|
|
1107
|
+
...jobStatus,
|
|
1108
|
+
...{
|
|
1109
|
+
videoUrl: sequelize.models.Video.getFullUrl(video.meta),
|
|
1110
|
+
},
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
else if (job.data.status === "Error") {
|
|
1116
|
+
log.error("Could not transcode video image and video", {
|
|
1117
|
+
jobStatus: jobStatus,
|
|
1118
|
+
data: job.data,
|
|
1119
|
+
});
|
|
1120
|
+
res.sendStatus(500);
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
res.send(jobStatus);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
log.error("Could not find transcoding job");
|
|
1128
|
+
res.sendStatus(404);
|
|
1129
|
+
}
|
|
1130
|
+
})
|
|
1131
|
+
.catch((error) => {
|
|
1132
|
+
log.error("Could not transcode image and video", { error });
|
|
1133
|
+
res.sendStatus(500);
|
|
1134
|
+
});
|
|
1135
|
+
};
|
|
1136
|
+
return Video;
|
|
1137
|
+
};
|