@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,810 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const models = require("../../../models/index.cjs");
|
|
3
|
-
const async = require("async");
|
|
4
|
-
const log = require("../../utils/logger.cjs");
|
|
5
|
-
const TOXICITY_THRESHOLD = 0.5;
|
|
6
|
-
const TOXICITY_EMAIL_THRESHOLD = 0.75;
|
|
7
|
-
const Perspective = require("./perspective_api_client.cjs");
|
|
8
|
-
const queue = require("../../workers/queue.cjs");
|
|
9
|
-
let perspectiveApi;
|
|
10
|
-
if (process.env.GOOGLE_PERSPECTIVE_API_KEY) {
|
|
11
|
-
perspectiveApi = new Perspective({
|
|
12
|
-
apiKey: process.env.GOOGLE_PERSPECTIVE_API_KEY,
|
|
13
|
-
projectId: process.env.GOOGLE_TRANSLATE_PROJECT_ID
|
|
14
|
-
? process.env.GOOGLE_TRANSLATE_PROJECT_ID
|
|
15
|
-
: undefined,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
const getToxicityScoreForText = (text, doNotStore, callback) => {
|
|
19
|
-
log.info("getToxicityScoreForText starting", { doNotStore });
|
|
20
|
-
if (text && text !== "") {
|
|
21
|
-
perspectiveApi
|
|
22
|
-
.analyze(text, {
|
|
23
|
-
doNotStore,
|
|
24
|
-
attributes: [
|
|
25
|
-
"TOXICITY",
|
|
26
|
-
"SEVERE_TOXICITY",
|
|
27
|
-
"IDENTITY_ATTACK",
|
|
28
|
-
"THREAT",
|
|
29
|
-
"INSULT",
|
|
30
|
-
"PROFANITY",
|
|
31
|
-
"SEXUALLY_EXPLICIT",
|
|
32
|
-
"FLIRTATION",
|
|
33
|
-
// New experimental attributes
|
|
34
|
-
"AFFINITY_EXPERIMENTAL",
|
|
35
|
-
"COMPASSION_EXPERIMENTAL",
|
|
36
|
-
"CURIOSITY_EXPERIMENTAL",
|
|
37
|
-
"NUANCE_EXPERIMENTAL",
|
|
38
|
-
"PERSONAL_STORY_EXPERIMENTAL",
|
|
39
|
-
"REASONING_EXPERIMENTAL",
|
|
40
|
-
"RESPECT_EXPERIMENTAL",
|
|
41
|
-
],
|
|
42
|
-
})
|
|
43
|
-
.then((result) => {
|
|
44
|
-
log.info("getToxicityScoreForText results");
|
|
45
|
-
callback(null, result);
|
|
46
|
-
})
|
|
47
|
-
.catch((error) => {
|
|
48
|
-
if (error &&
|
|
49
|
-
error.stack &&
|
|
50
|
-
error.stack.indexOf("ResponseError: Attribute") > -1 &&
|
|
51
|
-
error.stack.indexOf("does not support request languages") > -1) {
|
|
52
|
-
log.warn("getToxicityScoreForText warning", { warning: error });
|
|
53
|
-
callback();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
log.error("getToxicityScoreForText error", { error });
|
|
57
|
-
callback(error);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
callback("No text for toxicity score");
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const setupModelPublicDataScore = (model, text, results) => {
|
|
66
|
-
if (!model.data)
|
|
67
|
-
model.set("data", {});
|
|
68
|
-
if (!model.data.moderation)
|
|
69
|
-
model.set("data.moderation", {});
|
|
70
|
-
model.set("data.moderation.rawToxicityResults", results);
|
|
71
|
-
// Existing attributes
|
|
72
|
-
let toxicityScore, severeToxicityScore, identityAttackScore, threatScore, insultScore, profanityScore, sexuallyExplicitScore, flirtationScore;
|
|
73
|
-
// New attributes
|
|
74
|
-
let affinityScore, compassionScore, curiosityScore, nuanceScore, personalStoryScore, reasoningScore, respectScore;
|
|
75
|
-
try {
|
|
76
|
-
// Existing scores
|
|
77
|
-
toxicityScore = results.attributeScores["TOXICITY"].summaryScore.value;
|
|
78
|
-
severeToxicityScore =
|
|
79
|
-
results.attributeScores["SEVERE_TOXICITY"].summaryScore.value;
|
|
80
|
-
identityAttackScore =
|
|
81
|
-
results.attributeScores["IDENTITY_ATTACK"].summaryScore.value;
|
|
82
|
-
threatScore = results.attributeScores["THREAT"].summaryScore.value;
|
|
83
|
-
insultScore = results.attributeScores["INSULT"].summaryScore.value;
|
|
84
|
-
profanityScore = results.attributeScores["PROFANITY"].summaryScore.value;
|
|
85
|
-
sexuallyExplicitScore =
|
|
86
|
-
results.attributeScores["SEXUALLY_EXPLICIT"].summaryScore.value;
|
|
87
|
-
flirtationScore = results.attributeScores["FLIRTATION"].summaryScore.value;
|
|
88
|
-
affinityScore =
|
|
89
|
-
results.attributeScores["AFFINITY_EXPERIMENTAL"].summaryScore.value;
|
|
90
|
-
compassionScore =
|
|
91
|
-
results.attributeScores["COMPASSION_EXPERIMENTAL"].summaryScore.value;
|
|
92
|
-
curiosityScore =
|
|
93
|
-
results.attributeScores["CURIOSITY_EXPERIMENTAL"].summaryScore.value;
|
|
94
|
-
nuanceScore =
|
|
95
|
-
results.attributeScores["NUANCE_EXPERIMENTAL"].summaryScore.value;
|
|
96
|
-
personalStoryScore =
|
|
97
|
-
results.attributeScores["PERSONAL_STORY_EXPERIMENTAL"].summaryScore.value;
|
|
98
|
-
reasoningScore =
|
|
99
|
-
results.attributeScores["REASONING_EXPERIMENTAL"].summaryScore.value;
|
|
100
|
-
respectScore =
|
|
101
|
-
results.attributeScores["RESPECT_EXPERIMENTAL"].summaryScore.value;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
log.error(error);
|
|
105
|
-
}
|
|
106
|
-
model.set("data.moderation.toxicityScore", toxicityScore);
|
|
107
|
-
model.set("data.moderation.severeToxicityScore", severeToxicityScore);
|
|
108
|
-
model.set("data.moderation.identityAttackScore", identityAttackScore);
|
|
109
|
-
model.set("data.moderation.threatScore", threatScore);
|
|
110
|
-
model.set("data.moderation.insultScore", insultScore);
|
|
111
|
-
model.set("data.moderation.profanityScore", profanityScore);
|
|
112
|
-
model.set("data.moderation.sexuallyExplicitScore", sexuallyExplicitScore);
|
|
113
|
-
model.set("data.moderation.flirtationScore", flirtationScore);
|
|
114
|
-
model.set("data.moderation.textUsedForScore", text);
|
|
115
|
-
model.set("data.moderation.affinityScore", affinityScore);
|
|
116
|
-
model.set("data.moderation.compassionScore", compassionScore);
|
|
117
|
-
model.set("data.moderation.curiosityScore", curiosityScore);
|
|
118
|
-
model.set("data.moderation.nuanceScore", nuanceScore);
|
|
119
|
-
model.set("data.moderation.personalStoryScore", personalStoryScore);
|
|
120
|
-
model.set("data.moderation.reasoningScore", reasoningScore);
|
|
121
|
-
model.set("data.moderation.respectScore", respectScore);
|
|
122
|
-
};
|
|
123
|
-
const hasModelBreachedToxicityThreshold = (model) => {
|
|
124
|
-
if (model.data &&
|
|
125
|
-
model.data.moderation &&
|
|
126
|
-
(model.data.moderation.toxicityScore ||
|
|
127
|
-
model.data.moderation.severeToxicityScore)) {
|
|
128
|
-
if (model.data.moderation.toxicityScore > TOXICITY_THRESHOLD) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const hasModelBreachedToxicityEmailThreshold = (model) => {
|
|
140
|
-
if (model.data &&
|
|
141
|
-
model.data.moderation &&
|
|
142
|
-
(model.data.moderation.toxicityScore ||
|
|
143
|
-
model.data.moderation.severeToxicityScore)) {
|
|
144
|
-
if (model.data.moderation.toxicityScore > TOXICITY_EMAIL_THRESHOLD) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
const getTranslatedTextForCollection = (collectionType, model, callback) => {
|
|
156
|
-
let name, content;
|
|
157
|
-
async.parallel([
|
|
158
|
-
(parallelCallback) => {
|
|
159
|
-
const req = {
|
|
160
|
-
query: {
|
|
161
|
-
textType: collectionType === "community" ? "communityName" : "groupName",
|
|
162
|
-
targetLanguage: "en",
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
models.AcTranslationCache.getTranslation(req, model, (error, translation) => {
|
|
166
|
-
if (error) {
|
|
167
|
-
parallelCallback(error);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
name = translation;
|
|
171
|
-
parallelCallback();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
},
|
|
175
|
-
(parallelCallback) => {
|
|
176
|
-
const req = {
|
|
177
|
-
query: {
|
|
178
|
-
textType: collectionType === "community"
|
|
179
|
-
? "communityContent"
|
|
180
|
-
: "groupContent",
|
|
181
|
-
targetLanguage: "en",
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
models.AcTranslationCache.getTranslation(req, model, (error, translation) => {
|
|
185
|
-
if (error) {
|
|
186
|
-
parallelCallback(error);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
content = translation;
|
|
190
|
-
parallelCallback();
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
},
|
|
194
|
-
], (error) => {
|
|
195
|
-
if (name && content) {
|
|
196
|
-
callback(error, `${name.content} ${content.content}`);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
log.error("No collection name or content for toxicity!", { error });
|
|
200
|
-
callback(error);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
const getTranslatedTextForPoint = (point, callback) => {
|
|
205
|
-
const req = {
|
|
206
|
-
query: {
|
|
207
|
-
textType: "pointContent",
|
|
208
|
-
targetLanguage: "en",
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
models.AcTranslationCache.getTranslation(req, point, (error, translation) => {
|
|
212
|
-
if (error) {
|
|
213
|
-
callback(error);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
callback(null, translation);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
const getTranslatedTextForPost = (post, callback) => {
|
|
221
|
-
let postName, postDescription, postTranscript;
|
|
222
|
-
let postStructuredAnswers = "";
|
|
223
|
-
async.parallel([
|
|
224
|
-
(parallelCallback) => {
|
|
225
|
-
const req = {
|
|
226
|
-
query: {
|
|
227
|
-
textType: "postName",
|
|
228
|
-
targetLanguage: "en",
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
models.AcTranslationCache.getTranslation(req, post, (error, translation) => {
|
|
232
|
-
if (error) {
|
|
233
|
-
parallelCallback(error);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
postName = translation;
|
|
237
|
-
parallelCallback();
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
(parallelCallback) => {
|
|
242
|
-
const req = {
|
|
243
|
-
query: {
|
|
244
|
-
textType: "postContent",
|
|
245
|
-
targetLanguage: "en",
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
models.AcTranslationCache.getTranslation(req, post, (error, translation) => {
|
|
249
|
-
if (error) {
|
|
250
|
-
parallelCallback(error);
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
postDescription = translation;
|
|
254
|
-
parallelCallback();
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
},
|
|
258
|
-
(parallelCallback) => {
|
|
259
|
-
const req = {
|
|
260
|
-
query: {
|
|
261
|
-
textType: "postTranscriptContent",
|
|
262
|
-
targetLanguage: "en",
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
models.AcTranslationCache.getTranslation(req, post, (error, translation) => {
|
|
266
|
-
if (error) {
|
|
267
|
-
log.warn("No text from translate", { error });
|
|
268
|
-
parallelCallback();
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
postTranscript = translation;
|
|
272
|
-
parallelCallback();
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
},
|
|
276
|
-
(parallelCallback) => {
|
|
277
|
-
if (post.public_data &&
|
|
278
|
-
post.public_data.structuredAnswersJson &&
|
|
279
|
-
post.public_data.structuredAnswersJson.length > 0) {
|
|
280
|
-
models.AcTranslationCache.getSurveyAnswerTranslations(post.id, "en", (error, translations) => {
|
|
281
|
-
if (error) {
|
|
282
|
-
parallelCallback(error);
|
|
283
|
-
}
|
|
284
|
-
else if (translations) {
|
|
285
|
-
const safeTranslations = translations.map((val) => {
|
|
286
|
-
return typeof val === "string" ? val : String(val);
|
|
287
|
-
});
|
|
288
|
-
postStructuredAnswers = safeTranslations.join(". ");
|
|
289
|
-
parallelCallback();
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
log.warn("No translations for survey answers");
|
|
293
|
-
parallelCallback();
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
parallelCallback();
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
], (error) => {
|
|
302
|
-
if (postName && (postDescription || postStructuredAnswers)) {
|
|
303
|
-
callback(error, `${postName.content} ${postDescription ? postDescription.content : ""} ${postStructuredAnswers} ${postTranscript ? postTranscript.content : ""}`);
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
log.error("No postname for toxicity!", { error });
|
|
307
|
-
callback(error);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
const estimateToxicityScoreForCollection = (options, callback) => {
|
|
312
|
-
if (process.env.GOOGLE_PERSPECTIVE_API_KEY) {
|
|
313
|
-
log.info("getToxicityScoreForText collection preparing", { options });
|
|
314
|
-
const model = options.collectionType === "community" ? models.Community : models.Group;
|
|
315
|
-
let collectionIncludes = [];
|
|
316
|
-
let attributes = [];
|
|
317
|
-
if (options.collectionType === "group") {
|
|
318
|
-
collectionIncludes = [
|
|
319
|
-
{
|
|
320
|
-
model: models.Community,
|
|
321
|
-
attributes: ["id", "access", "domain_id"],
|
|
322
|
-
},
|
|
323
|
-
];
|
|
324
|
-
attributes = ["id", "language", "name", "objectives", "data"];
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
attributes = [
|
|
328
|
-
"id",
|
|
329
|
-
"language",
|
|
330
|
-
"name",
|
|
331
|
-
"domain_id",
|
|
332
|
-
"description",
|
|
333
|
-
"data",
|
|
334
|
-
];
|
|
335
|
-
}
|
|
336
|
-
model
|
|
337
|
-
.unscoped()
|
|
338
|
-
.findOne({
|
|
339
|
-
where: {
|
|
340
|
-
id: options.collectionId,
|
|
341
|
-
},
|
|
342
|
-
include: collectionIncludes,
|
|
343
|
-
attributes: attributes,
|
|
344
|
-
})
|
|
345
|
-
.then((collection) => {
|
|
346
|
-
if (collection) {
|
|
347
|
-
let doNotStoreValue = collection.access === 0;
|
|
348
|
-
if (options.collectionType === "group" &&
|
|
349
|
-
collection.Community.access === 0)
|
|
350
|
-
doNotStoreValue = true;
|
|
351
|
-
let textContent, textUsed, transcriptText;
|
|
352
|
-
textContent = `${collection.name}`;
|
|
353
|
-
if (textContent !== "") {
|
|
354
|
-
log.info("getToxicityScoreForText collection getting translated text");
|
|
355
|
-
getTranslatedTextForCollection(options.collectionType, collection, (error, translatedText) => {
|
|
356
|
-
log.info("getToxicityScoreForText collection got translated text", { translatedText, error });
|
|
357
|
-
if (error)
|
|
358
|
-
callback(error);
|
|
359
|
-
else
|
|
360
|
-
textUsed = translatedText;
|
|
361
|
-
getToxicityScoreForText(textUsed, doNotStoreValue, (error, results) => {
|
|
362
|
-
if (error) {
|
|
363
|
-
callback(error);
|
|
364
|
-
}
|
|
365
|
-
else if (results) {
|
|
366
|
-
collection.reload().then(() => {
|
|
367
|
-
setupModelPublicDataScore(collection, textUsed, results);
|
|
368
|
-
collection
|
|
369
|
-
.save()
|
|
370
|
-
.then(() => {
|
|
371
|
-
if (hasModelBreachedToxicityThreshold(collection)) {
|
|
372
|
-
collection.report({
|
|
373
|
-
disableNotification: !hasModelBreachedToxicityEmailThreshold(collection),
|
|
374
|
-
}, "perspectiveAPI", callback);
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
callback();
|
|
378
|
-
}
|
|
379
|
-
})
|
|
380
|
-
.catch((error) => {
|
|
381
|
-
callback(error);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
log.warn("No results from getToxicityScoreForText");
|
|
387
|
-
callback();
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
else {
|
|
393
|
-
log.warn("getToxicityScoreForText collection No text for toxicity");
|
|
394
|
-
callback();
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
log.error("getToxicityScoreForText collection could not find collection");
|
|
399
|
-
callback("Could not find collection");
|
|
400
|
-
}
|
|
401
|
-
})
|
|
402
|
-
.catch((error) => {
|
|
403
|
-
log.error("getToxicityScoreForText collection error", { error });
|
|
404
|
-
callback(error);
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
log.warn("getToxicityScoreForText: No API key");
|
|
409
|
-
callback();
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
const estimateToxicityScoreForPost = (options, callback) => {
|
|
413
|
-
if (process.env.GOOGLE_PERSPECTIVE_API_KEY) {
|
|
414
|
-
log.info("getToxicityScoreForText post preparing");
|
|
415
|
-
models.Post.unscoped()
|
|
416
|
-
.findOne({
|
|
417
|
-
where: {
|
|
418
|
-
id: options.postId,
|
|
419
|
-
},
|
|
420
|
-
include: [
|
|
421
|
-
{
|
|
422
|
-
model: models.Audio,
|
|
423
|
-
as: "PostAudios",
|
|
424
|
-
required: false,
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
model: models.Video,
|
|
428
|
-
as: "PostVideos",
|
|
429
|
-
required: false,
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
model: models.Group,
|
|
433
|
-
attributes: ["id", "access"],
|
|
434
|
-
include: [
|
|
435
|
-
{
|
|
436
|
-
model: models.Community,
|
|
437
|
-
required: true,
|
|
438
|
-
attributes: ["id", "access"],
|
|
439
|
-
include: [
|
|
440
|
-
{
|
|
441
|
-
model: models.Domain,
|
|
442
|
-
required: true,
|
|
443
|
-
attributes: ["id"],
|
|
444
|
-
},
|
|
445
|
-
],
|
|
446
|
-
},
|
|
447
|
-
],
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
model: models.User,
|
|
451
|
-
attribues: ["id", "age_group"],
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
attributes: [
|
|
455
|
-
"id",
|
|
456
|
-
"name",
|
|
457
|
-
"description",
|
|
458
|
-
"language",
|
|
459
|
-
"data",
|
|
460
|
-
"group_id",
|
|
461
|
-
"public_data",
|
|
462
|
-
"user_id",
|
|
463
|
-
"user_agent",
|
|
464
|
-
"ip_address",
|
|
465
|
-
],
|
|
466
|
-
})
|
|
467
|
-
.then((post) => {
|
|
468
|
-
if (post) {
|
|
469
|
-
let doNotStoreValue = post.Group.access === 0 && post.Group.Community.access === 0
|
|
470
|
-
? false
|
|
471
|
-
: true;
|
|
472
|
-
if (post.User.age_group &&
|
|
473
|
-
(post.User.age_group === "0-12" || post.User.age_group === "0"))
|
|
474
|
-
doNotStoreValue = true;
|
|
475
|
-
let textContent, textUsed, transcriptText;
|
|
476
|
-
if (post.public_data &&
|
|
477
|
-
post.public_data.transcript &&
|
|
478
|
-
post.public_data.transcript.text) {
|
|
479
|
-
transcriptText = post.public_data.transcript.text;
|
|
480
|
-
}
|
|
481
|
-
textContent = `${post.name} ${post.description} ${transcriptText ? transcriptText : ""}`;
|
|
482
|
-
if (textContent !== "") {
|
|
483
|
-
log.info("getToxicityScoreForText post getting translated text");
|
|
484
|
-
getTranslatedTextForPost(post, (error, translatedText) => {
|
|
485
|
-
//log.info("getToxicityScoreForText post got translated text", { translatedText, error });
|
|
486
|
-
if (error) {
|
|
487
|
-
callback(error);
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
textUsed = translatedText;
|
|
491
|
-
getToxicityScoreForText(textUsed, doNotStoreValue, (error, results) => {
|
|
492
|
-
if (error) {
|
|
493
|
-
callback(error);
|
|
494
|
-
}
|
|
495
|
-
else if (results) {
|
|
496
|
-
post.reload().then(() => {
|
|
497
|
-
setupModelPublicDataScore(post, textUsed, results);
|
|
498
|
-
post
|
|
499
|
-
.save()
|
|
500
|
-
.then(() => {
|
|
501
|
-
sendPostAnalyticsEvent(post);
|
|
502
|
-
if (hasModelBreachedToxicityThreshold(post)) {
|
|
503
|
-
post.report({
|
|
504
|
-
disableNotification: !hasModelBreachedToxicityEmailThreshold(post),
|
|
505
|
-
}, "perspectiveAPI", callback);
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
callback();
|
|
509
|
-
}
|
|
510
|
-
})
|
|
511
|
-
.catch((error) => {
|
|
512
|
-
callback(error);
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
log.warn("No results for toxicity");
|
|
518
|
-
callback();
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
log.warn("getToxicityScoreForText post No text for toxicity");
|
|
526
|
-
callback();
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
log.error("getToxicityScoreForText post could not find post");
|
|
531
|
-
callback("Could not find post");
|
|
532
|
-
}
|
|
533
|
-
})
|
|
534
|
-
.catch((error) => {
|
|
535
|
-
log.error("getToxicityScoreForText post error", { error });
|
|
536
|
-
callback(error);
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
log.warn("getToxicityScoreForText: No API key");
|
|
541
|
-
callback();
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
const estimateToxicityScoreForPoint = (options, callback) => {
|
|
545
|
-
if (process.env.GOOGLE_PERSPECTIVE_API_KEY) {
|
|
546
|
-
log.info("getToxicityScoreForText preparing");
|
|
547
|
-
models.Point.unscoped()
|
|
548
|
-
.findOne({
|
|
549
|
-
attributes: [
|
|
550
|
-
"id",
|
|
551
|
-
"language",
|
|
552
|
-
"data",
|
|
553
|
-
"post_id",
|
|
554
|
-
"group_id",
|
|
555
|
-
"user_id",
|
|
556
|
-
"user_agent",
|
|
557
|
-
"ip_address",
|
|
558
|
-
],
|
|
559
|
-
where: {
|
|
560
|
-
id: options.pointId,
|
|
561
|
-
},
|
|
562
|
-
order: [[models.PointRevision, "created_at", "asc"]],
|
|
563
|
-
include: [
|
|
564
|
-
{
|
|
565
|
-
model: models.Audio,
|
|
566
|
-
as: "PointAudios",
|
|
567
|
-
required: false,
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
model: models.Video,
|
|
571
|
-
as: "PointVideos",
|
|
572
|
-
required: false,
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
model: models.Group,
|
|
576
|
-
attributes: ["id", "access"],
|
|
577
|
-
required: false,
|
|
578
|
-
include: [
|
|
579
|
-
{
|
|
580
|
-
model: models.Community,
|
|
581
|
-
required: false,
|
|
582
|
-
attributes: ["id", "access"],
|
|
583
|
-
include: [
|
|
584
|
-
{
|
|
585
|
-
model: models.Domain,
|
|
586
|
-
required: false,
|
|
587
|
-
attributes: ["id"],
|
|
588
|
-
},
|
|
589
|
-
],
|
|
590
|
-
},
|
|
591
|
-
],
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
model: models.PointRevision,
|
|
595
|
-
attribues: ["id", "content"],
|
|
596
|
-
},
|
|
597
|
-
{
|
|
598
|
-
model: models.User,
|
|
599
|
-
attribues: ["id", "age_group"],
|
|
600
|
-
},
|
|
601
|
-
],
|
|
602
|
-
})
|
|
603
|
-
.then((point) => {
|
|
604
|
-
if (point) {
|
|
605
|
-
let doNotStoreValue = true;
|
|
606
|
-
if (point.Group &&
|
|
607
|
-
point.Group.access === 0 &&
|
|
608
|
-
(!point.Group.Community || point.Group.Community.access === 0))
|
|
609
|
-
doNotStoreValue = false;
|
|
610
|
-
if (point.User &&
|
|
611
|
-
point.User.age_group &&
|
|
612
|
-
(point.User.age_group === "0-12" || point.User.age_group === "0"))
|
|
613
|
-
doNotStoreValue = true;
|
|
614
|
-
let textContent, textUsed;
|
|
615
|
-
textContent =
|
|
616
|
-
point.PointRevisions[point.PointRevisions.length - 1].content;
|
|
617
|
-
if (textContent && textContent !== "") {
|
|
618
|
-
log.info("getToxicityScoreForText getting translated text");
|
|
619
|
-
getTranslatedTextForPoint(point, (error, translatedText) => {
|
|
620
|
-
//log.info("getToxicityScoreForText got translated text", { translatedText, error });
|
|
621
|
-
if (error)
|
|
622
|
-
callback(error);
|
|
623
|
-
else if (translatedText.content == null)
|
|
624
|
-
callback("Can't find translatedText.content");
|
|
625
|
-
else
|
|
626
|
-
textUsed = translatedText.content;
|
|
627
|
-
getToxicityScoreForText(textUsed, doNotStoreValue, (error, results) => {
|
|
628
|
-
if (error) {
|
|
629
|
-
callback(error);
|
|
630
|
-
}
|
|
631
|
-
else if (results) {
|
|
632
|
-
point.reload().then(() => {
|
|
633
|
-
setupModelPublicDataScore(point, textUsed, results);
|
|
634
|
-
point
|
|
635
|
-
.save()
|
|
636
|
-
.then(() => {
|
|
637
|
-
sendPointAnalyticsEvent(point);
|
|
638
|
-
if (hasModelBreachedToxicityThreshold(point)) {
|
|
639
|
-
if (point.post_id) {
|
|
640
|
-
models.Post.unscoped()
|
|
641
|
-
.findOne({
|
|
642
|
-
where: {
|
|
643
|
-
id: point.post_id,
|
|
644
|
-
},
|
|
645
|
-
attributes: ["id", "data"],
|
|
646
|
-
include: [
|
|
647
|
-
{
|
|
648
|
-
model: models.Group,
|
|
649
|
-
attributes: ["id"],
|
|
650
|
-
include: [
|
|
651
|
-
{
|
|
652
|
-
model: models.Community,
|
|
653
|
-
attributes: ["id"],
|
|
654
|
-
include: [
|
|
655
|
-
{
|
|
656
|
-
model: models.Domain,
|
|
657
|
-
attributes: ["id"],
|
|
658
|
-
},
|
|
659
|
-
],
|
|
660
|
-
},
|
|
661
|
-
],
|
|
662
|
-
},
|
|
663
|
-
],
|
|
664
|
-
})
|
|
665
|
-
.then((post) => {
|
|
666
|
-
point.report({
|
|
667
|
-
disableNotification: !hasModelBreachedToxicityEmailThreshold(point),
|
|
668
|
-
}, "perspectiveAPI", post, callback);
|
|
669
|
-
})
|
|
670
|
-
.catch((error) => {
|
|
671
|
-
callback(error);
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
else {
|
|
675
|
-
point.report({
|
|
676
|
-
disableNotification: !hasModelBreachedToxicityEmailThreshold(point),
|
|
677
|
-
}, "perspectiveAPI", null, callback);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
callback();
|
|
682
|
-
}
|
|
683
|
-
})
|
|
684
|
-
.catch((error) => {
|
|
685
|
-
callback(error);
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
else {
|
|
690
|
-
log.warn("No results for toxicity");
|
|
691
|
-
callback();
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
log.warn("getToxicityScoreForText No text for toxicity");
|
|
698
|
-
callback();
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
log.error("getToxicityScoreForText could not find point");
|
|
703
|
-
callback("Could not find point");
|
|
704
|
-
}
|
|
705
|
-
})
|
|
706
|
-
.catch((error) => {
|
|
707
|
-
log.error("getToxicityScoreForText error", { error });
|
|
708
|
-
callback(error);
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
log.warn("getToxicityScoreForText: No Google API key");
|
|
713
|
-
callback();
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
const sendPostAnalyticsEvent = (post) => {
|
|
717
|
-
try {
|
|
718
|
-
if (post.data &&
|
|
719
|
-
post.data.moderation &&
|
|
720
|
-
post.data.moderation.toxicityScore) {
|
|
721
|
-
const moderationScore = JSON.parse(JSON.stringify(post.data.moderation));
|
|
722
|
-
moderationScore.rawToxicityResults = undefined;
|
|
723
|
-
moderationScore.textUsedForScore = undefined;
|
|
724
|
-
const analyticsEvent = {
|
|
725
|
-
postId: post.id,
|
|
726
|
-
groupId: post.Group.id,
|
|
727
|
-
communityId: post.Group.Community.id,
|
|
728
|
-
domainId: post.Group.Community.Domain.id,
|
|
729
|
-
userId: post.user_id,
|
|
730
|
-
body: {
|
|
731
|
-
type: "evaluated - post toxicity",
|
|
732
|
-
useTypeNameUnchanged: true,
|
|
733
|
-
originalQueryString: post.data.originalQueryString,
|
|
734
|
-
userLocale: post.data.userLocale,
|
|
735
|
-
userAutoTranslate: post.data.userAutoTranslate,
|
|
736
|
-
referrer: post.data.referrer || "",
|
|
737
|
-
url: post.data.url || "",
|
|
738
|
-
screen_width: post.data.screen_width || "1200",
|
|
739
|
-
props: moderationScore,
|
|
740
|
-
user_agent: post.user_agent || "Internal systems",
|
|
741
|
-
ipAddress: post.ip_address || "127.0.0.1",
|
|
742
|
-
server_timestamp: Date.now(),
|
|
743
|
-
},
|
|
744
|
-
};
|
|
745
|
-
if (hasModelBreachedToxicityEmailThreshold(post)) {
|
|
746
|
-
analyticsEvent.body.type = "evaluated - post toxicity high";
|
|
747
|
-
}
|
|
748
|
-
else if (hasModelBreachedToxicityThreshold(post)) {
|
|
749
|
-
analyticsEvent.body.type = "evaluated - post toxicity medium";
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
analyticsEvent.body.type = "evaluated - post toxicity low";
|
|
753
|
-
}
|
|
754
|
-
queue.add("delayed-job", { type: "create-activity-from-app", workData: analyticsEvent }, "medium");
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
catch (error) {
|
|
758
|
-
log.error(error);
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
const sendPointAnalyticsEvent = (point) => {
|
|
762
|
-
try {
|
|
763
|
-
if (point.data &&
|
|
764
|
-
point.data.moderation &&
|
|
765
|
-
point.data.moderation.toxicityScore) {
|
|
766
|
-
const moderationScore = JSON.parse(JSON.stringify(point.data.moderation));
|
|
767
|
-
moderationScore.rawToxicityResults = undefined;
|
|
768
|
-
moderationScore.textUsedForScore = undefined;
|
|
769
|
-
const analyticsEvent = {
|
|
770
|
-
postId: point.post_id,
|
|
771
|
-
groupId: point.Group.id,
|
|
772
|
-
communityId: point.Group.Community.id,
|
|
773
|
-
domainId: point.Group.Community.Domain.id,
|
|
774
|
-
userId: point.user_id,
|
|
775
|
-
pointId: point.id,
|
|
776
|
-
body: {
|
|
777
|
-
useTypeNameUnchanged: true,
|
|
778
|
-
originalQueryString: point.data.originalQueryString,
|
|
779
|
-
userLocale: point.data.userLocale,
|
|
780
|
-
userAutoTranslate: point.data.userAutoTranslate,
|
|
781
|
-
referrer: point.data.referrer || "",
|
|
782
|
-
url: point.data.url || "",
|
|
783
|
-
screen_width: point.data.screen_width || "1200",
|
|
784
|
-
props: moderationScore,
|
|
785
|
-
user_agent: point.user_agent || "Internal systems",
|
|
786
|
-
ipAddress: point.ip_address || "127.0.0.1",
|
|
787
|
-
server_timestamp: Date.now(),
|
|
788
|
-
},
|
|
789
|
-
};
|
|
790
|
-
if (hasModelBreachedToxicityEmailThreshold(point)) {
|
|
791
|
-
analyticsEvent.body.type = "evaluated - point toxicity high";
|
|
792
|
-
}
|
|
793
|
-
else if (hasModelBreachedToxicityThreshold(point)) {
|
|
794
|
-
analyticsEvent.body.type = "evaluated - point toxicity medium";
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
analyticsEvent.body.type = "evaluated - point toxicity low";
|
|
798
|
-
}
|
|
799
|
-
queue.add("delayed-job", { type: "create-activity-from-app", workData: analyticsEvent }, "medium");
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
catch (error) {
|
|
803
|
-
log.error(error);
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
module.exports = {
|
|
807
|
-
estimateToxicityScoreForPoint,
|
|
808
|
-
estimateToxicityScoreForPost,
|
|
809
|
-
estimateToxicityScoreForCollection,
|
|
810
|
-
};
|