@yrpri/api 9.0.103 → 9.0.104
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/package.json +1 -1
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
package/dist/models/video.cjs
DELETED
|
@@ -1,1137 +0,0 @@
|
|
|
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
|
-
};
|