@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,368 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://gist.github.com/mojodna/1251812
|
|
3
|
-
var async = require("async");
|
|
4
|
-
var models = require("../../models/index.cjs");
|
|
5
|
-
var log = require('../utils/logger.cjs');
|
|
6
|
-
var queue = require('./queue.cjs');
|
|
7
|
-
var i18n = require('../utils/i18n.cjs');
|
|
8
|
-
var toJson = require('../utils/to_json.cjs');
|
|
9
|
-
var deliverPostNotification = require('../engine/notifications/post_delivery.cjs');
|
|
10
|
-
var deliverPointNotification = require('../engine/notifications/point_delivery.cjs');
|
|
11
|
-
const processGeneralNotification = require('../engine/notifications/process_general_notifications.cjs');
|
|
12
|
-
var airbrake = null;
|
|
13
|
-
if (process.env.AIRBRAKE_PROJECT_ID) {
|
|
14
|
-
airbrake = require('../utils/airbrake.cjs');
|
|
15
|
-
}
|
|
16
|
-
var NotificationDeliveryWorker = function () { };
|
|
17
|
-
NotificationDeliveryWorker.prototype.process = function (notificationJson, callback) {
|
|
18
|
-
var user;
|
|
19
|
-
var notification;
|
|
20
|
-
var domain;
|
|
21
|
-
var community;
|
|
22
|
-
var group;
|
|
23
|
-
async.series([
|
|
24
|
-
function (seriesCallback) {
|
|
25
|
-
models.AcNotification.findOne({
|
|
26
|
-
where: { id: notificationJson.id },
|
|
27
|
-
include: [
|
|
28
|
-
{
|
|
29
|
-
model: models.User,
|
|
30
|
-
attributes: ['id', 'notifications_settings', 'email', 'name', 'created_at'],
|
|
31
|
-
required: false
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
model: models.AcActivity,
|
|
35
|
-
as: 'AcActivities',
|
|
36
|
-
required: true,
|
|
37
|
-
include: [
|
|
38
|
-
{
|
|
39
|
-
model: models.Domain,
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
model: models.Community,
|
|
44
|
-
required: false
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
model: models.Group,
|
|
48
|
-
required: false,
|
|
49
|
-
include: [
|
|
50
|
-
{
|
|
51
|
-
model: models.Community,
|
|
52
|
-
required: false,
|
|
53
|
-
include: [
|
|
54
|
-
{
|
|
55
|
-
model: models.Domain,
|
|
56
|
-
required: false
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
model: models.Post.unscoped(),
|
|
64
|
-
required: false
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
model: models.PostStatusChange,
|
|
68
|
-
required: false
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
model: models.Point.unscoped(),
|
|
72
|
-
required: false,
|
|
73
|
-
include: [
|
|
74
|
-
{
|
|
75
|
-
model: models.Community,
|
|
76
|
-
required: false,
|
|
77
|
-
attributes: ['id', 'name']
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
model: models.Group,
|
|
81
|
-
required: false,
|
|
82
|
-
attributes: ['id', 'name']
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
model: models.User,
|
|
86
|
-
required: false,
|
|
87
|
-
attributes: ['id', 'name']
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}).then(function (results) {
|
|
95
|
-
if (results) {
|
|
96
|
-
notification = results;
|
|
97
|
-
group = notification.AcActivities[0].Group;
|
|
98
|
-
if (notification.AcActivities[0].Domain) {
|
|
99
|
-
domain = notification.AcActivities[0].Domain;
|
|
100
|
-
}
|
|
101
|
-
else if (notification.AcActivities[0].Group &&
|
|
102
|
-
notification.AcActivities[0].Group.Community &&
|
|
103
|
-
notification.AcActivities[0].Group.Community.Domain) {
|
|
104
|
-
domain = notification.AcActivities[0].Group.Community.Domain;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
log.error("Couldn't find domain for NotificationDeliveryWorker");
|
|
108
|
-
}
|
|
109
|
-
if (notification.AcActivities[0].Community) {
|
|
110
|
-
community = notification.AcActivities[0].Community;
|
|
111
|
-
}
|
|
112
|
-
else if (notification.AcActivities[0].Group &&
|
|
113
|
-
notification.AcActivities[0].Group.Community) {
|
|
114
|
-
community = notification.AcActivities[0].Group.Community;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
log.error("Couldn't find community for NotificationDeliveryWorker");
|
|
118
|
-
}
|
|
119
|
-
seriesCallback();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
seriesCallback('NotificationDeliveryWorker Notification not found');
|
|
123
|
-
}
|
|
124
|
-
}).catch(function (error) {
|
|
125
|
-
seriesCallback(error);
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
function (seriesCallback) {
|
|
129
|
-
if (notification.user_id) {
|
|
130
|
-
models.User.findOne({
|
|
131
|
-
where: { id: notification.user_id },
|
|
132
|
-
attributes: ['id', 'notifications_settings', 'email', 'name', 'created_at']
|
|
133
|
-
}).then(function (userResults) {
|
|
134
|
-
if (userResults) {
|
|
135
|
-
user = userResults;
|
|
136
|
-
seriesCallback();
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
if (notification.AcActivities[0].object.email) {
|
|
140
|
-
seriesCallback();
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
seriesCallback('User not found');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}).catch(function (error) {
|
|
147
|
-
seriesCallback(error);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
seriesCallback();
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
function (seriesCallback) {
|
|
155
|
-
if (user) {
|
|
156
|
-
user.setLocale(i18n, domain, community, function () {
|
|
157
|
-
seriesCallback();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
seriesCallback();
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
function (seriesCallback) {
|
|
165
|
-
log.info('Processing NotificationDeliveryWorker Started', { type: notification.type, userId: user ? user.id : null });
|
|
166
|
-
switch (notification.type) {
|
|
167
|
-
case "notification.user.invite":
|
|
168
|
-
var inviteFromName;
|
|
169
|
-
if (notification.AcActivities[0].group_id) {
|
|
170
|
-
inviteFromName = notification.AcActivities[0].Group.name;
|
|
171
|
-
}
|
|
172
|
-
else if (notification.AcActivities[0].community_id) {
|
|
173
|
-
inviteFromName = notification.AcActivities[0].Community.name;
|
|
174
|
-
}
|
|
175
|
-
if (process.env.DEFAULT_HOSTNAME) {
|
|
176
|
-
community.hostname = process.env.DEFAULT_HOSTNAME;
|
|
177
|
-
}
|
|
178
|
-
queue.add('send-one-email', {
|
|
179
|
-
subject: { translateToken: 'notification.email.user_invite', contentName: inviteFromName },
|
|
180
|
-
template: 'user_invite',
|
|
181
|
-
user: user ? user : { id: null, email: notification.AcActivities[0].object.email, name: notification.AcActivities[0].object.email },
|
|
182
|
-
sender_name: notification.AcActivities[0].object.sender_name,
|
|
183
|
-
invite_link: notification.AcActivities[0].object.invite_link,
|
|
184
|
-
domain: domain,
|
|
185
|
-
community: community,
|
|
186
|
-
group: group,
|
|
187
|
-
token: notification.AcActivities[0].object.token
|
|
188
|
-
}, 'critical');
|
|
189
|
-
log.info('NotificationDeliveryWorker notification.user.invite Queued', { type: notification.type, userId: user ? user.id : null });
|
|
190
|
-
seriesCallback();
|
|
191
|
-
break;
|
|
192
|
-
case "notification.password.recovery":
|
|
193
|
-
queue.add('send-one-email', {
|
|
194
|
-
subject: { translateToken: 'notification.email.password_recovery' },
|
|
195
|
-
template: 'password_recovery',
|
|
196
|
-
user: user,
|
|
197
|
-
domain: domain,
|
|
198
|
-
community: community,
|
|
199
|
-
token: notification.AcActivities[0].object.token
|
|
200
|
-
}, 'now');
|
|
201
|
-
log.info('NotificationDeliveryWorker notification.password.recovery Completed', { type: notification.type, userId: user ? user.id : null });
|
|
202
|
-
seriesCallback();
|
|
203
|
-
break;
|
|
204
|
-
case "notification.report.content":
|
|
205
|
-
var template, translateToken, moderation, source, toxicity;
|
|
206
|
-
if (notification.AcActivities[0].Point) {
|
|
207
|
-
template = 'point_activity';
|
|
208
|
-
translateToken = 'notification.email.pointReport';
|
|
209
|
-
const point = notification.AcActivities[0].Point;
|
|
210
|
-
if (point.data && point.data.moderation) {
|
|
211
|
-
moderation = point.data.moderation;
|
|
212
|
-
if (moderation.lastReportedBy && moderation.lastReportedBy.length > 0) {
|
|
213
|
-
source = moderation.lastReportedBy[moderation.lastReportedBy.length - 1].source;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
template = 'post_activity';
|
|
219
|
-
translateToken = 'notification.email.postReport';
|
|
220
|
-
const post = notification.AcActivities[0].Post;
|
|
221
|
-
if (post && post.data && post.data.moderation) {
|
|
222
|
-
moderation = post.data.moderation;
|
|
223
|
-
if (moderation.lastReportedBy && moderation.lastReportedBy.length > 0) {
|
|
224
|
-
source = moderation.lastReportedBy[moderation.lastReportedBy.length - 1].source;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (moderation && moderation.toxicityScore) {
|
|
229
|
-
moderation.toxicityScorePercent = Math.round(moderation.toxicityScore * 100) + '%';
|
|
230
|
-
}
|
|
231
|
-
queue.add('send-one-email', {
|
|
232
|
-
subject: { translateToken: translateToken },
|
|
233
|
-
template: template,
|
|
234
|
-
user: user,
|
|
235
|
-
domain: domain,
|
|
236
|
-
moderation: moderation,
|
|
237
|
-
source: source,
|
|
238
|
-
isAutomated: source && (source !== 'user' && source !== 'fromUser'),
|
|
239
|
-
isAutomatedVision: source && (source === 'visionAPI'),
|
|
240
|
-
isReportingContent: true,
|
|
241
|
-
community: community,
|
|
242
|
-
post: notification.AcActivities[0].Post ? notification.AcActivities[0].Post.toJSON() : null,
|
|
243
|
-
point: notification.AcActivities[0].Point ? notification.AcActivities[0].Point.toJSON() : null,
|
|
244
|
-
activity: notification.AcActivities[0].toJSON()
|
|
245
|
-
}, 'critical');
|
|
246
|
-
log.info('NotificationDeliveryWorker notification.report.content Completed', { type: notification.type, userId: user ? user.id : null });
|
|
247
|
-
seriesCallback();
|
|
248
|
-
break;
|
|
249
|
-
case "notification.password.changed":
|
|
250
|
-
if (notification.activity && notification.activity.object && notification.activity.object.token) {
|
|
251
|
-
queue.add('send-one-email', {
|
|
252
|
-
subject: { translateToken: 'email.password_changed' },
|
|
253
|
-
template: 'password_changed',
|
|
254
|
-
user: user,
|
|
255
|
-
domain: domain,
|
|
256
|
-
community: community,
|
|
257
|
-
token: notification.activity.object.token
|
|
258
|
-
}, 'critical');
|
|
259
|
-
log.info('NotificationDeliveryWorker notification.password.changed Completed', { type: notification.type, userId: user ? user.id : null });
|
|
260
|
-
seriesCallback();
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
log.error('NotificationDeliveryWorker notification.password.changed cant find token!', { type: notification.type, userId: user ? user.id : null });
|
|
264
|
-
seriesCallback();
|
|
265
|
-
}
|
|
266
|
-
break;
|
|
267
|
-
case "notification.post.status.change":
|
|
268
|
-
if (notification.AcActivities[0].object && notification.AcActivities[0].object.bulkStatusUpdate) {
|
|
269
|
-
log.info('Processing notification.status.change Not Sent Due To Bulk Status Update', { type: notification.type, userId: user ? user.id : null });
|
|
270
|
-
seriesCallback();
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
var post = notification.AcActivities[0].Post;
|
|
274
|
-
var content = notification.AcActivities[0].PostStatusChange.content;
|
|
275
|
-
queue.add('send-one-email', {
|
|
276
|
-
subject: { translateToken: 'notification.post.statusChangeSubject', contentName: post.name },
|
|
277
|
-
template: 'post_status_change',
|
|
278
|
-
user: user,
|
|
279
|
-
domain: domain,
|
|
280
|
-
community: community,
|
|
281
|
-
post: post,
|
|
282
|
-
content: content ? content : "",
|
|
283
|
-
status_changed_to: notification.AcActivities[0].PostStatusChange.status_changed_to
|
|
284
|
-
}, 'high');
|
|
285
|
-
log.info('Processing notification.status.change Completed', { type: notification.type, userId: user ? user.id : null });
|
|
286
|
-
seriesCallback();
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
case "notification.bulk.status.update":
|
|
290
|
-
var bulkStatusUpdateId = notification.AcActivities[0].object.bulkStatusUpdateId;
|
|
291
|
-
var groupUpdate = notification.AcActivities[0].object.groupUpdate;
|
|
292
|
-
models.BulkStatusUpdate.findOne({
|
|
293
|
-
where: {
|
|
294
|
-
id: bulkStatusUpdateId
|
|
295
|
-
}
|
|
296
|
-
}).then(function (statusUpdate) {
|
|
297
|
-
if (statusUpdate) {
|
|
298
|
-
queue.add('send-one-email', {
|
|
299
|
-
subject: { translateToken: 'notification.bulkStatusUpdate', contentName: groupUpdate ? group.name : community.name },
|
|
300
|
-
template: 'bulk_status_update',
|
|
301
|
-
user: user,
|
|
302
|
-
domain: domain,
|
|
303
|
-
community: community,
|
|
304
|
-
post: post,
|
|
305
|
-
bulkStatusUpdateId: bulkStatusUpdateId,
|
|
306
|
-
emailHeader: statusUpdate.config.emailHeader,
|
|
307
|
-
emailFooter: statusUpdate.config.emailFooter
|
|
308
|
-
}, 'high');
|
|
309
|
-
log.info('Processing notification.bulk.status.change Completed', { type: notification.type, userId: user ? user.id : null });
|
|
310
|
-
seriesCallback();
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
seriesCallback("Can't find bulk status update");
|
|
314
|
-
}
|
|
315
|
-
}).catch(function (error) {
|
|
316
|
-
seriesCallback(error);
|
|
317
|
-
});
|
|
318
|
-
break;
|
|
319
|
-
case "notification.post.new":
|
|
320
|
-
case "notification.post.endorsement":
|
|
321
|
-
deliverPostNotification(notification, user, function (error) {
|
|
322
|
-
log.info('Processing notification.post.* Completed', { type: notification.type, userId: user ? user.id : null });
|
|
323
|
-
seriesCallback(error);
|
|
324
|
-
});
|
|
325
|
-
break;
|
|
326
|
-
case "notification.point.new":
|
|
327
|
-
case "notification.point.quality":
|
|
328
|
-
case "notification.point.newsStory":
|
|
329
|
-
case "notification.point.comment":
|
|
330
|
-
deliverPointNotification(notification, user, function (error) {
|
|
331
|
-
log.info('Processing notification.point.* Completed', { type: notification.type, userId: user ? user.id : null });
|
|
332
|
-
seriesCallback(error);
|
|
333
|
-
});
|
|
334
|
-
break;
|
|
335
|
-
case "notification.generalUserNotification":
|
|
336
|
-
processGeneralNotification(notification, domain, community, group, user, (error) => {
|
|
337
|
-
log.info('Processing notification.generalUserNotification Completed', { type: notification.type, userId: user ? user.id : null });
|
|
338
|
-
seriesCallback(error);
|
|
339
|
-
});
|
|
340
|
-
break;
|
|
341
|
-
default:
|
|
342
|
-
seriesCallback();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
], (error) => {
|
|
346
|
-
if (error) {
|
|
347
|
-
if (error.stack)
|
|
348
|
-
log.error("NotificationDeliveryWorker Error", { err: error, stack: error.stack.split("\n") });
|
|
349
|
-
else
|
|
350
|
-
log.error("NotificationDeliveryWorker Error", { err: error });
|
|
351
|
-
if (airbrake) {
|
|
352
|
-
airbrake.notify(error).then((airbrakeErr) => {
|
|
353
|
-
if (airbrakeErr.error) {
|
|
354
|
-
log.error("AirBrake Error", { context: 'airbrake', err: airbrakeErr.error });
|
|
355
|
-
}
|
|
356
|
-
callback(error);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
callback(error);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
callback();
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
module.exports = new NotificationDeliveryWorker();
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://gist.github.com/mojodna/1251812
|
|
3
|
-
var async = require("async");
|
|
4
|
-
var models = require("../../models/index.cjs");
|
|
5
|
-
var log = require('../utils/logger.cjs');
|
|
6
|
-
var queue = require('./queue.cjs');
|
|
7
|
-
var i18n = require('../utils/i18n.cjs');
|
|
8
|
-
var toJson = require('../utils/to_json.cjs');
|
|
9
|
-
var airbrake = null;
|
|
10
|
-
if (process.env.AIRBRAKE_PROJECT_ID) {
|
|
11
|
-
airbrake = require('../utils/airbrake.cjs');
|
|
12
|
-
}
|
|
13
|
-
var GenerateNewsFeedFromNotifications = require('../engine/news_feeds/generate_from_notifications.cjs');
|
|
14
|
-
var NotificationNewsFeedWorker = function () { };
|
|
15
|
-
NotificationNewsFeedWorker.prototype.process = function (notificationJson, callback) {
|
|
16
|
-
var user;
|
|
17
|
-
var notification;
|
|
18
|
-
var domain;
|
|
19
|
-
var community;
|
|
20
|
-
async.series([
|
|
21
|
-
function (seriesCallback) {
|
|
22
|
-
models.AcNotification.findOne({
|
|
23
|
-
where: { id: notificationJson.id },
|
|
24
|
-
order: [
|
|
25
|
-
[{ model: models.AcActivity, as: 'AcActivities' }, 'updated_at', 'asc']
|
|
26
|
-
],
|
|
27
|
-
include: [
|
|
28
|
-
{
|
|
29
|
-
model: models.User,
|
|
30
|
-
attributes: ['id', 'notifications_settings', 'email', 'name', 'created_at'],
|
|
31
|
-
required: false
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
model: models.AcActivity,
|
|
35
|
-
as: 'AcActivities',
|
|
36
|
-
required: true,
|
|
37
|
-
include: [
|
|
38
|
-
{
|
|
39
|
-
model: models.User,
|
|
40
|
-
attributes: ['id', 'notifications_settings', 'email', 'name', 'created_at'],
|
|
41
|
-
required: false
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
model: models.Domain,
|
|
45
|
-
required: false
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
model: models.Community,
|
|
49
|
-
required: false
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
model: models.Group,
|
|
53
|
-
required: false
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
model: models.Post,
|
|
57
|
-
required: false
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
model: models.Point,
|
|
61
|
-
required: false
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
}).then(function (results) {
|
|
67
|
-
if (results) {
|
|
68
|
-
notification = results;
|
|
69
|
-
domain = notification.AcActivities[0].Domain;
|
|
70
|
-
community = notification.AcActivities[0].Community;
|
|
71
|
-
seriesCallback();
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
seriesCallback('Notification not found');
|
|
75
|
-
}
|
|
76
|
-
}).catch(function (error) {
|
|
77
|
-
seriesCallback(error);
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
function (seriesCallback) {
|
|
81
|
-
models.User.findOne({
|
|
82
|
-
where: { id: notification.user_id },
|
|
83
|
-
attributes: ['id', 'notifications_settings', 'email', 'name', 'created_at']
|
|
84
|
-
}).then(function (userResults) {
|
|
85
|
-
if (userResults) {
|
|
86
|
-
user = userResults;
|
|
87
|
-
seriesCallback();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
seriesCallback();
|
|
91
|
-
}
|
|
92
|
-
}).catch(function (error) {
|
|
93
|
-
seriesCallback(error);
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
function (seriesCallback) {
|
|
97
|
-
if (user) {
|
|
98
|
-
user.setLocale(i18n, domain, community, function () {
|
|
99
|
-
seriesCallback();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
seriesCallback();
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
function (seriesCallback) {
|
|
107
|
-
log.info('Processing NotificationNewsFeedWorker Started', { type: notification.type, user: user ? user.simple() : null });
|
|
108
|
-
switch (notification.type) {
|
|
109
|
-
case "notification.post.new":
|
|
110
|
-
case "notification.post.endorsement":
|
|
111
|
-
case "notification.point.new":
|
|
112
|
-
case "notification.point.quality":
|
|
113
|
-
GenerateNewsFeedFromNotifications(notification, user, function (error) {
|
|
114
|
-
log.info('Processing GenerateNewsFeedFromNotifications Completed', { type: notification.type, user: user.simple() });
|
|
115
|
-
seriesCallback(error);
|
|
116
|
-
});
|
|
117
|
-
break;
|
|
118
|
-
default:
|
|
119
|
-
seriesCallback();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
], function (error) {
|
|
123
|
-
if (error) {
|
|
124
|
-
log.error("NotificationNewsFeedWorker Error", { err: error });
|
|
125
|
-
if (airbrake) {
|
|
126
|
-
airbrake.notify(error).then((airbrakeErr) => {
|
|
127
|
-
if (airbrakeErr.error) {
|
|
128
|
-
log.error("AirBrake Error", { context: 'airbrake', err: airbrakeErr.error });
|
|
129
|
-
}
|
|
130
|
-
callback(error);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
callback(error);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
callback();
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
module.exports = new NotificationNewsFeedWorker();
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const log = require('../utils/logger.cjs');
|
|
3
|
-
const url = require('url');
|
|
4
|
-
var airbrake = null;
|
|
5
|
-
if (process.env.AIRBRAKE_PROJECT_ID) {
|
|
6
|
-
airbrake = require('../utils/airbrake.cjs');
|
|
7
|
-
}
|
|
8
|
-
const BullQueue = require('bull');
|
|
9
|
-
let redisUrl = process.env.REDIS_URL ? process.env.REDIS_URL : "redis://localhost:6379";
|
|
10
|
-
if (redisUrl.startsWith("redis://h:")) {
|
|
11
|
-
redisUrl = redisUrl.replace("redis://h:", "redis://:");
|
|
12
|
-
}
|
|
13
|
-
const EventEmitter = require('events');
|
|
14
|
-
EventEmitter.defaultMaxListeners = 100;
|
|
15
|
-
const redissOptions = {
|
|
16
|
-
tls: {
|
|
17
|
-
rejectUnauthorized: false,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
log.info("Starting app access to Bull Queue", { redis_url: redisUrl });
|
|
21
|
-
class YpQueue {
|
|
22
|
-
constructor() {
|
|
23
|
-
console.log("Create YpQueue");
|
|
24
|
-
this.createQueues();
|
|
25
|
-
}
|
|
26
|
-
get defaultQueueOptions() {
|
|
27
|
-
return {
|
|
28
|
-
redis: redisUrl.includes("rediss://") ? redissOptions : undefined,
|
|
29
|
-
defaultJobOptions: {
|
|
30
|
-
attempts: 1,
|
|
31
|
-
removeOnComplete: true,
|
|
32
|
-
removeOnFail: true
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
process(name, concurrency, processor) {
|
|
37
|
-
this.mainQueue.process(name, concurrency, processor);
|
|
38
|
-
}
|
|
39
|
-
add(name, workPackage, priority, options) {
|
|
40
|
-
const jobOptions = options || {};
|
|
41
|
-
let priorityNumber = 1000;
|
|
42
|
-
switch (priority) {
|
|
43
|
-
case 'now':
|
|
44
|
-
priorityNumber = 1;
|
|
45
|
-
break;
|
|
46
|
-
case 'critical':
|
|
47
|
-
priorityNumber = 5;
|
|
48
|
-
break;
|
|
49
|
-
case 'high':
|
|
50
|
-
priorityNumber = 100;
|
|
51
|
-
break;
|
|
52
|
-
case 'medium':
|
|
53
|
-
priorityNumber = 1000;
|
|
54
|
-
break;
|
|
55
|
-
case 'low':
|
|
56
|
-
priorityNumber = 10000;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
jobOptions.priority = priorityNumber;
|
|
60
|
-
this.mainQueue.add(name, workPackage, jobOptions);
|
|
61
|
-
}
|
|
62
|
-
createQueues() {
|
|
63
|
-
this.mainQueue = new BullQueue('mainYpQueue', redisUrl, this.defaultQueueOptions);
|
|
64
|
-
this.mainQueue.on('active', function (job) {
|
|
65
|
-
log.info('JQ', { id: job.id, name: job.name });
|
|
66
|
-
}).on('completed', function (job, result) {
|
|
67
|
-
log.info('JC', { id: job.id, name: job.name });
|
|
68
|
-
}).on('failed', function (job, error) {
|
|
69
|
-
log.error('Job Failed', { id: job ? job.id : null, name: job ? job.name : null, data: job ? job.data : null, error });
|
|
70
|
-
}).on('resumed', function (job) {
|
|
71
|
-
log.info('Job Removed', { id: job.id });
|
|
72
|
-
}).on('waiting', function (jobId) {
|
|
73
|
-
log.info('Job Waiting', { id: jobId });
|
|
74
|
-
}).on('stalled', function (job) {
|
|
75
|
-
log.info('Job Stalled', { id: job.id, name: job.name, data: job.data, });
|
|
76
|
-
}).on('progress', function (job, process) {
|
|
77
|
-
log.info('Job Progress', { id: job.id, process });
|
|
78
|
-
}).on('paused', function () {
|
|
79
|
-
log.info('Queue Paused');
|
|
80
|
-
}).on('cleaned', function (jobs, type) {
|
|
81
|
-
log.info('Job Cleaned', { jobs, type });
|
|
82
|
-
}).on('drained', function () {
|
|
83
|
-
log.info('Queue Drained');
|
|
84
|
-
}).on('error', function (error) {
|
|
85
|
-
log.error('Job Error', { error });
|
|
86
|
-
if (airbrake) {
|
|
87
|
-
if (!(error instanceof Error)) {
|
|
88
|
-
error = new Error(error);
|
|
89
|
-
}
|
|
90
|
-
airbrake.notify(error).then((airbrakeErr) => {
|
|
91
|
-
if (airbrakeErr.error) {
|
|
92
|
-
log.error("AirBrake Error", { context: 'airbrake', err: airbrakeErr.error, errorStatus: 500 });
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
module.exports = new YpQueue();
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const models = require("../../models/index.cjs");
|
|
3
|
-
const log = require('../utils/logger.cjs');
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
const recountGroupFolder = async (workPackage, callback) => {
|
|
6
|
-
try {
|
|
7
|
-
log.info(`recountGroupFolder ${workPackage.groupId}`);
|
|
8
|
-
let stackSize = 0;
|
|
9
|
-
const maxStackSize = 100;
|
|
10
|
-
let haveCompletedSearch = false;
|
|
11
|
-
const groupdIdsToCount = [];
|
|
12
|
-
let nextGroupIdToSearch = workPackage.groupId;
|
|
13
|
-
while (!haveCompletedSearch || stackSize < maxStackSize) {
|
|
14
|
-
stackSize++;
|
|
15
|
-
const group = await models.Group.findOne({
|
|
16
|
-
where: {
|
|
17
|
-
id: nextGroupIdToSearch,
|
|
18
|
-
},
|
|
19
|
-
attributes: ['in_group_folder_id']
|
|
20
|
-
});
|
|
21
|
-
if (group && group.in_group_folder_id) {
|
|
22
|
-
groupdIdsToCount.push(group.in_group_folder_id);
|
|
23
|
-
nextGroupIdToSearch = group.in_group_folder_id;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
haveCompletedSearch = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (let i = 0; i < groupdIdsToCount.length; i++) {
|
|
30
|
-
const groupId = groupdIdsToCount[i];
|
|
31
|
-
const groupToCount = await models.Group.findOne({
|
|
32
|
-
where: {
|
|
33
|
-
id: groupId,
|
|
34
|
-
},
|
|
35
|
-
attributes: ['id', 'in_group_folder_id'],
|
|
36
|
-
});
|
|
37
|
-
const subGroupsToCount = await models.Group.findAll({
|
|
38
|
-
where: {
|
|
39
|
-
in_group_folder_id: groupId,
|
|
40
|
-
},
|
|
41
|
-
attributes: ['id', 'in_group_folder_id', 'counter_points', 'counter_posts', 'counter_users'],
|
|
42
|
-
include: [
|
|
43
|
-
{
|
|
44
|
-
model: models.User,
|
|
45
|
-
as: 'GroupUsers',
|
|
46
|
-
attributes: ['id']
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
});
|
|
50
|
-
let counter_posts = 0;
|
|
51
|
-
let counter_points = 0;
|
|
52
|
-
let allUsers = [];
|
|
53
|
-
for (let j = 0; j < subGroupsToCount.length; j++) {
|
|
54
|
-
counter_posts += subGroupsToCount[j].counter_posts;
|
|
55
|
-
counter_points += subGroupsToCount[j].counter_points;
|
|
56
|
-
if (subGroupsToCount[j].GroupUsers) {
|
|
57
|
-
allUsers = _.union(allUsers, subGroupsToCount[j].GroupUsers.map(user => user.id));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
await groupToCount.reload();
|
|
61
|
-
groupToCount.counter_points = counter_points;
|
|
62
|
-
groupToCount.counter_posts = counter_posts;
|
|
63
|
-
groupToCount.counter_users = Math.max(_.uniq(allUsers).length, 1);
|
|
64
|
-
await groupToCount.save();
|
|
65
|
-
}
|
|
66
|
-
callback();
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
callback(error);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
module.exports = {
|
|
73
|
-
recountGroupFolder
|
|
74
|
-
};
|