@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
|
@@ -1,1911 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const async = require("async");
|
|
3
|
-
const models = require("../../models/index.cjs");
|
|
4
|
-
const log = require('../utils/logger.cjs');
|
|
5
|
-
const queue = require('./queue.cjs');
|
|
6
|
-
const i18n = require('../utils/i18n.cjs');
|
|
7
|
-
const toJson = require('../utils/to_json.cjs');
|
|
8
|
-
const _ = require('lodash');
|
|
9
|
-
const getAnonymousUser = require('../utils/get_anonymous_system_user.cjs');
|
|
10
|
-
let airbrake = null;
|
|
11
|
-
if (process.env.AIRBRAKE_PROJECT_ID) {
|
|
12
|
-
airbrake = require('../utils/airbrake.cjs');
|
|
13
|
-
}
|
|
14
|
-
let DeletionWorker = function () { };
|
|
15
|
-
const getGroupAndUser = (groupId, userId, userEmail, callback) => {
|
|
16
|
-
var user, group;
|
|
17
|
-
async.series([
|
|
18
|
-
(seriesCallback) => {
|
|
19
|
-
models.Group.findOne({
|
|
20
|
-
where: {
|
|
21
|
-
id: groupId
|
|
22
|
-
}
|
|
23
|
-
}).then((groupIn) => {
|
|
24
|
-
if (groupIn) {
|
|
25
|
-
group = groupIn;
|
|
26
|
-
}
|
|
27
|
-
seriesCallback();
|
|
28
|
-
}).catch((error) => {
|
|
29
|
-
seriesCallback(error);
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
(seriesCallback) => {
|
|
33
|
-
if (userId) {
|
|
34
|
-
models.User.findOne({
|
|
35
|
-
where: {
|
|
36
|
-
id: userId
|
|
37
|
-
},
|
|
38
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
39
|
-
}).then((userIn) => {
|
|
40
|
-
if (userIn) {
|
|
41
|
-
user = userIn;
|
|
42
|
-
}
|
|
43
|
-
seriesCallback();
|
|
44
|
-
}).catch((error) => {
|
|
45
|
-
seriesCallback(error);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
seriesCallback();
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
(seriesCallback) => {
|
|
53
|
-
if (userEmail) {
|
|
54
|
-
models.User.findOne({
|
|
55
|
-
where: {
|
|
56
|
-
email: userEmail
|
|
57
|
-
},
|
|
58
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
59
|
-
}).then((userIn) => {
|
|
60
|
-
if (userIn) {
|
|
61
|
-
user = userIn;
|
|
62
|
-
}
|
|
63
|
-
seriesCallback();
|
|
64
|
-
}).catch((error) => {
|
|
65
|
-
seriesCallback(error);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
seriesCallback();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
], (error) => {
|
|
73
|
-
if (error) {
|
|
74
|
-
callback(error);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
callback(null, group, user);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
var getCommunityAndUser = function (communityId, userId, userEmail, callback) {
|
|
82
|
-
var user, community;
|
|
83
|
-
async.series([
|
|
84
|
-
function (seriesCallback) {
|
|
85
|
-
models.Community.findOne({
|
|
86
|
-
where: {
|
|
87
|
-
id: communityId
|
|
88
|
-
}
|
|
89
|
-
}).then(function (communityIn) {
|
|
90
|
-
if (communityIn) {
|
|
91
|
-
community = communityIn;
|
|
92
|
-
}
|
|
93
|
-
seriesCallback();
|
|
94
|
-
}).catch(function (error) {
|
|
95
|
-
seriesCallback(error);
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
function (seriesCallback) {
|
|
99
|
-
if (userId) {
|
|
100
|
-
models.User.findOne({
|
|
101
|
-
where: {
|
|
102
|
-
id: userId
|
|
103
|
-
},
|
|
104
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
105
|
-
}).then(function (userIn) {
|
|
106
|
-
if (userIn) {
|
|
107
|
-
user = userIn;
|
|
108
|
-
}
|
|
109
|
-
seriesCallback();
|
|
110
|
-
}).catch(function (error) {
|
|
111
|
-
seriesCallback(error);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
seriesCallback();
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
function (seriesCallback) {
|
|
119
|
-
if (userEmail) {
|
|
120
|
-
models.User.findOne({
|
|
121
|
-
where: {
|
|
122
|
-
email: userEmail
|
|
123
|
-
},
|
|
124
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
125
|
-
}).then(function (userIn) {
|
|
126
|
-
if (userIn) {
|
|
127
|
-
user = userIn;
|
|
128
|
-
}
|
|
129
|
-
seriesCallback();
|
|
130
|
-
}).catch(function (error) {
|
|
131
|
-
seriesCallback(error);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
seriesCallback();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
], function (error) {
|
|
139
|
-
if (error) {
|
|
140
|
-
callback(error);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
callback(null, community, user);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
var getDomainAndUser = function (domainId, userId, userEmail, callback) {
|
|
148
|
-
var user, domain;
|
|
149
|
-
async.series([
|
|
150
|
-
function (seriesCallback) {
|
|
151
|
-
models.Domain.findOne({
|
|
152
|
-
where: {
|
|
153
|
-
id: domainId
|
|
154
|
-
}
|
|
155
|
-
}).then(function (domainIn) {
|
|
156
|
-
if (domainIn) {
|
|
157
|
-
domain = domainIn;
|
|
158
|
-
}
|
|
159
|
-
seriesCallback();
|
|
160
|
-
}).catch(function (error) {
|
|
161
|
-
seriesCallback(error);
|
|
162
|
-
});
|
|
163
|
-
},
|
|
164
|
-
function (seriesCallback) {
|
|
165
|
-
if (userId) {
|
|
166
|
-
models.User.findOne({
|
|
167
|
-
where: {
|
|
168
|
-
id: userId
|
|
169
|
-
},
|
|
170
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
171
|
-
}).then(function (userIn) {
|
|
172
|
-
if (userIn) {
|
|
173
|
-
user = userIn;
|
|
174
|
-
}
|
|
175
|
-
seriesCallback();
|
|
176
|
-
}).catch(function (error) {
|
|
177
|
-
seriesCallback(error);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
seriesCallback();
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
function (seriesCallback) {
|
|
185
|
-
if (userEmail) {
|
|
186
|
-
models.User.findOne({
|
|
187
|
-
where: {
|
|
188
|
-
email: userEmail
|
|
189
|
-
},
|
|
190
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
191
|
-
}).then(function (userIn) {
|
|
192
|
-
if (userIn) {
|
|
193
|
-
user = userIn;
|
|
194
|
-
}
|
|
195
|
-
seriesCallback();
|
|
196
|
-
}).catch(function (error) {
|
|
197
|
-
seriesCallback(error);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
seriesCallback();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
], function (error) {
|
|
205
|
-
if (error) {
|
|
206
|
-
callback(error);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
callback(null, domain, user);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
const recountPost = (postId, callback) => {
|
|
214
|
-
let endorsementsUpCount = 0, endorsementsDownCount = 0, pointsCount = 0;
|
|
215
|
-
async.series([
|
|
216
|
-
(seriesCallback) => {
|
|
217
|
-
models.Endorsement.findAll({
|
|
218
|
-
where: {
|
|
219
|
-
post_id: postId
|
|
220
|
-
},
|
|
221
|
-
attributes: ['value']
|
|
222
|
-
}).then((endorsements) => {
|
|
223
|
-
_.forEach(endorsements, (endorsement) => {
|
|
224
|
-
if (endorsement.value > 0) {
|
|
225
|
-
endorsementsUpCount += 1;
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
endorsementsDownCount += 1;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
seriesCallback();
|
|
232
|
-
}).catch((error) => {
|
|
233
|
-
seriesCallback(error);
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
(seriesCallback) => {
|
|
237
|
-
models.Point.findAll({
|
|
238
|
-
where: {
|
|
239
|
-
post_id: postId
|
|
240
|
-
},
|
|
241
|
-
attributes: ['id']
|
|
242
|
-
}).then((points) => {
|
|
243
|
-
pointsCount = points.length;
|
|
244
|
-
seriesCallback();
|
|
245
|
-
}).catch((error) => {
|
|
246
|
-
seriesCallback(error);
|
|
247
|
-
});
|
|
248
|
-
},
|
|
249
|
-
(seriesCallback) => {
|
|
250
|
-
models.Post.findOne({
|
|
251
|
-
where: {
|
|
252
|
-
id: postId
|
|
253
|
-
},
|
|
254
|
-
attributes: ['id', 'counter_points', 'counter_endorsements_up', 'counter_endorsements_down']
|
|
255
|
-
}).then((post) => {
|
|
256
|
-
if (post) {
|
|
257
|
-
post.counter_points = pointsCount;
|
|
258
|
-
post.counter_endorsements_up = endorsementsUpCount;
|
|
259
|
-
post.counter_endorsements_down = endorsementsDownCount;
|
|
260
|
-
post.save().then(() => {
|
|
261
|
-
seriesCallback();
|
|
262
|
-
}).catch((error) => { seriesCallback(error); });
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
log.warn("No post for recountPost", { postId: postId });
|
|
266
|
-
seriesCallback();
|
|
267
|
-
}
|
|
268
|
-
}).catch((error) => { seriesCallback(error); });
|
|
269
|
-
}
|
|
270
|
-
], (error) => {
|
|
271
|
-
log.info("Post recounted", { error: error });
|
|
272
|
-
callback();
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
const recountGroup = (workPackage, callback) => {
|
|
276
|
-
const groupId = workPackage.groupId;
|
|
277
|
-
let postsCount = 0, pointsCount = 0;
|
|
278
|
-
async.series([
|
|
279
|
-
(seriesCallback) => {
|
|
280
|
-
models.Post.findAll({
|
|
281
|
-
where: {
|
|
282
|
-
group_id: groupId
|
|
283
|
-
}
|
|
284
|
-
}).then(function (posts) {
|
|
285
|
-
postsCount = posts.length;
|
|
286
|
-
async.forEachLimit(posts, 100, (post, forEachCallback) => {
|
|
287
|
-
recountPost(post.id, forEachCallback);
|
|
288
|
-
}, (error) => {
|
|
289
|
-
seriesCallback(error);
|
|
290
|
-
});
|
|
291
|
-
}).catch((error) => {
|
|
292
|
-
seriesCallback(error);
|
|
293
|
-
});
|
|
294
|
-
},
|
|
295
|
-
(seriesCallback) => {
|
|
296
|
-
models.Point.findAll({
|
|
297
|
-
include: [
|
|
298
|
-
{
|
|
299
|
-
model: models.Post,
|
|
300
|
-
where: {
|
|
301
|
-
group_id: groupId
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
]
|
|
305
|
-
}).then(function (points) {
|
|
306
|
-
pointsCount = points.length;
|
|
307
|
-
seriesCallback();
|
|
308
|
-
}).catch((error) => {
|
|
309
|
-
seriesCallback(error);
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
], (error) => {
|
|
313
|
-
if (error) {
|
|
314
|
-
callback(error);
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
models.Group.findOne({
|
|
318
|
-
where: { id: groupId },
|
|
319
|
-
attributes: ['id', 'community_id', 'counter_posts', 'counter_points', 'counter_users'],
|
|
320
|
-
include: [
|
|
321
|
-
{
|
|
322
|
-
model: models.User,
|
|
323
|
-
as: 'GroupUsers',
|
|
324
|
-
attributes: ['id'],
|
|
325
|
-
required: false
|
|
326
|
-
}
|
|
327
|
-
]
|
|
328
|
-
}).then((group) => {
|
|
329
|
-
if (group) {
|
|
330
|
-
group.counter_posts = postsCount;
|
|
331
|
-
group.counter_points = pointsCount;
|
|
332
|
-
group.counter_users = group.GroupUsers ? group.GroupUsers.length : 0;
|
|
333
|
-
group.save().then(() => {
|
|
334
|
-
log.info("Group recounted", { error: error, context: 'ac-delete', groupId: groupId });
|
|
335
|
-
callback();
|
|
336
|
-
}).catch((error) => {
|
|
337
|
-
callback(error);
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
log.warn("No group for update counters, recountGroup", { groupId: groupId });
|
|
342
|
-
callback();
|
|
343
|
-
}
|
|
344
|
-
}).catch((error) => {
|
|
345
|
-
callback(error);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
};
|
|
350
|
-
const recountCommunity = (workPackage, callback) => {
|
|
351
|
-
models.Community.findOne({
|
|
352
|
-
attributes: ['id', 'counter_posts', 'counter_points', 'counter_users'],
|
|
353
|
-
where: {
|
|
354
|
-
id: workPackage.communityId
|
|
355
|
-
},
|
|
356
|
-
include: [
|
|
357
|
-
{
|
|
358
|
-
model: models.Group,
|
|
359
|
-
attributes: ['id', 'counter_posts', 'counter_points', 'counter_users'],
|
|
360
|
-
where: {
|
|
361
|
-
is_group_folder: false
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
model: models.User,
|
|
366
|
-
as: 'CommunityUsers',
|
|
367
|
-
attributes: ['id'],
|
|
368
|
-
required: false
|
|
369
|
-
}
|
|
370
|
-
]
|
|
371
|
-
}).then((community) => {
|
|
372
|
-
if (community) {
|
|
373
|
-
const groupIds = _.map(community.Groups, (group) => {
|
|
374
|
-
return group.id;
|
|
375
|
-
});
|
|
376
|
-
async.series([
|
|
377
|
-
(innerCallback) => {
|
|
378
|
-
if (workPackage.doDeepGroupCounting) {
|
|
379
|
-
async.forEachLimit(groupIds, 100, (groupId, forEachCallback) => {
|
|
380
|
-
recountGroup({ groupId: groupId }, forEachCallback);
|
|
381
|
-
}, (error) => {
|
|
382
|
-
log.info("Community groups deep recounted", { error: error, context: 'ac-delete', communityId: workPackage.communityId });
|
|
383
|
-
innerCallback(error);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
innerCallback();
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
(innerCallback) => {
|
|
391
|
-
let postCount = 0, pointCount = 0, userCount = 0;
|
|
392
|
-
community.reload().then((community) => {
|
|
393
|
-
_.forEach(community.Groups, (group) => {
|
|
394
|
-
postCount += group.counter_posts;
|
|
395
|
-
pointCount += group.counter_points;
|
|
396
|
-
});
|
|
397
|
-
community.counter_posts = postCount;
|
|
398
|
-
community.counter_points = pointCount;
|
|
399
|
-
community.counter_users = community.CommunityUsers ? community.CommunityUsers.length : 0;
|
|
400
|
-
community.save().then(() => {
|
|
401
|
-
log.info("Community recounted", { context: 'ac-delete', communityId: workPackage.communityId });
|
|
402
|
-
innerCallback();
|
|
403
|
-
}).catch((error) => {
|
|
404
|
-
innerCallback(error);
|
|
405
|
-
});
|
|
406
|
-
}).catch((error) => {
|
|
407
|
-
innerCallback();
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
], (error) => {
|
|
411
|
-
callback(error);
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
callback("No community in recount community");
|
|
416
|
-
}
|
|
417
|
-
}).catch((error) => {
|
|
418
|
-
callback(error);
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
const recountDomain = (workPackage, callback) => {
|
|
422
|
-
log.info("recountDomain started");
|
|
423
|
-
models.Domain.findOne({
|
|
424
|
-
attributes: ['id', 'counter_posts', 'counter_points', 'counter_users'],
|
|
425
|
-
where: {
|
|
426
|
-
id: workPackage.domainId
|
|
427
|
-
},
|
|
428
|
-
include: [
|
|
429
|
-
{
|
|
430
|
-
model: models.Community,
|
|
431
|
-
attributes: ['id', 'counter_posts', 'counter_points', 'counter_users']
|
|
432
|
-
}
|
|
433
|
-
]
|
|
434
|
-
}).then((domain) => {
|
|
435
|
-
if (domain) {
|
|
436
|
-
log.info("recountDomain found domain");
|
|
437
|
-
async.series([
|
|
438
|
-
(innerCallback) => {
|
|
439
|
-
let postCount = 0, pointCount = 0, userCount = 0;
|
|
440
|
-
_.forEach(domain.Communities, (community) => {
|
|
441
|
-
postCount += community.counter_posts;
|
|
442
|
-
pointCount += community.counter_points;
|
|
443
|
-
});
|
|
444
|
-
domain.counter_posts = postCount;
|
|
445
|
-
domain.counter_points = pointCount;
|
|
446
|
-
domain.save().then(() => {
|
|
447
|
-
log.info("recountDomain done", { workPackage: workPackage });
|
|
448
|
-
innerCallback();
|
|
449
|
-
}).catch((error) => {
|
|
450
|
-
innerCallback(error);
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
], (error) => {
|
|
454
|
-
callback(error);
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
callback("No domain");
|
|
459
|
-
}
|
|
460
|
-
}).catch((error) => {
|
|
461
|
-
callback(error);
|
|
462
|
-
});
|
|
463
|
-
};
|
|
464
|
-
const recountGroupFromPostId = (postId, callback) => {
|
|
465
|
-
let postsCount = 0;
|
|
466
|
-
let pointsCount = 0;
|
|
467
|
-
models.Post.unscoped().findOne({
|
|
468
|
-
where: { id: postId },
|
|
469
|
-
attributes: ['id', 'group_id']
|
|
470
|
-
}).then((post) => {
|
|
471
|
-
if (post) {
|
|
472
|
-
let groupId = post.group_id;
|
|
473
|
-
async.series([
|
|
474
|
-
(seriesCallback) => {
|
|
475
|
-
models.Post.findAll({
|
|
476
|
-
where: {
|
|
477
|
-
group_id: groupId
|
|
478
|
-
}
|
|
479
|
-
}).then(function (posts) {
|
|
480
|
-
postsCount = posts.length;
|
|
481
|
-
seriesCallback();
|
|
482
|
-
}).catch((error) => {
|
|
483
|
-
seriesCallback(error);
|
|
484
|
-
});
|
|
485
|
-
},
|
|
486
|
-
(seriesCallback) => {
|
|
487
|
-
models.Point.findAll({
|
|
488
|
-
include: [
|
|
489
|
-
{
|
|
490
|
-
model: models.Post,
|
|
491
|
-
where: {
|
|
492
|
-
group_id: groupId
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
]
|
|
496
|
-
}).then(function (posts) {
|
|
497
|
-
pointsCount = posts.length;
|
|
498
|
-
seriesCallback();
|
|
499
|
-
}).catch((error) => {
|
|
500
|
-
seriesCallback(error);
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
], (error) => {
|
|
504
|
-
if (error) {
|
|
505
|
-
callback(error);
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
models.Group.findOne({
|
|
509
|
-
where: { id: groupId },
|
|
510
|
-
attributes: ['id', 'community_id', 'counter_posts', 'counter_points']
|
|
511
|
-
}).then((group) => {
|
|
512
|
-
if (group) {
|
|
513
|
-
group.counter_posts = postsCount;
|
|
514
|
-
group.counter_points = pointsCount;
|
|
515
|
-
group.save().then(() => {
|
|
516
|
-
callback();
|
|
517
|
-
}).catch((error) => {
|
|
518
|
-
callback(error);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
log.warn("No group for update counters, recountGroupFromPostId", { groupId: groupId });
|
|
523
|
-
callback();
|
|
524
|
-
}
|
|
525
|
-
}).catch((error) => {
|
|
526
|
-
callback(error);
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
log.warn("No post for update counters");
|
|
533
|
-
callback();
|
|
534
|
-
}
|
|
535
|
-
}).catch((error) => {
|
|
536
|
-
log.info("recountGroupFromPostId done", { error: error });
|
|
537
|
-
callback(error);
|
|
538
|
-
});
|
|
539
|
-
};
|
|
540
|
-
const resetCountForCommunityForGroup = (groupId, callback) => {
|
|
541
|
-
let totalPosts = 0, totalPoints = 0;
|
|
542
|
-
models.Group.unscoped().findOne({
|
|
543
|
-
where: { id: groupId },
|
|
544
|
-
attributes: ['id', 'community_id']
|
|
545
|
-
}).then((group) => {
|
|
546
|
-
if (group) {
|
|
547
|
-
let communityId = group.community_id;
|
|
548
|
-
async.series([
|
|
549
|
-
(seriesCallback) => {
|
|
550
|
-
models.Group.findAll({
|
|
551
|
-
where: { community_id: communityId },
|
|
552
|
-
attributes: ['id', 'community_id', 'counter_points', 'counter_posts']
|
|
553
|
-
}).then((groups) => {
|
|
554
|
-
groups.forEach((group) => {
|
|
555
|
-
if (group.counter_posts) {
|
|
556
|
-
totalPosts += group.counter_posts;
|
|
557
|
-
}
|
|
558
|
-
if (group.counter_points) {
|
|
559
|
-
totalPoints += group.counter_points;
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
models.Community.update({ counter_posts: totalPosts, counter_points: totalPoints }, { where: { id: communityId } }).then(() => {
|
|
563
|
-
seriesCallback();
|
|
564
|
-
}).catch((error) => {
|
|
565
|
-
seriesCallback(error);
|
|
566
|
-
});
|
|
567
|
-
}).catch((error) => {
|
|
568
|
-
seriesCallback(error);
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
], (error) => {
|
|
572
|
-
callback(error);
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
callback();
|
|
577
|
-
}
|
|
578
|
-
}).catch((error) => {
|
|
579
|
-
log.info("resetCountForCommunityForGroup done", { error: error });
|
|
580
|
-
callback(error);
|
|
581
|
-
});
|
|
582
|
-
};
|
|
583
|
-
const deletePointContent = (workPackage, callback) => {
|
|
584
|
-
const pointId = workPackage.pointId;
|
|
585
|
-
log.info('Starting Point Activities Delete', { pointId: pointId, context: 'ac-delete', userId: workPackage.userId });
|
|
586
|
-
if (pointId) {
|
|
587
|
-
async.series([
|
|
588
|
-
(seriesCallback) => {
|
|
589
|
-
if (!workPackage.skipActivities) {
|
|
590
|
-
models.AcActivity.update({ deleted: true }, { where: { point_id: pointId } }).then(function (spread) {
|
|
591
|
-
log.info('Point Activities Deleted', { pointId: pointId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
592
|
-
seriesCallback();
|
|
593
|
-
}).catch(function (error) {
|
|
594
|
-
seriesCallback(error);
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
seriesCallback();
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
(seriesCallback) => {
|
|
602
|
-
models.PointQuality.update({ deleted: true }, { where: { point_id: pointId } }).then(function (spread) {
|
|
603
|
-
log.info('Point Quality Deleted', { pointId: pointId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
604
|
-
seriesCallback();
|
|
605
|
-
}).catch(function (error) {
|
|
606
|
-
seriesCallback(error);
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
], (error) => {
|
|
610
|
-
log.info("deletePointContent done", { error: error, workPackage: workPackage });
|
|
611
|
-
callback(error);
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
else {
|
|
615
|
-
callback("No pointId for deletePointContent");
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
const deletePointActivities = (workPackage, callback) => {
|
|
619
|
-
const pointId = workPackage.pointId;
|
|
620
|
-
const userId = workPackage.userId;
|
|
621
|
-
log.info('Starting Point Activities Delete', { pointId: pointId, context: 'ac-delete', userId: workPackage.userId });
|
|
622
|
-
if (pointId) {
|
|
623
|
-
async.series([
|
|
624
|
-
(seriesCallback) => {
|
|
625
|
-
models.AcActivity.update({ deleted: true }, { where: { point_id: pointId } }).then(function (spread) {
|
|
626
|
-
log.info('Point Activities Deleted', { pointId: pointId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
627
|
-
seriesCallback();
|
|
628
|
-
}).catch(function (error) {
|
|
629
|
-
seriesCallback(error);
|
|
630
|
-
});
|
|
631
|
-
},
|
|
632
|
-
(seriesCallback) => {
|
|
633
|
-
models.PointRevision.update({ deleted: true }, { where: { point_id: pointId } }).then(function (spread) {
|
|
634
|
-
log.info('Point Revision Deleted', { pointId: pointId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
635
|
-
seriesCallback();
|
|
636
|
-
}).catch(function (error) {
|
|
637
|
-
seriesCallback(error);
|
|
638
|
-
});
|
|
639
|
-
},
|
|
640
|
-
(seriesCallback) => {
|
|
641
|
-
models.PointQuality.update({ deleted: true }, { where: { point_id: pointId } }).then(function (spread) {
|
|
642
|
-
log.info('Point Quality Deleted', { pointId: pointId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
643
|
-
seriesCallback();
|
|
644
|
-
}).catch(function (error) {
|
|
645
|
-
seriesCallback(error);
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
], (error) => {
|
|
649
|
-
log.info("deletePointActivities done", { error: error, workPackage: workPackage });
|
|
650
|
-
callback(error);
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
log.error("No pointId, userId for deletePointActivities", { workPackage: workPackage });
|
|
655
|
-
callback("No pointId, userId for deletePointActivities");
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
const deletePostActivities = (workPackage, callback) => {
|
|
659
|
-
const postId = workPackage.postId;
|
|
660
|
-
const userId = workPackage.userId;
|
|
661
|
-
log.info('Starting Post Activities Delete', { postId: postId, context: 'ac-delete', userId: workPackage.userId });
|
|
662
|
-
if (postId) {
|
|
663
|
-
async.series([
|
|
664
|
-
(seriesCallback) => {
|
|
665
|
-
models.AcActivity.update({ deleted: true }, { where: { post_id: postId } }).then(function (spread) {
|
|
666
|
-
log.info('Post User Activities Deleted', { postId: postId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
667
|
-
seriesCallback();
|
|
668
|
-
}).catch(function (error) {
|
|
669
|
-
seriesCallback(error);
|
|
670
|
-
});
|
|
671
|
-
},
|
|
672
|
-
(seriesCallback) => {
|
|
673
|
-
models.Endorsement.update({ deleted: true }, { where: { post_id: postId } }).then(function (spread) {
|
|
674
|
-
log.info('Post User Endorsement Deleted', { postId: postId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
675
|
-
seriesCallback();
|
|
676
|
-
}).catch(function (error) {
|
|
677
|
-
seriesCallback(error);
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
], (error) => {
|
|
681
|
-
log.info("deletePostActivities done", { error: error, workPackage: workPackage });
|
|
682
|
-
callback(error);
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
else {
|
|
686
|
-
callback("No pointId, userId for deletePostActivities");
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
const deletePostContent = (workPackage, callback) => {
|
|
690
|
-
const postId = workPackage.postId;
|
|
691
|
-
log.info('Starting Post Activities Delete', { postId: postId, context: 'ac-delete', userId: workPackage.userId });
|
|
692
|
-
if (postId) {
|
|
693
|
-
async.series([
|
|
694
|
-
(seriesCallback) => {
|
|
695
|
-
if (!workPackage.skipActivities) {
|
|
696
|
-
models.AcActivity.update({ deleted: true }, { where: { post_id: postId } }).then((spread) => {
|
|
697
|
-
log.info('Post Activities Deleted', { postId: postId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
698
|
-
seriesCallback();
|
|
699
|
-
}).catch((error) => {
|
|
700
|
-
seriesCallback(error);
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
else {
|
|
704
|
-
seriesCallback();
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
(seriesCallback) => {
|
|
708
|
-
models.Point.findAll({
|
|
709
|
-
attributes: ['id', 'post_id'],
|
|
710
|
-
where: {
|
|
711
|
-
post_id: postId
|
|
712
|
-
}
|
|
713
|
-
}).then((points) => {
|
|
714
|
-
async.forEachLimit(points, 100, (point, innerCallback) => {
|
|
715
|
-
deletePointContent(_.merge({ pointId: point.id, skipActivities: true }, workPackage), innerCallback);
|
|
716
|
-
queue.add('process-similarities', { type: 'update-collection', pointId: point.id }, 'low', { delay: 10000 });
|
|
717
|
-
}, (error) => {
|
|
718
|
-
seriesCallback(error);
|
|
719
|
-
});
|
|
720
|
-
}).catch((error) => {
|
|
721
|
-
seriesCallback(error);
|
|
722
|
-
});
|
|
723
|
-
},
|
|
724
|
-
(seriesCallback) => {
|
|
725
|
-
models.Point.update({ deleted: true }, { where: { post_id: postId } }).then((spread) => {
|
|
726
|
-
log.info('Post Activities Points Deleted', { postId: postId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
727
|
-
seriesCallback();
|
|
728
|
-
}).catch((error) => {
|
|
729
|
-
seriesCallback(error);
|
|
730
|
-
});
|
|
731
|
-
},
|
|
732
|
-
(seriesCallback) => {
|
|
733
|
-
models.Endorsement.update({ deleted: true }, { where: { post_id: postId } }).then((spread) => {
|
|
734
|
-
log.info('Post Endorsement Deleted', { postId: postId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
735
|
-
seriesCallback();
|
|
736
|
-
}).catch((error) => {
|
|
737
|
-
seriesCallback(error);
|
|
738
|
-
});
|
|
739
|
-
},
|
|
740
|
-
(seriesCallback) => {
|
|
741
|
-
if (workPackage.resetCounters) {
|
|
742
|
-
models.Post.update({ counter_endorsements_up: 0, counter_endorsements_down: 0, counter_points: 0, counter_users: 0 }, { where: { id: postId } }).then(function () {
|
|
743
|
-
log.info("Post reset counters for post");
|
|
744
|
-
recountGroupFromPostId(postId, (error) => {
|
|
745
|
-
seriesCallback(error);
|
|
746
|
-
});
|
|
747
|
-
}).catch((error) => {
|
|
748
|
-
seriesCallback(error);
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
seriesCallback();
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
], (error) => {
|
|
756
|
-
if (workPackage.useNotification) {
|
|
757
|
-
models.Post.findOne({
|
|
758
|
-
where: { id: postId },
|
|
759
|
-
attributes: ['id', 'group_id'],
|
|
760
|
-
include: [
|
|
761
|
-
{
|
|
762
|
-
model: models.Group,
|
|
763
|
-
attributes: ['id', 'community_id'],
|
|
764
|
-
include: [
|
|
765
|
-
{
|
|
766
|
-
model: models.Community,
|
|
767
|
-
attributes: ['id', 'domain_id']
|
|
768
|
-
}
|
|
769
|
-
]
|
|
770
|
-
}
|
|
771
|
-
]
|
|
772
|
-
}).then((post) => {
|
|
773
|
-
if (post) {
|
|
774
|
-
const notificationType = error ? 'deletePostContentError' : 'deletePostContentDone';
|
|
775
|
-
models.AcActivity.createActivity({
|
|
776
|
-
type: 'activity.system.generalUserNotification',
|
|
777
|
-
object: { type: notificationType, name: workPackage.postName, forwardToUser: true, offerReload: true },
|
|
778
|
-
userId: workPackage.userId, postId: postId, groupId: post.Group.id, communityId: post.Group.Community.id,
|
|
779
|
-
domainId: post.Group.Community.domain_id
|
|
780
|
-
}, (subError) => {
|
|
781
|
-
callback(error || subError);
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
else {
|
|
785
|
-
callback("Could not find post for notification in deletions");
|
|
786
|
-
}
|
|
787
|
-
}).catch((error) => {
|
|
788
|
-
callback(error);
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
else {
|
|
792
|
-
callback(error);
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
callback("No postId for deletePostContent");
|
|
798
|
-
}
|
|
799
|
-
};
|
|
800
|
-
const deleteGroupContent = (workPackage, callback) => {
|
|
801
|
-
const groupId = workPackage.groupId;
|
|
802
|
-
let allPosts = null;
|
|
803
|
-
log.info('Starting Group Activities Delete', { groupId: groupId, context: 'ac-delete', userId: workPackage.userId });
|
|
804
|
-
if (groupId) {
|
|
805
|
-
async.series([
|
|
806
|
-
(seriesCallback) => {
|
|
807
|
-
models.AcActivity.update({ deleted: true }, { where: { group_id: groupId } }).then((spread) => {
|
|
808
|
-
log.info('Group Activities Deleted', { groupId: groupId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
809
|
-
seriesCallback();
|
|
810
|
-
}).catch((error) => {
|
|
811
|
-
seriesCallback(error);
|
|
812
|
-
});
|
|
813
|
-
},
|
|
814
|
-
(seriesCallback) => {
|
|
815
|
-
models.Post.findAll({
|
|
816
|
-
attributes: ['id'],
|
|
817
|
-
where: { group_id: groupId }
|
|
818
|
-
}).then(function (posts) {
|
|
819
|
-
async.forEachLimit(posts, 100, function (post, innerCallback) {
|
|
820
|
-
deletePostContent(_.merge({ postId: post.id, skipActivities: true, useNotification: false, resetCounters: false }, workPackage), innerCallback);
|
|
821
|
-
queue.add('process-similarities', { type: 'update-collection', postId: post.id }, 'low', { delay: 10000 });
|
|
822
|
-
}, (error) => {
|
|
823
|
-
seriesCallback(error);
|
|
824
|
-
});
|
|
825
|
-
}).catch((error) => {
|
|
826
|
-
seriesCallback(error);
|
|
827
|
-
});
|
|
828
|
-
},
|
|
829
|
-
(seriesCallback) => {
|
|
830
|
-
models.Post.update({ deleted: true }, { where: { group_id: groupId } }).then((spread) => {
|
|
831
|
-
log.info('Group Activities Post Deleted', { groupId: groupId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
832
|
-
seriesCallback();
|
|
833
|
-
}).catch((error) => {
|
|
834
|
-
seriesCallback(error);
|
|
835
|
-
});
|
|
836
|
-
},
|
|
837
|
-
(seriesCallback) => {
|
|
838
|
-
if (workPackage.resetCounters) {
|
|
839
|
-
models.Group.update({ counter_posts: 0, counter_points: 0, counter_users: 0 }, { where: { id: groupId } }).then(function () {
|
|
840
|
-
log.info("Group reset counters for group");
|
|
841
|
-
resetCountForCommunityForGroup(groupId, seriesCallback);
|
|
842
|
-
}).catch((error) => {
|
|
843
|
-
seriesCallback(error);
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
seriesCallback();
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
], (error) => {
|
|
851
|
-
if (workPackage.useNotification) {
|
|
852
|
-
models.Group.findOne({
|
|
853
|
-
where: { id: groupId },
|
|
854
|
-
attributes: ['id', 'community_id'],
|
|
855
|
-
include: [
|
|
856
|
-
{
|
|
857
|
-
model: models.Community,
|
|
858
|
-
attributes: ['id', 'domain_id']
|
|
859
|
-
}
|
|
860
|
-
]
|
|
861
|
-
}).then((group) => {
|
|
862
|
-
if (group) {
|
|
863
|
-
const notificationType = error ? 'deleteGroupContentError' : 'deleteGroupContentDone';
|
|
864
|
-
models.AcActivity.createActivity({
|
|
865
|
-
type: 'activity.system.generalUserNotification',
|
|
866
|
-
object: { type: notificationType, name: workPackage.groupName, forwardToUser: true, offerReload: true },
|
|
867
|
-
userId: workPackage.userId, groupId: group.id, communityId: group.Community.id, domainId: group.Community.domain_id
|
|
868
|
-
}, (subError) => {
|
|
869
|
-
callback(error || subError);
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
callback("Could not find group for notification in deletions");
|
|
874
|
-
}
|
|
875
|
-
}).catch((error) => {
|
|
876
|
-
callback(error);
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
else {
|
|
880
|
-
callback(error);
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
else {
|
|
885
|
-
callback("No groupId for deleteGroupContent");
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
|
-
const deleteCommunityContent = (workPackage, callback) => {
|
|
889
|
-
const communityId = workPackage.communityId;
|
|
890
|
-
log.info('Starting Community Activities Delete', { communityId: communityId, context: 'ac-delete', userId: workPackage.userId });
|
|
891
|
-
if (communityId) {
|
|
892
|
-
async.series([
|
|
893
|
-
(seriesCallback) => {
|
|
894
|
-
models.AcActivity.update({ deleted: true }, { where: { community_id: communityId } }).then(function (spread) {
|
|
895
|
-
log.info('Community Activities Deleted', { communityId: communityId, numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
896
|
-
seriesCallback();
|
|
897
|
-
}).catch(function (error) {
|
|
898
|
-
seriesCallback(error);
|
|
899
|
-
});
|
|
900
|
-
},
|
|
901
|
-
(seriesCallback) => {
|
|
902
|
-
models.Group.findAll({
|
|
903
|
-
attributes: ['id'],
|
|
904
|
-
where: { community_id: communityId }
|
|
905
|
-
}).then(function (groups) {
|
|
906
|
-
groups.forEach(function (group) {
|
|
907
|
-
queue.add('process-deletion', { type: 'delete-group-content', userId: workPackage.userId, groupId: group.id }, 'high');
|
|
908
|
-
queue.add('process-similarities', { type: 'update-collection', groupId: group.id }, 'low', { delay: 10000 });
|
|
909
|
-
});
|
|
910
|
-
seriesCallback();
|
|
911
|
-
}).catch((error) => {
|
|
912
|
-
seriesCallback(error);
|
|
913
|
-
});
|
|
914
|
-
},
|
|
915
|
-
(seriesCallback) => {
|
|
916
|
-
if (workPackage.resetCounters) {
|
|
917
|
-
models.Community.update({ counter_posts: 0, counter_points: 0, counter_groups: 0, counter_users: 0 }, { where: { id: communityId } }).then(function () {
|
|
918
|
-
log.info("Community reset counters for community");
|
|
919
|
-
seriesCallback();
|
|
920
|
-
}).catch((error) => {
|
|
921
|
-
seriesCallback(error);
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
seriesCallback();
|
|
926
|
-
}
|
|
927
|
-
},
|
|
928
|
-
(seriesCallback) => {
|
|
929
|
-
models.Group.update({ deleted: true }, { where: { community_id: communityId } }).then(function () {
|
|
930
|
-
log.info("Community groups deleted");
|
|
931
|
-
seriesCallback();
|
|
932
|
-
}).catch((error) => {
|
|
933
|
-
seriesCallback(error);
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
], (error) => {
|
|
937
|
-
if (workPackage.useNotification) {
|
|
938
|
-
models.Community.findOne({
|
|
939
|
-
where: { id: communityId },
|
|
940
|
-
attributes: ['id', 'domain_id']
|
|
941
|
-
}).then((community) => {
|
|
942
|
-
if (community) {
|
|
943
|
-
const notificationType = error ? 'deleteCommunityContentError' : 'deleteCommunityContentDone';
|
|
944
|
-
models.AcActivity.createActivity({
|
|
945
|
-
type: 'activity.system.generalUserNotification',
|
|
946
|
-
object: { type: notificationType, name: workPackage.communityName, forwardToUser: true, offerReload: true },
|
|
947
|
-
userId: workPackage.userId, communityId: community.id, domainId: community.domain_id
|
|
948
|
-
}, (subError) => {
|
|
949
|
-
callback(error || subError);
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
else {
|
|
953
|
-
callback("Could not find community for notifications in deletions");
|
|
954
|
-
}
|
|
955
|
-
}).catch((error) => {
|
|
956
|
-
callback(error);
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
else {
|
|
960
|
-
callback(error);
|
|
961
|
-
}
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
else {
|
|
965
|
-
callback("No communityId for deleteCommunityContent");
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
const deleteUserEndorsements = (workPackage, callback) => {
|
|
969
|
-
models.Endorsement.findAll({
|
|
970
|
-
attributes: ['id', 'post_id', 'deleted', 'value'],
|
|
971
|
-
where: {
|
|
972
|
-
user_id: workPackage.userId
|
|
973
|
-
},
|
|
974
|
-
include: [
|
|
975
|
-
{
|
|
976
|
-
model: models.Post,
|
|
977
|
-
attributes: ['id', 'counter_endorsements_up', 'counter_endorsements_down']
|
|
978
|
-
}
|
|
979
|
-
]
|
|
980
|
-
}).then((endorsements) => {
|
|
981
|
-
async.forEachLimit(endorsements, 100, (endorsement, forEachCallback) => {
|
|
982
|
-
if (endorsement.value === 1) {
|
|
983
|
-
endorsement.Post.decrement('counter_endorsements_up');
|
|
984
|
-
}
|
|
985
|
-
else {
|
|
986
|
-
endorsement.Post.decrement('counter_endorsements_down');
|
|
987
|
-
}
|
|
988
|
-
endorsement.deleted = true;
|
|
989
|
-
endorsement.save().then(() => {
|
|
990
|
-
forEachCallback();
|
|
991
|
-
}).catch((error) => {
|
|
992
|
-
forEachCallback(error);
|
|
993
|
-
});
|
|
994
|
-
}, (error) => {
|
|
995
|
-
if (error) {
|
|
996
|
-
callback(error);
|
|
997
|
-
}
|
|
998
|
-
else {
|
|
999
|
-
log.info('User Endorsements Deleted', { context: 'ac-delete', userId: workPackage.userId });
|
|
1000
|
-
callback();
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
}).catch((error) => {
|
|
1004
|
-
callback(error);
|
|
1005
|
-
});
|
|
1006
|
-
};
|
|
1007
|
-
const deleteUserGroupEndorsements = (workPackage, callback) => {
|
|
1008
|
-
models.Endorsement.findAll({
|
|
1009
|
-
attributes: ['id', 'post_id', 'deleted', 'value'],
|
|
1010
|
-
where: {
|
|
1011
|
-
user_id: workPackage.userId
|
|
1012
|
-
},
|
|
1013
|
-
include: [
|
|
1014
|
-
{
|
|
1015
|
-
model: models.Post,
|
|
1016
|
-
attributes: ['id', 'counter_endorsements_up', 'counter_endorsements_down'],
|
|
1017
|
-
where: {
|
|
1018
|
-
group_id: workPackage.groupId
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
]
|
|
1022
|
-
}).then((endorsements) => {
|
|
1023
|
-
async.forEachLimit(endorsements, 100, (endorsement, forEachCallback) => {
|
|
1024
|
-
if (endorsement.value === 1) {
|
|
1025
|
-
endorsement.Post.decrement('counter_endorsements_up');
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
endorsement.Post.decrement('counter_endorsements_down');
|
|
1029
|
-
}
|
|
1030
|
-
endorsement.deleted = true;
|
|
1031
|
-
endorsement.save().then(() => {
|
|
1032
|
-
forEachCallback();
|
|
1033
|
-
}).catch((error) => {
|
|
1034
|
-
forEachCallback(error);
|
|
1035
|
-
});
|
|
1036
|
-
}, (error) => {
|
|
1037
|
-
if (error) {
|
|
1038
|
-
callback(error);
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
log.info('User Group Endorsements Deleted', { context: 'ac-delete', userId: workPackage.userId });
|
|
1042
|
-
callback();
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
}).catch((error) => {
|
|
1046
|
-
callback(error);
|
|
1047
|
-
});
|
|
1048
|
-
};
|
|
1049
|
-
const moveUserEndorsements = (workPackage, callback) => {
|
|
1050
|
-
models.Endorsement.update({ user_id: workPackage.toUserId }, { where: { user_id: workPackage.fromUserId } }).then((spread) => {
|
|
1051
|
-
log.info('Endorsement Moved', { numberDeleted: spread[0], context: 'ac-move', fromUserId: workPackage.fromUserId, toUserId: workPackage.toUserId });
|
|
1052
|
-
callback();
|
|
1053
|
-
}).catch((error) => {
|
|
1054
|
-
callback(error);
|
|
1055
|
-
});
|
|
1056
|
-
};
|
|
1057
|
-
const deleteUserContent = (workPackage, callback) => {
|
|
1058
|
-
if (workPackage.userId && workPackage.anonymousUserId) {
|
|
1059
|
-
async.series([
|
|
1060
|
-
(seriesCallback) => {
|
|
1061
|
-
deleteUserEndorsements(workPackage, seriesCallback);
|
|
1062
|
-
},
|
|
1063
|
-
(seriesCallback) => {
|
|
1064
|
-
models.PointQuality.findAll({
|
|
1065
|
-
attributes: ['id', 'point_id', 'deleted', 'value'],
|
|
1066
|
-
where: {
|
|
1067
|
-
user_id: workPackage.userId
|
|
1068
|
-
},
|
|
1069
|
-
include: [
|
|
1070
|
-
{
|
|
1071
|
-
model: models.Point,
|
|
1072
|
-
attributes: ['id', 'counter_quality_up', 'counter_quality_down']
|
|
1073
|
-
}
|
|
1074
|
-
]
|
|
1075
|
-
}).then(function (pointQualities) {
|
|
1076
|
-
async.forEachLimit(pointQualities, 100, function (pointQuality, forEachCallback) {
|
|
1077
|
-
if (pointQuality.value === 1) {
|
|
1078
|
-
pointQuality.Point.decrement('counter_quality_up');
|
|
1079
|
-
}
|
|
1080
|
-
else {
|
|
1081
|
-
pointQuality.Point.decrement('counter_quality_down');
|
|
1082
|
-
}
|
|
1083
|
-
pointQuality.deleted = true;
|
|
1084
|
-
pointQuality.save().then(function () {
|
|
1085
|
-
forEachCallback();
|
|
1086
|
-
}).catch((error) => {
|
|
1087
|
-
forEachCallback(error);
|
|
1088
|
-
});
|
|
1089
|
-
}, function (error) {
|
|
1090
|
-
if (error) {
|
|
1091
|
-
seriesCallback(error);
|
|
1092
|
-
}
|
|
1093
|
-
else {
|
|
1094
|
-
log.info('User PointQuality Deleted', { context: 'ac-delete', userId: workPackage.userId });
|
|
1095
|
-
seriesCallback();
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
}).catch((error) => {
|
|
1099
|
-
seriesCallback(error);
|
|
1100
|
-
});
|
|
1101
|
-
},
|
|
1102
|
-
(seriesCallback) => {
|
|
1103
|
-
models.Point.update({ deleted: true }, { where: { user_id: workPackage.userId } }).then((spread) => {
|
|
1104
|
-
log.info('User Points Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1105
|
-
seriesCallback();
|
|
1106
|
-
}).catch((error) => {
|
|
1107
|
-
seriesCallback(error);
|
|
1108
|
-
});
|
|
1109
|
-
},
|
|
1110
|
-
(seriesCallback) => {
|
|
1111
|
-
models.AcActivity.update({ deleted: true }, { where: { user_id: workPackage.userId } }).then((spread) => {
|
|
1112
|
-
log.info('User AcActitivies Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1113
|
-
seriesCallback();
|
|
1114
|
-
}).catch((error) => {
|
|
1115
|
-
seriesCallback(error);
|
|
1116
|
-
});
|
|
1117
|
-
},
|
|
1118
|
-
(seriesCallback) => {
|
|
1119
|
-
models.Post.update({ deleted: true }, { where: { user_id: workPackage.userId } }).then((spread) => {
|
|
1120
|
-
log.info('User Post Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1121
|
-
seriesCallback();
|
|
1122
|
-
}).catch((error) => {
|
|
1123
|
-
seriesCallback(error);
|
|
1124
|
-
});
|
|
1125
|
-
},
|
|
1126
|
-
(seriesCallback) => {
|
|
1127
|
-
models.Group.update({ user_id: workPackage.anonymousUserId }, { where: { user_id: workPackage.userId } }).then((spread) => {
|
|
1128
|
-
log.info('User Groups Anonymized', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1129
|
-
seriesCallback();
|
|
1130
|
-
}).catch((error) => {
|
|
1131
|
-
seriesCallback(error);
|
|
1132
|
-
});
|
|
1133
|
-
},
|
|
1134
|
-
(seriesCallback) => {
|
|
1135
|
-
models.Community.update({ user_id: workPackage.anonymousUserId, ip_address: '127.0.0.1' }, { where: { user_id: workPackage.userId } }).then((spread) => {
|
|
1136
|
-
log.info('User Communities Anonymized', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1137
|
-
seriesCallback();
|
|
1138
|
-
}).catch((error) => {
|
|
1139
|
-
seriesCallback(error);
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
], (error) => {
|
|
1143
|
-
callback(error);
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
else {
|
|
1147
|
-
callback("No userId or workPackage.anonymousUserId");
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
const recountAllFromGroup = (workPackage, callback) => {
|
|
1151
|
-
let domainId, communityId;
|
|
1152
|
-
async.series([
|
|
1153
|
-
(seriesCallback) => {
|
|
1154
|
-
log.info("RecountAllFromGroup start");
|
|
1155
|
-
models.Group.findOne({
|
|
1156
|
-
where: {
|
|
1157
|
-
id: workPackage.groupId
|
|
1158
|
-
},
|
|
1159
|
-
attributes: ['id'],
|
|
1160
|
-
include: [
|
|
1161
|
-
{
|
|
1162
|
-
model: models.Community,
|
|
1163
|
-
attributes: ['id'],
|
|
1164
|
-
include: [
|
|
1165
|
-
{
|
|
1166
|
-
model: models.Domain,
|
|
1167
|
-
attributes: ['id']
|
|
1168
|
-
}
|
|
1169
|
-
]
|
|
1170
|
-
}
|
|
1171
|
-
]
|
|
1172
|
-
}).then((group) => {
|
|
1173
|
-
communityId = group.Community.id;
|
|
1174
|
-
domainId = group.Community.Domain.id;
|
|
1175
|
-
seriesCallback();
|
|
1176
|
-
}).catch((error) => { seriesCallback(); });
|
|
1177
|
-
},
|
|
1178
|
-
(seriesCallback) => {
|
|
1179
|
-
log.info("RecountAllFromGroup group count");
|
|
1180
|
-
recountGroup({ groupId: workPackage.groupId }, seriesCallback);
|
|
1181
|
-
},
|
|
1182
|
-
(seriesCallback) => {
|
|
1183
|
-
log.info("RecountAllFromGroup community count");
|
|
1184
|
-
recountCommunity({ communityId: communityId }, seriesCallback);
|
|
1185
|
-
},
|
|
1186
|
-
(seriesCallback) => {
|
|
1187
|
-
log.info("RecountAllFromGroup domain count");
|
|
1188
|
-
recountDomain({ domainId: domainId }, seriesCallback);
|
|
1189
|
-
}
|
|
1190
|
-
], (error) => {
|
|
1191
|
-
log.info("RecountAllFromGroup finished");
|
|
1192
|
-
callback();
|
|
1193
|
-
});
|
|
1194
|
-
};
|
|
1195
|
-
const recountAllFromCommunity = (workPackage, callback) => {
|
|
1196
|
-
let domainId;
|
|
1197
|
-
async.series([
|
|
1198
|
-
(seriesCallback) => {
|
|
1199
|
-
models.Community.findOne({
|
|
1200
|
-
where: {
|
|
1201
|
-
id: workPackage.communityId
|
|
1202
|
-
},
|
|
1203
|
-
attributes: ['id'],
|
|
1204
|
-
include: [
|
|
1205
|
-
{
|
|
1206
|
-
model: models.Domain,
|
|
1207
|
-
attributes: ['id']
|
|
1208
|
-
}
|
|
1209
|
-
]
|
|
1210
|
-
}).then((community) => {
|
|
1211
|
-
domainId = community.Domain.id;
|
|
1212
|
-
seriesCallback();
|
|
1213
|
-
}).catch((error) => { seriesCallback(); });
|
|
1214
|
-
},
|
|
1215
|
-
(seriesCallback) => {
|
|
1216
|
-
recountCommunity({ communityId: workPackage.communityId, doDeepGroupCounting: true }, seriesCallback);
|
|
1217
|
-
},
|
|
1218
|
-
(seriesCallback) => {
|
|
1219
|
-
recountDomain({ domainId: domainId }, seriesCallback);
|
|
1220
|
-
}
|
|
1221
|
-
], (error) => {
|
|
1222
|
-
log.info("RecountAllFromCommunity finished");
|
|
1223
|
-
callback(error);
|
|
1224
|
-
});
|
|
1225
|
-
};
|
|
1226
|
-
const recountAllFromDomain = (workPackage, callback) => {
|
|
1227
|
-
async.series([
|
|
1228
|
-
(seriesCallback) => {
|
|
1229
|
-
models.Domain.findOne({
|
|
1230
|
-
where: {
|
|
1231
|
-
id: workPackage.domainId
|
|
1232
|
-
},
|
|
1233
|
-
attributes: ['id'],
|
|
1234
|
-
include: [
|
|
1235
|
-
{
|
|
1236
|
-
model: models.Community,
|
|
1237
|
-
attributes: ['id']
|
|
1238
|
-
}
|
|
1239
|
-
]
|
|
1240
|
-
}).then((domain) => {
|
|
1241
|
-
async.forEachLimit(domain.Communities, 100, (community, forEachCallback) => {
|
|
1242
|
-
recountCommunity({ communityId: community.id, doDeepGroupCounting: true }, forEachCallback);
|
|
1243
|
-
}, (error) => { seriesCallback(error); });
|
|
1244
|
-
}).catch((error) => { seriesCallback(); });
|
|
1245
|
-
},
|
|
1246
|
-
(seriesCallback) => {
|
|
1247
|
-
recountDomain({ domainId: workPackage.domainId }, seriesCallback);
|
|
1248
|
-
}
|
|
1249
|
-
], (error) => {
|
|
1250
|
-
log.info("RecountAllFromDomain finished");
|
|
1251
|
-
callback(error);
|
|
1252
|
-
});
|
|
1253
|
-
};
|
|
1254
|
-
const deleteUserGroupContent = (workPackage, callback) => {
|
|
1255
|
-
if (workPackage.userId && workPackage.anonymousUserId && workPackage.groupId) {
|
|
1256
|
-
async.series([
|
|
1257
|
-
(seriesCallback) => {
|
|
1258
|
-
deleteUserGroupEndorsements(workPackage, seriesCallback);
|
|
1259
|
-
},
|
|
1260
|
-
(seriesCallback) => {
|
|
1261
|
-
models.PointQuality.findAll({
|
|
1262
|
-
attributes: ['id', 'point_id', 'deleted', 'value'],
|
|
1263
|
-
where: {
|
|
1264
|
-
user_id: workPackage.userId
|
|
1265
|
-
},
|
|
1266
|
-
include: [
|
|
1267
|
-
{
|
|
1268
|
-
model: models.Point,
|
|
1269
|
-
attributes: ['id', 'counter_quality_up', 'counter_quality_down'],
|
|
1270
|
-
required: true,
|
|
1271
|
-
where: {
|
|
1272
|
-
group_id: workPackage.groupId
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
]
|
|
1276
|
-
}).then(function (pointQualities) {
|
|
1277
|
-
async.forEachLimit(pointQualities, 100, function (pointQuality, forEachCallback) {
|
|
1278
|
-
if (pointQuality.value === 1) {
|
|
1279
|
-
pointQuality.Point.decrement('counter_quality_up');
|
|
1280
|
-
}
|
|
1281
|
-
else {
|
|
1282
|
-
pointQuality.Point.decrement('counter_quality_down');
|
|
1283
|
-
}
|
|
1284
|
-
pointQuality.deleted = true;
|
|
1285
|
-
pointQuality.save().then(function () {
|
|
1286
|
-
forEachCallback();
|
|
1287
|
-
}).catch((error) => {
|
|
1288
|
-
forEachCallback(error);
|
|
1289
|
-
});
|
|
1290
|
-
}, function (error) {
|
|
1291
|
-
if (error) {
|
|
1292
|
-
seriesCallback(error);
|
|
1293
|
-
}
|
|
1294
|
-
else {
|
|
1295
|
-
log.info('User PointQuality Deleted', { context: 'ac-delete', userId: workPackage.userId });
|
|
1296
|
-
seriesCallback();
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
}).catch((error) => {
|
|
1300
|
-
seriesCallback(error);
|
|
1301
|
-
});
|
|
1302
|
-
},
|
|
1303
|
-
(seriesCallback) => {
|
|
1304
|
-
models.Point.update({ deleted: true }, { where: { user_id: workPackage.userId, group_id: workPackage.groupId } }).then((spread) => {
|
|
1305
|
-
log.info('User Group Points Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1306
|
-
seriesCallback();
|
|
1307
|
-
}).catch((error) => {
|
|
1308
|
-
seriesCallback(error);
|
|
1309
|
-
});
|
|
1310
|
-
},
|
|
1311
|
-
(seriesCallback) => {
|
|
1312
|
-
models.AcActivity.update({ deleted: true }, { where: { user_id: workPackage.userId, group_id: workPackage.groupId } }).then((spread) => {
|
|
1313
|
-
log.info('User Group AcActitivies Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1314
|
-
seriesCallback();
|
|
1315
|
-
}).catch((error) => {
|
|
1316
|
-
seriesCallback(error);
|
|
1317
|
-
});
|
|
1318
|
-
},
|
|
1319
|
-
(seriesCallback) => {
|
|
1320
|
-
models.Post.update({ deleted: true }, { where: { user_id: workPackage.userId, group_id: workPackage.groupId } }).then((spread) => {
|
|
1321
|
-
log.info('User Post Deleted', { numberDeleted: spread[0], context: 'ac-delete', userId: workPackage.userId });
|
|
1322
|
-
seriesCallback();
|
|
1323
|
-
}).catch((error) => {
|
|
1324
|
-
seriesCallback(error);
|
|
1325
|
-
});
|
|
1326
|
-
},
|
|
1327
|
-
(seriesCallback) => {
|
|
1328
|
-
if (workPackage.skipRecount) {
|
|
1329
|
-
log.info("Skip recount in deleteGroup content");
|
|
1330
|
-
seriesCallback();
|
|
1331
|
-
}
|
|
1332
|
-
else {
|
|
1333
|
-
recountAllFromGroup(workPackage, seriesCallback);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
], (error) => {
|
|
1337
|
-
log.info("deleteUserGroupContent done", { error: error });
|
|
1338
|
-
callback(error);
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
else {
|
|
1342
|
-
callback("No userId or anonymousUserId or groupId");
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
const deleteUserCommunityContent = (workPackage, callback) => {
|
|
1346
|
-
if (workPackage.userId && workPackage.anonymousUserId && workPackage.communityId) {
|
|
1347
|
-
models.Community.findOne({
|
|
1348
|
-
attributes: ['id'],
|
|
1349
|
-
where: {
|
|
1350
|
-
id: workPackage.communityId
|
|
1351
|
-
},
|
|
1352
|
-
include: [
|
|
1353
|
-
{
|
|
1354
|
-
model: models.Group,
|
|
1355
|
-
attributes: ['id']
|
|
1356
|
-
}
|
|
1357
|
-
]
|
|
1358
|
-
}).then((community) => {
|
|
1359
|
-
const groupIds = _.map(community.Groups, (group) => {
|
|
1360
|
-
return group.id;
|
|
1361
|
-
});
|
|
1362
|
-
async.forEachLimit(groupIds, 100, (groupId, forEachCallback) => {
|
|
1363
|
-
deleteUserGroupContent({
|
|
1364
|
-
userId: workPackage.userId,
|
|
1365
|
-
skipRecount: true,
|
|
1366
|
-
anonymousUserId: workPackage.anonymousUserId,
|
|
1367
|
-
groupId: groupId
|
|
1368
|
-
}, forEachCallback);
|
|
1369
|
-
}, (error) => {
|
|
1370
|
-
log.info("User Community Content Deleted", { error: error, context: 'ac-delete', userId: workPackage.userId });
|
|
1371
|
-
callback(error);
|
|
1372
|
-
});
|
|
1373
|
-
}).catch((error) => {
|
|
1374
|
-
if (workPackage.skipRecount) {
|
|
1375
|
-
log.info("Skiping recount for deleteUserCommunityContent");
|
|
1376
|
-
callback(error);
|
|
1377
|
-
}
|
|
1378
|
-
else {
|
|
1379
|
-
recountAllFromGroup(workPackage, callback);
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
else {
|
|
1384
|
-
callback("No userId or anonymousUserId or communityId");
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
const deleteUserDomainContent = (workPackage, callback) => {
|
|
1388
|
-
if (workPackage.userId && workPackage.anonymousUserId && workPackage.domainId) {
|
|
1389
|
-
models.Domain.findOne({
|
|
1390
|
-
attributes: ['id'],
|
|
1391
|
-
where: {
|
|
1392
|
-
id: workPackage.domainId
|
|
1393
|
-
},
|
|
1394
|
-
include: [
|
|
1395
|
-
{
|
|
1396
|
-
model: models.Community,
|
|
1397
|
-
attributes: ['id']
|
|
1398
|
-
}
|
|
1399
|
-
]
|
|
1400
|
-
}).then((domain) => {
|
|
1401
|
-
const communityIds = _.map(domain.Communities, (community) => {
|
|
1402
|
-
return community.id;
|
|
1403
|
-
});
|
|
1404
|
-
async.forEachLimit(communityIds, 100, (communityId, forEachCallback) => {
|
|
1405
|
-
deleteUserCommunityContent({
|
|
1406
|
-
userId: workPackage.userId,
|
|
1407
|
-
skipRecount: true,
|
|
1408
|
-
anonymousUserId: workPackage.anonymousUserId,
|
|
1409
|
-
communityId: communityId
|
|
1410
|
-
}, forEachCallback);
|
|
1411
|
-
}, (error) => {
|
|
1412
|
-
log.info("User Domain Content Deleted", { error: error, context: 'ac-delete', userId: workPackage.userId });
|
|
1413
|
-
if (workPackage.skipRecount) {
|
|
1414
|
-
log.info("Skiping recount for deleteUserDomainContent");
|
|
1415
|
-
callback(error);
|
|
1416
|
-
}
|
|
1417
|
-
else {
|
|
1418
|
-
recountAllFromDomain(workPackage, callback);
|
|
1419
|
-
}
|
|
1420
|
-
});
|
|
1421
|
-
}).catch((error) => {
|
|
1422
|
-
callback(error);
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
else {
|
|
1426
|
-
callback("No userId or anonymousUserId or domainId");
|
|
1427
|
-
}
|
|
1428
|
-
};
|
|
1429
|
-
const removeManyGroupAdmins = (workPackage, callback) => {
|
|
1430
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.groupId) {
|
|
1431
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1432
|
-
getGroupAndUser(workPackage.groupId, userId, null, (error, group, user) => {
|
|
1433
|
-
if (error) {
|
|
1434
|
-
seriesCallback(error);
|
|
1435
|
-
}
|
|
1436
|
-
else if (user && group) {
|
|
1437
|
-
group.removeGroupAdmins(user).then((results) => {
|
|
1438
|
-
log.info('Admin removed', { context: 'remove_admin', groupId: workPackage.groupId, userRemovedId: userId });
|
|
1439
|
-
seriesCallback();
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
else {
|
|
1443
|
-
seriesCallback("User or group not found for removeManyGroupAdmins");
|
|
1444
|
-
}
|
|
1445
|
-
});
|
|
1446
|
-
}, (error) => {
|
|
1447
|
-
callback(error);
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
else {
|
|
1451
|
-
callback("No userIds for removeManyGroupAdmins");
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
const removeManyGroupPromoters = (workPackage, callback) => {
|
|
1455
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.groupId) {
|
|
1456
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1457
|
-
getGroupAndUser(workPackage.groupId, userId, null, (error, group, user) => {
|
|
1458
|
-
if (error) {
|
|
1459
|
-
seriesCallback(error);
|
|
1460
|
-
}
|
|
1461
|
-
else if (user && group) {
|
|
1462
|
-
group.removeGroupPromoters(user).then((results) => {
|
|
1463
|
-
log.info('Promoter removed', { context: 'remove_promoter', groupId: workPackage.groupId, userRemovedId: userId });
|
|
1464
|
-
seriesCallback();
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
else {
|
|
1468
|
-
seriesCallback("User or group not found for removeManyGroupPromoters");
|
|
1469
|
-
}
|
|
1470
|
-
});
|
|
1471
|
-
}, (error) => {
|
|
1472
|
-
callback(error);
|
|
1473
|
-
});
|
|
1474
|
-
}
|
|
1475
|
-
else {
|
|
1476
|
-
callback("No userIds for removeManyGroupPromoters");
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
1479
|
-
const removeManyCommunityAdmins = (workPackage, callback) => {
|
|
1480
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.communityId) {
|
|
1481
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1482
|
-
getCommunityAndUser(workPackage.communityId, userId, null, (error, community, user) => {
|
|
1483
|
-
if (error) {
|
|
1484
|
-
seriesCallback(error);
|
|
1485
|
-
}
|
|
1486
|
-
else if (user && community) {
|
|
1487
|
-
community.removeCommunityAdmins(user).then((results) => {
|
|
1488
|
-
log.info('Admin removed', { context: 'remove_admin', communityId: workPackage.communityId, userRemovedId: userId });
|
|
1489
|
-
seriesCallback();
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
else {
|
|
1493
|
-
seriesCallback("User or community not found for removeManyCommunityAdmins");
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
}, (error) => {
|
|
1497
|
-
callback(error);
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
else {
|
|
1501
|
-
callback("No userIds for removeManyCommunityAdmins");
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
const removeManyCommunityPromoters = (workPackage, callback) => {
|
|
1505
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.communityId) {
|
|
1506
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1507
|
-
getCommunityAndUser(workPackage.communityId, userId, null, (error, community, user) => {
|
|
1508
|
-
if (error) {
|
|
1509
|
-
seriesCallback(error);
|
|
1510
|
-
}
|
|
1511
|
-
else if (user && community) {
|
|
1512
|
-
community.removeCommunityPromoters(user).then((results) => {
|
|
1513
|
-
log.info('Promoter removed', { context: 'remove_promoter', communityId: workPackage.communityId, userRemovedId: userId });
|
|
1514
|
-
seriesCallback();
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
else {
|
|
1518
|
-
seriesCallback("User or community not found for removeManyCommunityPromoters");
|
|
1519
|
-
}
|
|
1520
|
-
});
|
|
1521
|
-
}, (error) => {
|
|
1522
|
-
callback(error);
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
else {
|
|
1526
|
-
callback("No userIds for removeManyCommunityPromoters");
|
|
1527
|
-
}
|
|
1528
|
-
};
|
|
1529
|
-
const removeManyDomainAdmins = (workPackage, callback) => {
|
|
1530
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.domainId) {
|
|
1531
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1532
|
-
getDomainAndUser(workPackage.domainId, userId, null, (error, domain, user) => {
|
|
1533
|
-
if (error) {
|
|
1534
|
-
seriesCallback(error);
|
|
1535
|
-
}
|
|
1536
|
-
else if (user && domain) {
|
|
1537
|
-
domain.removeDomainAdmins(user).then((results) => {
|
|
1538
|
-
log.info('Admin removed', { context: 'remove_admin', domainId: workPackage.domainId, userRemovedId: userId });
|
|
1539
|
-
seriesCallback();
|
|
1540
|
-
});
|
|
1541
|
-
}
|
|
1542
|
-
else {
|
|
1543
|
-
seriesCallback("User or domain not found for removeManyDomainAdmins");
|
|
1544
|
-
}
|
|
1545
|
-
});
|
|
1546
|
-
}, (error) => {
|
|
1547
|
-
callback(error);
|
|
1548
|
-
});
|
|
1549
|
-
}
|
|
1550
|
-
else {
|
|
1551
|
-
callback("No userIds for removeManyDomainAdmins");
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
|
-
const removeManyGroupUsers = (workPackage, callback) => {
|
|
1555
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.groupId) {
|
|
1556
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1557
|
-
getGroupAndUser(workPackage.groupId, userId, null, (error, group, user) => {
|
|
1558
|
-
if (error) {
|
|
1559
|
-
seriesCallback(error);
|
|
1560
|
-
}
|
|
1561
|
-
else if (user && group) {
|
|
1562
|
-
group.removeGroupUsers(user).then((results) => {
|
|
1563
|
-
log.info('User removed', { context: 'remove_user', results: results, groupId: workPackage.groupId, userRemovedId: userId });
|
|
1564
|
-
seriesCallback();
|
|
1565
|
-
});
|
|
1566
|
-
}
|
|
1567
|
-
else {
|
|
1568
|
-
seriesCallback("User or group not found for removeManyGroupUsers");
|
|
1569
|
-
}
|
|
1570
|
-
});
|
|
1571
|
-
}, (error) => {
|
|
1572
|
-
if (error) {
|
|
1573
|
-
callback(error);
|
|
1574
|
-
}
|
|
1575
|
-
else {
|
|
1576
|
-
if (workPackage.skipRecount) {
|
|
1577
|
-
log.info("Skipping recount for group", { workPackage: workPackage });
|
|
1578
|
-
callback();
|
|
1579
|
-
}
|
|
1580
|
-
else {
|
|
1581
|
-
recountAllFromGroup(workPackage, callback);
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
else {
|
|
1587
|
-
callback("No userIds for removeManyGroupUsers");
|
|
1588
|
-
}
|
|
1589
|
-
};
|
|
1590
|
-
const removeManyCommunityUsers = (workPackage, callback) => {
|
|
1591
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.communityId) {
|
|
1592
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1593
|
-
getCommunityAndUser(workPackage.communityId, userId, null, (error, community, user) => {
|
|
1594
|
-
if (error) {
|
|
1595
|
-
seriesCallback(error);
|
|
1596
|
-
}
|
|
1597
|
-
else if (user && community) {
|
|
1598
|
-
community.removeCommunityUsers(user).then((results) => {
|
|
1599
|
-
log.info('User removed', { context: 'remove_user', communityId: workPackage.communityId, userRemovedId: userId });
|
|
1600
|
-
seriesCallback();
|
|
1601
|
-
});
|
|
1602
|
-
}
|
|
1603
|
-
else {
|
|
1604
|
-
seriesCallback("User or community not found for removeManyCommunityUsers");
|
|
1605
|
-
}
|
|
1606
|
-
});
|
|
1607
|
-
}, (error) => {
|
|
1608
|
-
if (error) {
|
|
1609
|
-
callback(error);
|
|
1610
|
-
}
|
|
1611
|
-
else {
|
|
1612
|
-
if (workPackage.skipRecount) {
|
|
1613
|
-
log.info("Skipping recount for community", { workPackage: workPackage });
|
|
1614
|
-
callback();
|
|
1615
|
-
}
|
|
1616
|
-
else {
|
|
1617
|
-
recountAllFromCommunity(workPackage, callback);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
});
|
|
1621
|
-
}
|
|
1622
|
-
else {
|
|
1623
|
-
callback("No userIds for removeManyCommunityUsers");
|
|
1624
|
-
}
|
|
1625
|
-
};
|
|
1626
|
-
const removeManyDomainUsers = (workPackage, callback) => {
|
|
1627
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.domainId) {
|
|
1628
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, seriesCallback) => {
|
|
1629
|
-
getDomainAndUser(workPackage.domainId, userId, null, (error, domain, user) => {
|
|
1630
|
-
if (error) {
|
|
1631
|
-
seriesCallback(error);
|
|
1632
|
-
}
|
|
1633
|
-
else if (user && domain) {
|
|
1634
|
-
domain.removeDomainUsers(user).then((results) => {
|
|
1635
|
-
log.info('User removed', { context: 'remove_user', domainId: workPackage.domainId, userRemovedId: userId });
|
|
1636
|
-
seriesCallback();
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
else {
|
|
1640
|
-
seriesCallback("User or domain not found for removeManyDomainUsers");
|
|
1641
|
-
}
|
|
1642
|
-
});
|
|
1643
|
-
}, (error) => {
|
|
1644
|
-
if (error) {
|
|
1645
|
-
callback(error);
|
|
1646
|
-
}
|
|
1647
|
-
else {
|
|
1648
|
-
if (workPackage.skipRecount) {
|
|
1649
|
-
callback();
|
|
1650
|
-
}
|
|
1651
|
-
else {
|
|
1652
|
-
recountAllFromDomain(workPackage, callback);
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
else {
|
|
1658
|
-
callback("No userIds for removeManyDomainUsers");
|
|
1659
|
-
}
|
|
1660
|
-
};
|
|
1661
|
-
const removeManyGroupUsersAndDeleteContent = (workPackage, callback) => {
|
|
1662
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.groupId) {
|
|
1663
|
-
async.parallel([
|
|
1664
|
-
(parallelCallback) => {
|
|
1665
|
-
removeManyGroupUsers(_.merge(workPackage, { skipRecount: true }), parallelCallback);
|
|
1666
|
-
},
|
|
1667
|
-
(parallelCallback) => {
|
|
1668
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, forEachCallback) => {
|
|
1669
|
-
deleteUserGroupContent({
|
|
1670
|
-
userId: userId,
|
|
1671
|
-
skipRecount: true,
|
|
1672
|
-
groupId: workPackage.groupId,
|
|
1673
|
-
anonymousUserId: workPackage.anonymousUserId
|
|
1674
|
-
}, forEachCallback);
|
|
1675
|
-
}, (error) => {
|
|
1676
|
-
parallelCallback(error);
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
], (error) => {
|
|
1680
|
-
if (error) {
|
|
1681
|
-
callback(error);
|
|
1682
|
-
}
|
|
1683
|
-
else {
|
|
1684
|
-
recountAllFromGroup(workPackage, callback);
|
|
1685
|
-
}
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
else {
|
|
1689
|
-
callback("No userIds for removeManyGroupUsersAndDeleteContent");
|
|
1690
|
-
}
|
|
1691
|
-
};
|
|
1692
|
-
const removeManyCommunityUsersAndDeleteContent = (workPackage, callback) => {
|
|
1693
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.communityId) {
|
|
1694
|
-
async.series([
|
|
1695
|
-
(seriesCallback) => {
|
|
1696
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, forEachCallback) => {
|
|
1697
|
-
deleteUserCommunityContent({
|
|
1698
|
-
userId: userId,
|
|
1699
|
-
skipRecount: true,
|
|
1700
|
-
communityId: workPackage.communityId,
|
|
1701
|
-
anonymousUserId: workPackage.anonymousUserId
|
|
1702
|
-
}, forEachCallback);
|
|
1703
|
-
}, (error) => {
|
|
1704
|
-
seriesCallback(error);
|
|
1705
|
-
});
|
|
1706
|
-
},
|
|
1707
|
-
(seriesCallback) => {
|
|
1708
|
-
removeManyCommunityUsers(_.merge(workPackage, { skipRecount: true }), seriesCallback);
|
|
1709
|
-
},
|
|
1710
|
-
(seriesCallback) => {
|
|
1711
|
-
models.Community.findOne({
|
|
1712
|
-
where: {
|
|
1713
|
-
id: workPackage.communityId
|
|
1714
|
-
},
|
|
1715
|
-
attributes: ['id'],
|
|
1716
|
-
include: [
|
|
1717
|
-
{
|
|
1718
|
-
model: models.Group,
|
|
1719
|
-
attributes: ['id']
|
|
1720
|
-
}
|
|
1721
|
-
]
|
|
1722
|
-
}).then((community) => {
|
|
1723
|
-
async.forEachLimit(community.Groups, 100, (group, forEachCallback) => {
|
|
1724
|
-
removeManyGroupUsers(_.merge(workPackage, { groupId: group.id, skipRecount: true }), forEachCallback);
|
|
1725
|
-
}, (error) => {
|
|
1726
|
-
log.info("Have removed group users for community deletion", { error: error, communityId: workPackage.communityId });
|
|
1727
|
-
seriesCallback(error);
|
|
1728
|
-
});
|
|
1729
|
-
}).catch((error) => {
|
|
1730
|
-
seriesCallback(error);
|
|
1731
|
-
});
|
|
1732
|
-
}
|
|
1733
|
-
], (error) => {
|
|
1734
|
-
if (error) {
|
|
1735
|
-
callback(error);
|
|
1736
|
-
}
|
|
1737
|
-
else {
|
|
1738
|
-
recountAllFromCommunity(workPackage, callback);
|
|
1739
|
-
}
|
|
1740
|
-
});
|
|
1741
|
-
}
|
|
1742
|
-
else {
|
|
1743
|
-
callback("No userIds for removeManyCommunityUsersAndDeleteContent");
|
|
1744
|
-
}
|
|
1745
|
-
};
|
|
1746
|
-
const removeManyDomainUsersAndDeleteContent = (workPackage, callback) => {
|
|
1747
|
-
if (workPackage.userIds && workPackage.userIds.length > 0 && workPackage.domainId) {
|
|
1748
|
-
async.series([
|
|
1749
|
-
(seriesCallback) => {
|
|
1750
|
-
async.forEachLimit(workPackage.userIds, 100, (userId, forEachCallback) => {
|
|
1751
|
-
deleteUserDomainContent({
|
|
1752
|
-
userId: userId,
|
|
1753
|
-
skipRecount: true,
|
|
1754
|
-
domainId: workPackage.domainId,
|
|
1755
|
-
anonymousUserId: workPackage.anonymousUserId
|
|
1756
|
-
}, forEachCallback);
|
|
1757
|
-
}, (error) => {
|
|
1758
|
-
seriesCallback(error);
|
|
1759
|
-
});
|
|
1760
|
-
},
|
|
1761
|
-
(seriesCallback) => {
|
|
1762
|
-
models.Domain.findOne({
|
|
1763
|
-
where: {
|
|
1764
|
-
id: workPackage.domainId
|
|
1765
|
-
},
|
|
1766
|
-
attributes: ['id'],
|
|
1767
|
-
include: [
|
|
1768
|
-
{
|
|
1769
|
-
model: models.Community,
|
|
1770
|
-
attributes: ['id']
|
|
1771
|
-
}
|
|
1772
|
-
]
|
|
1773
|
-
}).then((domain) => {
|
|
1774
|
-
async.forEachLimit(domain.Communities, 100, (community, forEachCallback) => {
|
|
1775
|
-
async.series([
|
|
1776
|
-
(innerSeriesCallback) => {
|
|
1777
|
-
removeManyCommunityUsers(_.merge(workPackage, { communityId: community.id, skipRecount: true }), innerSeriesCallback);
|
|
1778
|
-
},
|
|
1779
|
-
(innerSeriesCallback) => {
|
|
1780
|
-
models.Community.findOne({
|
|
1781
|
-
where: {
|
|
1782
|
-
id: community.id
|
|
1783
|
-
},
|
|
1784
|
-
attributes: ['id'],
|
|
1785
|
-
include: [
|
|
1786
|
-
{
|
|
1787
|
-
model: models.Group,
|
|
1788
|
-
attributes: ['id']
|
|
1789
|
-
}
|
|
1790
|
-
]
|
|
1791
|
-
}).then((community) => {
|
|
1792
|
-
async.forEachLimit(community.Groups, 100, (group, innerForEachCallback) => {
|
|
1793
|
-
removeManyGroupUsers(_.merge(workPackage, { groupId: group.id, skipRecount: true }), innerForEachCallback);
|
|
1794
|
-
}, (error) => {
|
|
1795
|
-
log.info("Have removed group users for domain deletion", { error: error, domainId: workPackage.domainId });
|
|
1796
|
-
innerSeriesCallback(error);
|
|
1797
|
-
});
|
|
1798
|
-
}).catch((error) => {
|
|
1799
|
-
innerSeriesCallback(error);
|
|
1800
|
-
});
|
|
1801
|
-
},
|
|
1802
|
-
], (error) => {
|
|
1803
|
-
forEachCallback(error);
|
|
1804
|
-
});
|
|
1805
|
-
}, (error) => {
|
|
1806
|
-
seriesCallback(error);
|
|
1807
|
-
});
|
|
1808
|
-
}).catch((error) => {
|
|
1809
|
-
seriesCallback(error);
|
|
1810
|
-
});
|
|
1811
|
-
},
|
|
1812
|
-
(seriesCallback) => {
|
|
1813
|
-
removeManyDomainUsers(_.merge(workPackage, { skipRecount: true }), seriesCallback);
|
|
1814
|
-
}
|
|
1815
|
-
], (error) => {
|
|
1816
|
-
if (error) {
|
|
1817
|
-
callback(error);
|
|
1818
|
-
}
|
|
1819
|
-
else {
|
|
1820
|
-
recountAllFromDomain(workPackage, callback);
|
|
1821
|
-
}
|
|
1822
|
-
});
|
|
1823
|
-
}
|
|
1824
|
-
else {
|
|
1825
|
-
callback("No userIds for removeManyDomainUsersAndDeleteContent");
|
|
1826
|
-
}
|
|
1827
|
-
};
|
|
1828
|
-
DeletionWorker.prototype.process = (workPackage, callback) => {
|
|
1829
|
-
getAnonymousUser((error, anonymousUser) => {
|
|
1830
|
-
if (error) {
|
|
1831
|
-
callback(error);
|
|
1832
|
-
}
|
|
1833
|
-
else {
|
|
1834
|
-
workPackage = _.merge({ anonymousUserId: anonymousUser.id }, workPackage);
|
|
1835
|
-
switch (workPackage.type) {
|
|
1836
|
-
case 'delete-point-content':
|
|
1837
|
-
deletePointContent(workPackage, callback);
|
|
1838
|
-
break;
|
|
1839
|
-
case 'delete-point-activities':
|
|
1840
|
-
deletePointActivities(workPackage, callback);
|
|
1841
|
-
break;
|
|
1842
|
-
case 'delete-post-content':
|
|
1843
|
-
deletePostContent(workPackage, callback);
|
|
1844
|
-
break;
|
|
1845
|
-
case 'delete-post-activities':
|
|
1846
|
-
deletePostActivities(workPackage, callback);
|
|
1847
|
-
break;
|
|
1848
|
-
case 'delete-group-content':
|
|
1849
|
-
deleteGroupContent(workPackage, callback);
|
|
1850
|
-
break;
|
|
1851
|
-
case 'delete-community-content':
|
|
1852
|
-
deleteCommunityContent(workPackage, callback);
|
|
1853
|
-
break;
|
|
1854
|
-
case 'delete-user-content':
|
|
1855
|
-
deleteUserContent(workPackage, callback);
|
|
1856
|
-
break;
|
|
1857
|
-
case 'delete-group-user-content':
|
|
1858
|
-
deleteUserGroupContent(workPackage, callback);
|
|
1859
|
-
break;
|
|
1860
|
-
case 'delete-community-user-content':
|
|
1861
|
-
deleteUserCommunityContent(workPackage, callback);
|
|
1862
|
-
break;
|
|
1863
|
-
case 'delete-domain-user-content':
|
|
1864
|
-
deleteUserDomainContent(workPackage, callback);
|
|
1865
|
-
break;
|
|
1866
|
-
case 'delete-user-endorsements':
|
|
1867
|
-
deleteUserEndorsements(workPackage, callback);
|
|
1868
|
-
break;
|
|
1869
|
-
case 'move-user-endorsements':
|
|
1870
|
-
moveUserEndorsements(workPackage, callback);
|
|
1871
|
-
break;
|
|
1872
|
-
case 'remove-many-group-admins':
|
|
1873
|
-
removeManyGroupAdmins(workPackage, callback);
|
|
1874
|
-
break;
|
|
1875
|
-
case 'remove-many-group-promoters':
|
|
1876
|
-
removeManyGroupPromoters(workPackage, callback);
|
|
1877
|
-
break;
|
|
1878
|
-
case 'remove-many-group-users':
|
|
1879
|
-
removeManyGroupUsers(workPackage, callback);
|
|
1880
|
-
break;
|
|
1881
|
-
case 'remove-many-group-users-and-delete-content':
|
|
1882
|
-
removeManyGroupUsersAndDeleteContent(workPackage, callback);
|
|
1883
|
-
break;
|
|
1884
|
-
case 'remove-many-community-admins':
|
|
1885
|
-
removeManyCommunityAdmins(workPackage, callback);
|
|
1886
|
-
break;
|
|
1887
|
-
case 'remove-many-community-promoters':
|
|
1888
|
-
removeManyCommunityPromoters(workPackage, callback);
|
|
1889
|
-
break;
|
|
1890
|
-
case 'remove-many-community-users':
|
|
1891
|
-
removeManyCommunityUsers(workPackage, callback);
|
|
1892
|
-
break;
|
|
1893
|
-
case 'remove-many-community-users-and-delete-content':
|
|
1894
|
-
removeManyCommunityUsersAndDeleteContent(workPackage, callback);
|
|
1895
|
-
break;
|
|
1896
|
-
case 'remove-many-domain-admins':
|
|
1897
|
-
removeManyDomainAdmins(workPackage, callback);
|
|
1898
|
-
break;
|
|
1899
|
-
case 'remove-many-domain-users':
|
|
1900
|
-
removeManyDomainUsers(workPackage, callback);
|
|
1901
|
-
break;
|
|
1902
|
-
case 'remove-many-domain-users-and-delete-content':
|
|
1903
|
-
removeManyDomainUsersAndDeleteContent(workPackage, callback);
|
|
1904
|
-
break;
|
|
1905
|
-
default:
|
|
1906
|
-
callback("Unknown type for workPackage: " + workPackage.type);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
});
|
|
1910
|
-
};
|
|
1911
|
-
module.exports = new DeletionWorker();
|