@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,740 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var models = require('../../../models/index.cjs');
|
|
3
|
+
var async = require('async');
|
|
4
|
+
var _ = require('lodash');
|
|
5
|
+
const moment = require('moment');
|
|
6
|
+
const skipEmail = false;
|
|
7
|
+
const aws = require('aws-sdk');
|
|
8
|
+
const log = require('../../utils/logger.cjs');
|
|
9
|
+
const request = require('request');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const downloadImage = (uri, filename, callback) => {
|
|
12
|
+
request.head(uri, (err, res, body) => {
|
|
13
|
+
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const uploadToS3 = (jobId, userId, filename, exportType, data, done) => {
|
|
17
|
+
const endPoint = process.env.S3_ENDPOINT || "s3.amazonaws.com";
|
|
18
|
+
const s3 = new aws.S3({
|
|
19
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
20
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
21
|
+
endpoint: endPoint,
|
|
22
|
+
region: process.env.S3_REGION || ((process.env.S3_ENDPOINT || process.env.S3_ACCELERATED_ENDPOINT) ? null : 'us-east-1'),
|
|
23
|
+
});
|
|
24
|
+
const keyName = "/" + exportType + "/" + userId + "/" + filename;
|
|
25
|
+
s3.upload({
|
|
26
|
+
Bucket: process.env.S3_REPORTS_BUCKET,
|
|
27
|
+
Key: keyName,
|
|
28
|
+
Body: data
|
|
29
|
+
}, (error, data) => {
|
|
30
|
+
if (error) {
|
|
31
|
+
done(error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
s3.getSignedUrl('getObject', {
|
|
35
|
+
Bucket: process.env.S3_REPORTS_BUCKET,
|
|
36
|
+
Key: keyName,
|
|
37
|
+
Expires: 60 * 60
|
|
38
|
+
}, (error, url) => {
|
|
39
|
+
if (error) {
|
|
40
|
+
done(error);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
done(null, url);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}).on('httpUploadProgress', function (progress) {
|
|
48
|
+
updateUploadJobStatus(jobId, Math.round((progress.loaded / progress.total) * 100));
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const updateUploadJobStatus = (jobId, uploadProgress) => {
|
|
52
|
+
let progress = Math.min(Math.round(50 + uploadProgress / 2), 95);
|
|
53
|
+
models.AcBackgroundJob.update({ progress }, { where: { id: jobId } }).then(() => {
|
|
54
|
+
}).catch((error) => {
|
|
55
|
+
log.error("updateUploadJobStatus", { error: error });
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const setJobError = (jobId, errorToUser, errorDetail, done) => {
|
|
59
|
+
log.error("Error in background job", { error: errorDetail });
|
|
60
|
+
models.AcBackgroundJob.update({ error: errorToUser, progress: 0 }, { where: { id: jobId } }).then(() => {
|
|
61
|
+
done();
|
|
62
|
+
}).catch((error) => {
|
|
63
|
+
done(error);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const updateJobStatusIfNeeded = (jobId, totalPosts, processedCount, lastReportedCount, done) => {
|
|
67
|
+
const countSinceLastSent = processedCount - lastReportedCount;
|
|
68
|
+
const percentOfTotalSinceLast = countSinceLastSent / totalPosts;
|
|
69
|
+
if (percentOfTotalSinceLast >= 0.1) {
|
|
70
|
+
let progress = Math.round(((processedCount / totalPosts) * 100) / 2);
|
|
71
|
+
models.AcBackgroundJob.update({ progress }, { where: { id: jobId } }).then(() => {
|
|
72
|
+
done(null, true);
|
|
73
|
+
}).catch((error) => {
|
|
74
|
+
console.log("Error updating job status", { error: error });
|
|
75
|
+
done(error);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
done();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getImageFromUrl = (url, done) => {
|
|
83
|
+
const tmpFilename = "/tmp/" + Math.random() + (url.replace("http://", "").replace(/\//g, ''));
|
|
84
|
+
downloadImage(url, tmpFilename, () => {
|
|
85
|
+
done(null, tmpFilename);
|
|
86
|
+
});
|
|
87
|
+
/* const options = {
|
|
88
|
+
url: url,
|
|
89
|
+
};
|
|
90
|
+
request.get(options, (error, response, body) => {
|
|
91
|
+
if (error || (response && response.statusCode!==200)) {
|
|
92
|
+
done("Error getting image");
|
|
93
|
+
} else {
|
|
94
|
+
// const data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64');
|
|
95
|
+
const data = new Buffer(body);
|
|
96
|
+
done(null, new Uint8Array(body));
|
|
97
|
+
}
|
|
98
|
+
});*/
|
|
99
|
+
};
|
|
100
|
+
async function preparePosts(workPackage, callback) {
|
|
101
|
+
let customRatings;
|
|
102
|
+
const group = workPackage.group;
|
|
103
|
+
const hostName = workPackage.hostname;
|
|
104
|
+
const targetLanguage = workPackage.translateLanguage;
|
|
105
|
+
const jobId = workPackage.jobId;
|
|
106
|
+
if (group.configuration && group.configuration.customRatings) {
|
|
107
|
+
customRatings = group.configuration.customRatings;
|
|
108
|
+
}
|
|
109
|
+
if (targetLanguage) {
|
|
110
|
+
group.translatedName = await getTranslation(group, 'groupName', targetLanguage);
|
|
111
|
+
group.translatedObjectives = await getTranslation(group, 'groupContent', targetLanguage);
|
|
112
|
+
group.targetTranslationLanguage = targetLanguage;
|
|
113
|
+
if (group.configuration) {
|
|
114
|
+
if (group.configuration.alternativePointForHeader) {
|
|
115
|
+
group.translatedAlternativePointForHeader = await getTranslation(group, 'alternativePointForHeader', targetLanguage);
|
|
116
|
+
}
|
|
117
|
+
if (group.configuration.alternativePointForHeader) {
|
|
118
|
+
group.translatedAlternativePointAgainstHeader = await getTranslation(group, 'alternativePointAgainstHeader', targetLanguage);
|
|
119
|
+
}
|
|
120
|
+
if (group.configuration.customTabTitleNewLocation) {
|
|
121
|
+
group.customTabTitleNewLocation = await getTranslation(group, 'customTabTitleNewLocation', targetLanguage);
|
|
122
|
+
}
|
|
123
|
+
if (group.configuration.customAdminCommentsTitle) {
|
|
124
|
+
group.translatedCustomAdminCommentsTitle = await getTranslation(group, 'customAdminCommentsTitle', targetLanguage);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
getGroupPosts(group, hostName, async (postsIn, error, categories) => {
|
|
129
|
+
if (error) {
|
|
130
|
+
callback(error);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const posts = [];
|
|
134
|
+
const totalPosts = postsIn.length;
|
|
135
|
+
async.eachLimit(postsIn, 1, async (post) => {
|
|
136
|
+
if (!post.deleted) {
|
|
137
|
+
const postRatings = (post.public_data && post.public_data.ratings) ? post.public_data.ratings : null;
|
|
138
|
+
posts.push({
|
|
139
|
+
id: post.id,
|
|
140
|
+
name: clean(post.name),
|
|
141
|
+
translatedName: targetLanguage ? await getTranslation(post, 'postName', targetLanguage) : null,
|
|
142
|
+
translatedDescription: targetLanguage ? await getTranslation(post, 'postContent', targetLanguage) : null,
|
|
143
|
+
realPost: post,
|
|
144
|
+
url: getPostUrl(post, hostName),
|
|
145
|
+
category: getCategory(post),
|
|
146
|
+
userEmail: getUserEmail(post),
|
|
147
|
+
userName: post.User.name,
|
|
148
|
+
location: getLocation(post),
|
|
149
|
+
endorsementsUp: post.counter_endorsements_up,
|
|
150
|
+
endorsementsDown: post.counter_endorsements_down,
|
|
151
|
+
status: post.status,
|
|
152
|
+
User: post.User,
|
|
153
|
+
counterPoints: post.counter_points,
|
|
154
|
+
pointsUp: getPointsUp(post),
|
|
155
|
+
Points: post.Points,
|
|
156
|
+
translatedPoints: targetLanguage ? await getTranslatedPoints(post.Points, targetLanguage) : null,
|
|
157
|
+
images: getImages(post),
|
|
158
|
+
pointsDown: getPointsDown(post),
|
|
159
|
+
contactData: getContactData(post),
|
|
160
|
+
attachmentData: getAttachmentData(post),
|
|
161
|
+
mediaURLs: getMediaURLs(post),
|
|
162
|
+
mediaTranscripts: getMediaTranscripts(post),
|
|
163
|
+
postRatings: getPostRatings(customRatings, postRatings)
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// seriesCallback();
|
|
167
|
+
}, function (error) {
|
|
168
|
+
if (error) {
|
|
169
|
+
callback(error);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
callback(null, { jobId, group, posts, customRatings, categories });
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
;
|
|
179
|
+
const getOrderedPosts = (posts) => {
|
|
180
|
+
return _.orderBy(posts, [post => { return post.endorsementsUp - post.endorsementsDown; }], ['desc']);
|
|
181
|
+
};
|
|
182
|
+
const getImageFormatUrl = function (image, formatId) {
|
|
183
|
+
var formats = JSON.parse(image.formats);
|
|
184
|
+
if (formats && formats.length > 0)
|
|
185
|
+
return formats[formatId];
|
|
186
|
+
else
|
|
187
|
+
return "";
|
|
188
|
+
};
|
|
189
|
+
const getImages = function (post) {
|
|
190
|
+
var imagesText = "";
|
|
191
|
+
if (post.PostHeaderImages && post.PostHeaderImages.length > 0) {
|
|
192
|
+
imagesText += _.map(post.PostHeaderImages, function (image) {
|
|
193
|
+
return getImageFormatUrl(image, 0) + "\n";
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (post.PostUserImages && post.PostUserImages.length > 0) {
|
|
197
|
+
imagesText += _.map(post.PostUserImages, function (image) {
|
|
198
|
+
return getImageFormatUrl(image, 0) + "\n";
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return '' + imagesText.replace(/,/g, "") + '';
|
|
202
|
+
};
|
|
203
|
+
async function getTranslation(model, textType, targetLanguage) {
|
|
204
|
+
return await new Promise(resolve => {
|
|
205
|
+
models.AcTranslationCache.getTranslation({ query: { textType, targetLanguage } }, model, async (error, translation) => {
|
|
206
|
+
if (error || !translation) {
|
|
207
|
+
resolve(null);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
resolve(translation.content);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
;
|
|
216
|
+
async function getTranslatedPoints(points, targetLanguage) {
|
|
217
|
+
const translatedPoints = {};
|
|
218
|
+
return await new Promise(resolve => {
|
|
219
|
+
async.eachSeries(points, (point, seriesCallback) => {
|
|
220
|
+
models.AcTranslationCache.getTranslation({ query: { textType: "pointContent", targetLanguage } }, point, async (error, translation) => {
|
|
221
|
+
if (!error && translation) {
|
|
222
|
+
translatedPoints[point.id] = translation.content;
|
|
223
|
+
if (point.public_data && point.public_data.admin_comments) {
|
|
224
|
+
models.AcTranslationCache.getTranslation({ query: { textType: "pointAdminCommentContent", targetLanguage } }, point, async (error, translation) => {
|
|
225
|
+
if (!error && translation) {
|
|
226
|
+
translatedPoints[point.id + "adminComments"] = translation.content;
|
|
227
|
+
seriesCallback();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
log.warn("Docx translation error or no translation", { error: error ? error : null });
|
|
231
|
+
seriesCallback();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
seriesCallback();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
log.warn("Docx translation error or no translation", { error: error ? error : null });
|
|
241
|
+
seriesCallback();
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}, (error) => {
|
|
245
|
+
resolve(translatedPoints);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const getPostUrl = function (post, hostname) {
|
|
250
|
+
if (hostname) {
|
|
251
|
+
return 'https://' + hostname + '/post/' + post.id;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return "https://yrpri.org/post/" + post.id;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const getUserEmail = function (post) {
|
|
258
|
+
if (skipEmail) {
|
|
259
|
+
return "hidden";
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return post.User.email;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const clean = function (text) {
|
|
266
|
+
//console.log("Before: "+ text);
|
|
267
|
+
var newText = text.replace('"', "'").replace('\n', '').replace('\r', '').replace(/(\r\n|\n|\r)/gm, "").replace(/"/gm, "'").replace(/,/, ';').trim();
|
|
268
|
+
//console.log("After:" + newText);
|
|
269
|
+
return newText.replace(/´/g, '');
|
|
270
|
+
};
|
|
271
|
+
const cleanDescription = function (text) {
|
|
272
|
+
//console.log("Before: "+ text);
|
|
273
|
+
var newText = text.replace('"', "'").replace(/"/gm, "'").replace(/,/, ';').trim();
|
|
274
|
+
//console.log("After:" + newText);
|
|
275
|
+
return newText.replace(/´/g, '');
|
|
276
|
+
};
|
|
277
|
+
const getLocation = function (post) {
|
|
278
|
+
if (post.location && post.location.latitude && post.location.longitude &&
|
|
279
|
+
post.location.latitude != "" && post.location.longitude != "") {
|
|
280
|
+
return post.location.latitude + ',' + post.location.longitude;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
return '"",""';
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const getPoints = function (points) {
|
|
287
|
+
var totalContent = "";
|
|
288
|
+
_.each(points, function (point) {
|
|
289
|
+
var content = clean(point.content) + "\n\n";
|
|
290
|
+
if (content.startsWith(",")) {
|
|
291
|
+
content = content.substr(1);
|
|
292
|
+
}
|
|
293
|
+
//console.log("content: "+content);
|
|
294
|
+
totalContent += content;
|
|
295
|
+
});
|
|
296
|
+
return totalContent;
|
|
297
|
+
};
|
|
298
|
+
const getContactData = function (post) {
|
|
299
|
+
if (post.data && post.data.contact && (post.data.contact.name || post.data.contact.email || post.data.contact.telephone)) {
|
|
300
|
+
return `"${post.data.contact.name}","${post.data.contact.email}","${post.data.contact.telephone}"`;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return ",,";
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const getAttachmentData = function (post) {
|
|
307
|
+
if (post.data && post.data.attachment && post.data.attachment.url) {
|
|
308
|
+
return `"${post.data.attachment.url}","${post.data.attachment.filename}"`;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
return ",";
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const getPointsUpOrDown = function (post, value) {
|
|
315
|
+
var points = _.filter(post.Points, function (point) {
|
|
316
|
+
if (value > 0) {
|
|
317
|
+
return point.value > 0;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
return point.value < 0;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
return points.map((point) => { return { content: point.content, id: point.id, public_data: point.public_data, created_at: point.created_at, PointRevisions: point.PointRevisions, User: point.User }; });
|
|
324
|
+
};
|
|
325
|
+
const getPointsUp = function (post) {
|
|
326
|
+
return getPointsUpOrDown(post, 1);
|
|
327
|
+
};
|
|
328
|
+
const getPointsDown = function (post) {
|
|
329
|
+
return getPointsUpOrDown(post, -1);
|
|
330
|
+
};
|
|
331
|
+
var getNewFromUsers = function (post) {
|
|
332
|
+
return "";
|
|
333
|
+
};
|
|
334
|
+
const getMediaFormatUrl = function (media, formatId) {
|
|
335
|
+
var formats = media.formats;
|
|
336
|
+
if (formats && formats.length > 0)
|
|
337
|
+
return formats[formatId];
|
|
338
|
+
else
|
|
339
|
+
return "";
|
|
340
|
+
};
|
|
341
|
+
const getPointMediaUrls = function (post) {
|
|
342
|
+
let mediaURLs = "";
|
|
343
|
+
if (post.Points && post.Points.length > 0) {
|
|
344
|
+
_.forEach(post.Points, function (point) {
|
|
345
|
+
if (point.PointVideos && point.PointVideos.length > 0) {
|
|
346
|
+
mediaURLs += _.map(point.PointVideos, function (media) {
|
|
347
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
if (point.PointAudios && point.PointAudios.length > 0) {
|
|
351
|
+
mediaURLs += _.map(point.PointAudios, function (media) {
|
|
352
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return mediaURLs;
|
|
358
|
+
};
|
|
359
|
+
const getMediaURLs = function (post) {
|
|
360
|
+
var mediaURLs = "";
|
|
361
|
+
if (post.Points && post.Points.length > 0) {
|
|
362
|
+
_.forEach(post.Points, function (point) {
|
|
363
|
+
if (point.PointVideos && point.PointVideos.length > 0) {
|
|
364
|
+
mediaURLs += _.map(point.PointVideos, function (media) {
|
|
365
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (point.PointAudios && point.PointAudios.length > 0) {
|
|
369
|
+
mediaURLs += _.map(point.PointAudios, function (media) {
|
|
370
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (post.PostVideos && post.PostVideos.length > 0) {
|
|
376
|
+
mediaURLs += _.map(post.PostVideos, function (media) {
|
|
377
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (post.PostAudios && post.PostAudios.length > 0) {
|
|
381
|
+
mediaURLs += _.map(post.PostAudios, function (media) {
|
|
382
|
+
return "" + getMediaFormatUrl(media, 0) + "\n";
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return '"' + mediaURLs + '"';
|
|
386
|
+
};
|
|
387
|
+
const getMediaTranscripts = function (post) {
|
|
388
|
+
if (post.public_data && post.public_data.transcript && post.public_data.transcript.text) {
|
|
389
|
+
return '"' + post.public_data.transcript.text + '"';
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
return "";
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const getCategory = function (post) {
|
|
396
|
+
if (post.Category) {
|
|
397
|
+
return post.Category.name;
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
return "";
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
const getRatingHeaders = (customRatings) => {
|
|
404
|
+
let out = "";
|
|
405
|
+
if (customRatings && customRatings.length > 0) {
|
|
406
|
+
customRatings.forEach((rating) => {
|
|
407
|
+
out += ',"' + rating.name + ' count"';
|
|
408
|
+
out += ',"' + rating.name + ' average"';
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return out;
|
|
412
|
+
};
|
|
413
|
+
const getPostRatings = (customRatings, postRatings) => {
|
|
414
|
+
let out = "";
|
|
415
|
+
if (customRatings && customRatings.length > 0) {
|
|
416
|
+
customRatings.forEach((rating, index) => {
|
|
417
|
+
out += ',' + (postRatings && postRatings[index] ? postRatings[index].count : '0');
|
|
418
|
+
out += ',' + (postRatings && postRatings[index] && postRatings[index].averageRating ? postRatings[index].averageRating : '0');
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return out;
|
|
422
|
+
};
|
|
423
|
+
const getDescriptionColumns = (group, post) => {
|
|
424
|
+
if (group && group.configuration && group.configuration.structuredQuestions && group.configuration.structuredQuestions !== "") {
|
|
425
|
+
var structuredAnswers = [];
|
|
426
|
+
var questionComponents = group.configuration.structuredQuestions.split(",");
|
|
427
|
+
for (var i = 0; i < questionComponents.length; i += 2) {
|
|
428
|
+
var question = questionComponents[i];
|
|
429
|
+
var maxLength = questionComponents[i + 1];
|
|
430
|
+
structuredAnswers.push({
|
|
431
|
+
translatedContent: question,
|
|
432
|
+
question: question,
|
|
433
|
+
maxLength: maxLength, value: ""
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
if (post.public_data && post.public_data.structuredAnswers && post.public_data.structuredAnswers !== "") {
|
|
437
|
+
var answers = post.public_data.structuredAnswers.split("%!#x");
|
|
438
|
+
for (i = 0; i < answers.length; i += 1) {
|
|
439
|
+
if (structuredAnswers[i])
|
|
440
|
+
structuredAnswers[i].value = answers[i];
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
structuredAnswers[0].value = post.description;
|
|
445
|
+
}
|
|
446
|
+
let columnsString = '';
|
|
447
|
+
structuredAnswers.forEach((question) => {
|
|
448
|
+
if (question.value) {
|
|
449
|
+
columnsString += '"' + question.value + '",';
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
columnsString += '"",';
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
return columnsString.substring(0, columnsString.length - 1);
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
return '"' + post.description + '"';
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
const getDescriptionHeaders = (group) => {
|
|
462
|
+
if (group && group.configuration.structuredQuestions && group.configuration.structuredQuestions !== "") {
|
|
463
|
+
var structuredQuestions = [];
|
|
464
|
+
var questionComponents = group.configuration.structuredQuestions.split(",");
|
|
465
|
+
for (var i = 0; i < questionComponents.length; i += 2) {
|
|
466
|
+
var question = questionComponents[i];
|
|
467
|
+
var maxLength = questionComponents[i + 1];
|
|
468
|
+
structuredQuestions.push({
|
|
469
|
+
translatedContent: question,
|
|
470
|
+
question: question,
|
|
471
|
+
maxLength: maxLength, value: ""
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
let columnsString = '';
|
|
475
|
+
structuredQuestions.forEach((question) => {
|
|
476
|
+
columnsString += '"' + question.translatedContent + '",';
|
|
477
|
+
});
|
|
478
|
+
return columnsString.substring(0, columnsString.length - 1);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
return "Description";
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const getGroupPosts = (group, hostName, callback) => {
|
|
485
|
+
models.Post.unscoped().findAll({
|
|
486
|
+
where: {
|
|
487
|
+
group_id: group.id
|
|
488
|
+
},
|
|
489
|
+
attributes: ['id', 'counter_endorsements_down', 'counter_endorsements_up', 'status', 'counter_points', 'public_data', 'name', 'description', 'language', 'location', 'data', 'created_at'],
|
|
490
|
+
order: [
|
|
491
|
+
['created_at', 'asc'],
|
|
492
|
+
[{ model: models.Point }, 'counter_quality_up', 'desc'],
|
|
493
|
+
[{ model: models.Point }, models.PointRevision, 'created_at', 'asc'],
|
|
494
|
+
],
|
|
495
|
+
include: [
|
|
496
|
+
{
|
|
497
|
+
model: models.Category,
|
|
498
|
+
required: false
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
model: models.Group,
|
|
502
|
+
attributes: ['id', 'configuration'],
|
|
503
|
+
required: true
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
model: models.PostRevision,
|
|
507
|
+
required: false
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
model: models.Point,
|
|
511
|
+
attributes: ['id', 'content', 'value', 'language', 'created_at', 'public_data', 'counter_quality_up', 'counter_quality_down', 'status'],
|
|
512
|
+
required: false,
|
|
513
|
+
include: [
|
|
514
|
+
{
|
|
515
|
+
model: models.User,
|
|
516
|
+
required: true,
|
|
517
|
+
attributes: ['id', 'name', 'email', 'private_profile_data']
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
model: models.Audio,
|
|
521
|
+
as: 'PointAudios',
|
|
522
|
+
attributes: ['id', 'public_meta', 'formats'],
|
|
523
|
+
required: false
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
model: models.PointRevision,
|
|
527
|
+
required: true,
|
|
528
|
+
attributes: ['id', 'content']
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
model: models.Video,
|
|
532
|
+
as: 'PointVideos',
|
|
533
|
+
attributes: ['id', 'public_meta', 'formats'],
|
|
534
|
+
required: false
|
|
535
|
+
}
|
|
536
|
+
]
|
|
537
|
+
},
|
|
538
|
+
{ model: models.Image,
|
|
539
|
+
as: 'PostHeaderImages',
|
|
540
|
+
required: false
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
model: models.User,
|
|
544
|
+
required: true,
|
|
545
|
+
attributes: ['id', 'name', 'email', 'private_profile_data']
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
model: models.Audio,
|
|
549
|
+
as: 'PostAudios',
|
|
550
|
+
attributes: ['id', 'public_meta', 'formats'],
|
|
551
|
+
required: false
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
model: models.Video,
|
|
555
|
+
as: 'PostVideos',
|
|
556
|
+
attributes: ['id', 'public_meta', 'formats'],
|
|
557
|
+
required: false
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
model: models.Image,
|
|
561
|
+
as: 'PostUserImages',
|
|
562
|
+
required: false,
|
|
563
|
+
where: {
|
|
564
|
+
deleted: false
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
]
|
|
568
|
+
}).then(function (posts) {
|
|
569
|
+
let categories = [];
|
|
570
|
+
posts.forEach((post) => {
|
|
571
|
+
if (post.Category) {
|
|
572
|
+
categories.push(post.Category.name);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
categories = _.uniq(categories);
|
|
576
|
+
callback(posts, null, categories);
|
|
577
|
+
}).catch(function (error) {
|
|
578
|
+
callback(null, error);
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
var getExportFileDataForGroup = function (group, hostName, callback) {
|
|
582
|
+
getGroupPosts(group, hostName, (posts, error) => {
|
|
583
|
+
if (error) {
|
|
584
|
+
callback(error);
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
var outFileContent = "";
|
|
588
|
+
let customRatings;
|
|
589
|
+
if (group.configuration && group.configuration.customRatings) {
|
|
590
|
+
customRatings = group.configuration.customRatings;
|
|
591
|
+
}
|
|
592
|
+
//console.log(posts.length);
|
|
593
|
+
outFileContent += "Nr, Post id,email,User Name,Post Name," + getDescriptionHeaders(group) + ",Url,Category,Latitude,Longitude,Up Votes,Down Votes,Points Count,Points For,Points Against,Images,Contact Name,Contact Email,Contact telephone,Attachment URL,Attachment filename,Media URLs,Post transcript" + getRatingHeaders(customRatings) + "\n";
|
|
594
|
+
let postCounter = 0;
|
|
595
|
+
async.eachSeries(posts, function (post, seriesCallback) {
|
|
596
|
+
postCounter += 1;
|
|
597
|
+
if (!post.deleted) {
|
|
598
|
+
const postRatings = (post.public_data && post.public_data.ratings) ? post.public_data.ratings : null;
|
|
599
|
+
outFileContent += postCounter + ',' + post.id + ',"' + getUserEmail(post) + '","' + post.User.name +
|
|
600
|
+
'","' + clean(post.name) + '",' + getDescriptionColumns(group, post) + ',' +
|
|
601
|
+
'"' + getPostUrl(post) + '",' + '"' + getCategory(post) + '",' +
|
|
602
|
+
getLocation(post) + ',' + post.counter_endorsements_up + ',' + post.counter_endorsements_down +
|
|
603
|
+
',' + post.counter_points + ',' + getPointsUp(post) + ',' + getPointsDown(post) + ',' +
|
|
604
|
+
getImages(post) + ',' +
|
|
605
|
+
getContactData(post) + ',' +
|
|
606
|
+
getAttachmentData(post) + ',' +
|
|
607
|
+
getMediaURLs(post) + ',' +
|
|
608
|
+
getMediaTranscripts(post) +
|
|
609
|
+
getPostRatings(customRatings, postRatings) + '\n';
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
outFileContent += postCounter + ',' + post.id + ',DELETED,,,,,,,,,,,\n';
|
|
613
|
+
}
|
|
614
|
+
seriesCallback();
|
|
615
|
+
}, function (error) {
|
|
616
|
+
if (error) {
|
|
617
|
+
callback(error);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
callback(null, outFileContent);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
const getLoginsExportDataForCommunity = (communityId, hostName, callback) => {
|
|
627
|
+
let outFileContent = "Date, User id, Name, Email, Method, Department\n";
|
|
628
|
+
models.AcActivity.findAll({
|
|
629
|
+
where: {
|
|
630
|
+
type: 'activity.user.login',
|
|
631
|
+
community_id: communityId
|
|
632
|
+
},
|
|
633
|
+
order: [['created_at', 'DESC']],
|
|
634
|
+
attributes: ['object', 'created_at'],
|
|
635
|
+
include: [
|
|
636
|
+
{
|
|
637
|
+
model: models.User,
|
|
638
|
+
attributes: ['id', 'email', 'name']
|
|
639
|
+
}
|
|
640
|
+
]
|
|
641
|
+
}).then((activities) => {
|
|
642
|
+
async.eachSeries(activities, (activity, seriesCallback) => {
|
|
643
|
+
const date = moment(activity.created_at).format("DD/MM/YY HH:mm");
|
|
644
|
+
outFileContent += date + "," + activity.User.id + ',"' + activity.User.name + '",' + activity.User.email + "," + activity.object.loginType + "," + activity.object.userDepartment + "\n";
|
|
645
|
+
seriesCallback();
|
|
646
|
+
}, (error) => {
|
|
647
|
+
callback(error, outFileContent);
|
|
648
|
+
});
|
|
649
|
+
}).catch((error) => {
|
|
650
|
+
callback(error);
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
const getUsersForCommunity = (communityId, callback) => {
|
|
654
|
+
let outFileContent = "User id, Name, Email, Ssn\n";
|
|
655
|
+
models.Community.findOne({
|
|
656
|
+
where: {
|
|
657
|
+
id: communityId
|
|
658
|
+
},
|
|
659
|
+
attributes: ['id'],
|
|
660
|
+
include: [
|
|
661
|
+
{
|
|
662
|
+
model: models.User,
|
|
663
|
+
attributes: ['id', 'email', 'name', 'ssn'],
|
|
664
|
+
as: "CommunityUsers"
|
|
665
|
+
}
|
|
666
|
+
]
|
|
667
|
+
}).then((community) => {
|
|
668
|
+
async.eachSeries(community.CommunityUsers, (user, seriesCallback) => {
|
|
669
|
+
if (!user.ssn)
|
|
670
|
+
user.ssn = "";
|
|
671
|
+
if (!user.email)
|
|
672
|
+
user.email = "";
|
|
673
|
+
outFileContent += user.id + ',"' + user.name + '",' + user.email + "," + user.ssn + "\n";
|
|
674
|
+
seriesCallback();
|
|
675
|
+
}, (error) => {
|
|
676
|
+
callback(error, outFileContent);
|
|
677
|
+
});
|
|
678
|
+
}).catch((error) => {
|
|
679
|
+
callback(error);
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
const getLoginsExportDataForDomain = (domainId, hostName, callback) => {
|
|
683
|
+
let outFileContent = "Date, User id, Name, Email, Method, Department\n";
|
|
684
|
+
models.AcActivity.findAll({
|
|
685
|
+
where: {
|
|
686
|
+
type: 'activity.user.login',
|
|
687
|
+
domain_id: domainId
|
|
688
|
+
},
|
|
689
|
+
order: [['created_at', 'DESC']],
|
|
690
|
+
attributes: ['object', 'created_at'],
|
|
691
|
+
include: [
|
|
692
|
+
{
|
|
693
|
+
model: models.User,
|
|
694
|
+
attributes: ['id', 'email', 'name']
|
|
695
|
+
}
|
|
696
|
+
]
|
|
697
|
+
}).then((activities) => {
|
|
698
|
+
async.eachSeries(activities, (activity, seriesCallback) => {
|
|
699
|
+
const date = moment(activity.created_at).format("DD/MM/YY HH:mm");
|
|
700
|
+
outFileContent += date + "," + activity.User.id + ',"' + activity.User.name + '",' + activity.User.email + "," + activity.object.loginType + "," + activity.object.userDepartment + "\n";
|
|
701
|
+
seriesCallback();
|
|
702
|
+
}, (error) => {
|
|
703
|
+
callback(error, outFileContent);
|
|
704
|
+
});
|
|
705
|
+
}).catch((error) => {
|
|
706
|
+
callback(error);
|
|
707
|
+
});
|
|
708
|
+
};
|
|
709
|
+
module.exports = {
|
|
710
|
+
getExportFileDataForGroup: getExportFileDataForGroup,
|
|
711
|
+
getLoginsExportDataForCommunity: getLoginsExportDataForCommunity,
|
|
712
|
+
getLoginsExportDataForDomain: getLoginsExportDataForDomain,
|
|
713
|
+
getGroupPosts: getGroupPosts,
|
|
714
|
+
getUsersForCommunity,
|
|
715
|
+
getDescriptionHeaders,
|
|
716
|
+
getPostUrl,
|
|
717
|
+
getCategory,
|
|
718
|
+
getImages,
|
|
719
|
+
clean,
|
|
720
|
+
getDescriptionColumns,
|
|
721
|
+
getPointsDown,
|
|
722
|
+
getPointsUp,
|
|
723
|
+
getUserEmail,
|
|
724
|
+
getRatingHeaders,
|
|
725
|
+
getContactData,
|
|
726
|
+
getLocation,
|
|
727
|
+
getAttachmentData,
|
|
728
|
+
getMediaURLs,
|
|
729
|
+
getMediaTranscripts,
|
|
730
|
+
getPostRatings,
|
|
731
|
+
updateJobStatusIfNeeded,
|
|
732
|
+
getTranslatedPoints,
|
|
733
|
+
getTranslation,
|
|
734
|
+
getOrderedPosts,
|
|
735
|
+
setJobError,
|
|
736
|
+
preparePosts,
|
|
737
|
+
uploadToS3,
|
|
738
|
+
getImageFromUrl,
|
|
739
|
+
getPointMediaUrls
|
|
740
|
+
};
|