@yrpri/api 9.0.103 → 9.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
package/dist/models/point.cjs
DELETED
|
@@ -1,622 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const async = require('async');
|
|
3
|
-
const queue = require('../active-citizen/workers/queue.cjs');
|
|
4
|
-
const log = require('../utils/logger.cjs');
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const findCommunityAndDomainForPointFromGroup = (sequelize, options, callback) => {
|
|
7
|
-
sequelize.models.Group.findOne({
|
|
8
|
-
where: {
|
|
9
|
-
id: options.group_id
|
|
10
|
-
},
|
|
11
|
-
include: [
|
|
12
|
-
{
|
|
13
|
-
model: sequelize.models.Community,
|
|
14
|
-
attributes: ['id'],
|
|
15
|
-
required: true,
|
|
16
|
-
include: [
|
|
17
|
-
{
|
|
18
|
-
model: sequelize.models.Domain,
|
|
19
|
-
attributes: ['id'],
|
|
20
|
-
required: true
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}).then((group) => {
|
|
26
|
-
if (group) {
|
|
27
|
-
options.community_id = group.Community.id;
|
|
28
|
-
options.domain_id = group.Community.Domain.id;
|
|
29
|
-
}
|
|
30
|
-
callback(null, options);
|
|
31
|
-
}).catch((error) => {
|
|
32
|
-
callback(error);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const attachEmptyGroupIfNeeded = (sequelize, options, callback) => {
|
|
36
|
-
if (!options.group_id &&
|
|
37
|
-
(options.domain_id || (options.community_id && options.communityAccess == sequelize.models.Community.ACCESS_PUBLIC))) {
|
|
38
|
-
sequelize.models.Group.findOrCreate({ where: { name: 'hidden_public_group_for_domain_level_points' },
|
|
39
|
-
defaults: { access: sequelize.models.Group.ACCESS_PUBLIC } })
|
|
40
|
-
.then(results => {
|
|
41
|
-
const [group, created] = results;
|
|
42
|
-
if (group) {
|
|
43
|
-
options.group_id = group.id;
|
|
44
|
-
callback(null, options);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
callback("Can't create hidden public group for domain level points");
|
|
48
|
-
}
|
|
49
|
-
}).catch(error => {
|
|
50
|
-
callback(error);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
callback(null, options);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const findGroupAndCommunityAndDomainForPointFromPost = (sequelize, options, callback) => {
|
|
58
|
-
sequelize.models.Post.findOne({
|
|
59
|
-
where: {
|
|
60
|
-
id: options.post_id
|
|
61
|
-
},
|
|
62
|
-
include: [
|
|
63
|
-
{
|
|
64
|
-
model: sequelize.models.Group,
|
|
65
|
-
attributes: ['id'],
|
|
66
|
-
required: true,
|
|
67
|
-
include: [
|
|
68
|
-
{
|
|
69
|
-
model: sequelize.models.Community,
|
|
70
|
-
attributes: ['id'],
|
|
71
|
-
required: true,
|
|
72
|
-
include: [
|
|
73
|
-
{
|
|
74
|
-
model: sequelize.models.Domain,
|
|
75
|
-
attributes: ['id'],
|
|
76
|
-
required: true
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}).then((post) => {
|
|
84
|
-
options.group_id = post.Group.id;
|
|
85
|
-
options.community_id = post.Group.Community.id;
|
|
86
|
-
options.domain_id = post.Group.Community.Domain.id;
|
|
87
|
-
callback(null, options);
|
|
88
|
-
}).catch((error) => {
|
|
89
|
-
callback(error);
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
const findDomainFromCommunity = (sequelize, options, callback) => {
|
|
93
|
-
sequelize.models.Community.findOne({
|
|
94
|
-
where: {
|
|
95
|
-
id: options.community_id
|
|
96
|
-
},
|
|
97
|
-
attributes: ['id', 'access'],
|
|
98
|
-
include: [
|
|
99
|
-
{
|
|
100
|
-
model: sequelize.models.Domain,
|
|
101
|
-
attributes: ['id'],
|
|
102
|
-
required: true
|
|
103
|
-
}
|
|
104
|
-
]
|
|
105
|
-
}).then((community) => {
|
|
106
|
-
options.domain_id = community.Domain.id;
|
|
107
|
-
options.communityAccess = community.access;
|
|
108
|
-
callback(null, options);
|
|
109
|
-
}).catch((error) => {
|
|
110
|
-
callback(error);
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
const setAllActivityGroupingIds = (sequelize, options, callback) => {
|
|
114
|
-
async.series([
|
|
115
|
-
(seriesCallback) => {
|
|
116
|
-
if (options.post_id) {
|
|
117
|
-
findGroupAndCommunityAndDomainForPointFromPost(sequelize, options, (error, optionsIn) => {
|
|
118
|
-
if (optionsIn) {
|
|
119
|
-
options = optionsIn;
|
|
120
|
-
}
|
|
121
|
-
seriesCallback(error);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
seriesCallback();
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
(seriesCallback) => {
|
|
129
|
-
if (options.group_id) {
|
|
130
|
-
findCommunityAndDomainForPointFromGroup(sequelize, options, (error, optionsIn) => {
|
|
131
|
-
if (optionsIn) {
|
|
132
|
-
options = optionsIn;
|
|
133
|
-
}
|
|
134
|
-
seriesCallback(error);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
seriesCallback();
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
(seriesCallback) => {
|
|
142
|
-
if (options.community_id) {
|
|
143
|
-
findDomainFromCommunity(sequelize, options, (error, optionsIn) => {
|
|
144
|
-
if (optionsIn) {
|
|
145
|
-
options = optionsIn;
|
|
146
|
-
}
|
|
147
|
-
seriesCallback(error);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
seriesCallback();
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
// Attach an empty public group to domain and community levels to enable join on activities with group access control
|
|
155
|
-
(seriesCallback) => {
|
|
156
|
-
attachEmptyGroupIfNeeded(sequelize, options, (error, optionsIn) => {
|
|
157
|
-
if (optionsIn) {
|
|
158
|
-
options = optionsIn;
|
|
159
|
-
}
|
|
160
|
-
seriesCallback(error);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
], (error) => {
|
|
164
|
-
callback(error);
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
module.exports = (sequelize, DataTypes) => {
|
|
168
|
-
const Point = sequelize.define("Point", {
|
|
169
|
-
name: { type: DataTypes.STRING, allowNull: true },
|
|
170
|
-
content_type: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
|
|
171
|
-
content: { type: DataTypes.TEXT, allowNull: false },
|
|
172
|
-
status: { type: DataTypes.STRING, allowNull: false },
|
|
173
|
-
value: { type: DataTypes.INTEGER, allowNull: false },
|
|
174
|
-
website: DataTypes.STRING,
|
|
175
|
-
deleted: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
|
176
|
-
deleted_at: { type: DataTypes.DATE, allowNull: true },
|
|
177
|
-
ip_address: { type: DataTypes.STRING, allowNull: false },
|
|
178
|
-
user_agent: { type: DataTypes.TEXT, allowNull: false },
|
|
179
|
-
counter_revisions: { type: DataTypes.INTEGER, defaultValue: 1 },
|
|
180
|
-
counter_quality_up: { type: DataTypes.INTEGER, defaultValue: 0 },
|
|
181
|
-
counter_quality_down: { type: DataTypes.INTEGER, defaultValue: 0 },
|
|
182
|
-
counter_flags: { type: DataTypes.INTEGER, defaultValue: 0 },
|
|
183
|
-
embed_data: DataTypes.JSONB,
|
|
184
|
-
data: DataTypes.JSONB,
|
|
185
|
-
public_data: DataTypes.JSONB,
|
|
186
|
-
language: { type: DataTypes.STRING, allowNull: true }
|
|
187
|
-
}, {
|
|
188
|
-
defaultScope: {
|
|
189
|
-
where: {
|
|
190
|
-
deleted: false,
|
|
191
|
-
status: 'published'
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
indexes: [
|
|
195
|
-
{
|
|
196
|
-
fields: ['post_id'],
|
|
197
|
-
where: {
|
|
198
|
-
deleted: false
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
fields: ['data'],
|
|
203
|
-
using: 'gin',
|
|
204
|
-
operator: 'jsonb_path_ops'
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
fields: ['public_data'],
|
|
208
|
-
using: 'gin',
|
|
209
|
-
operator: 'jsonb_path_ops'
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
fields: ['image_id'],
|
|
213
|
-
where: {
|
|
214
|
-
deleted: false
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
fields: ['post_status_change_id'],
|
|
219
|
-
where: {
|
|
220
|
-
deleted: false
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
fields: ['parent_point_id'],
|
|
225
|
-
where: {
|
|
226
|
-
deleted: false
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
fields: ['user_id', 'group_id', 'deleted']
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
fields: ['user_id', 'group_id', 'deleted', 'status']
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
fields: ['id', 'deleted', 'status']
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
fields: ['post_id', 'deleted', 'status']
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
fields: ['post_id', 'deleted', 'status', 'created_at']
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
name: 'points_idx_deleted_status_id',
|
|
246
|
-
fields: ['deleted', 'status', 'id']
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
name: 'points_idx_deleted_status',
|
|
250
|
-
fields: ['deleted', 'status']
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
underscored: true,
|
|
254
|
-
timestamps: true,
|
|
255
|
-
createdAt: 'created_at',
|
|
256
|
-
updatedAt: 'updated_at',
|
|
257
|
-
tableName: 'points',
|
|
258
|
-
});
|
|
259
|
-
Point.defaultAttributesPublic = [
|
|
260
|
-
'id', 'name', 'content_type', 'content', 'status', 'value',
|
|
261
|
-
'website', 'deleted', 'counter_revisions', 'counter_quality_up',
|
|
262
|
-
'embed_data', 'counter_quality_down', 'public_data', 'language'
|
|
263
|
-
];
|
|
264
|
-
Point.associate = (models) => {
|
|
265
|
-
Point.belongsTo(sequelize.models.PostStatusChange, { foreignKey: 'post_status_change_id' });
|
|
266
|
-
Point.belongsTo(sequelize.models.Post, { foreignKey: 'post_id' });
|
|
267
|
-
Point.belongsTo(sequelize.models.Community, { foreignKey: 'community_id' });
|
|
268
|
-
Point.belongsTo(sequelize.models.Domain, { foreignKey: 'domain_id' });
|
|
269
|
-
Point.belongsTo(sequelize.models.User, { foreignKey: 'user_id' });
|
|
270
|
-
Point.belongsTo(sequelize.models.Image, { foreignKey: 'image_id' });
|
|
271
|
-
Point.belongsTo(sequelize.models.Point, { as: 'ParentPoint', foreignKey: 'parent_point_id' });
|
|
272
|
-
Point.belongsTo(sequelize.models.Group, { foreignKey: 'group_id' });
|
|
273
|
-
Point.hasMany(sequelize.models.PointRevision);
|
|
274
|
-
Point.hasMany(sequelize.models.PointQuality);
|
|
275
|
-
Point.belongsToMany(models.Video, { as: 'PointVideos', through: 'PointVideo' });
|
|
276
|
-
Point.belongsToMany(models.Audio, { as: 'PointAudios', through: 'PointAudio' });
|
|
277
|
-
};
|
|
278
|
-
Point.CONTENT_DEBATE = 0;
|
|
279
|
-
Point.CONTENT_NEWS_STORY = 1;
|
|
280
|
-
Point.CONTENT_COMMENT = 2;
|
|
281
|
-
Point.createComment = (req, options, callback) => {
|
|
282
|
-
options.content = options.comment.content;
|
|
283
|
-
delete options.comment;
|
|
284
|
-
options.user_id = req.user.id;
|
|
285
|
-
options.content_type = sequelize.models.Point.CONTENT_COMMENT;
|
|
286
|
-
options.value = 0;
|
|
287
|
-
options.status = 'published';
|
|
288
|
-
options.user_agent = req.useragent.source;
|
|
289
|
-
options.ip_address = req.clientIp;
|
|
290
|
-
async.series([
|
|
291
|
-
(seriesCallback) => {
|
|
292
|
-
if (options.parent_point_id) {
|
|
293
|
-
sequelize.models.Point.findOne({
|
|
294
|
-
where: {
|
|
295
|
-
id: options.parent_point_id
|
|
296
|
-
},
|
|
297
|
-
attributes: ['id', 'group_id', 'post_id', 'community_id', 'domain_id']
|
|
298
|
-
}).then((parentPoint) => {
|
|
299
|
-
if (parentPoint) {
|
|
300
|
-
options.group_id = parentPoint.group_id;
|
|
301
|
-
options.community_id = parentPoint.community_id;
|
|
302
|
-
options.domain_id = parentPoint.domain_id;
|
|
303
|
-
options.post_id = options.post_id ? options.post_id : parentPoint.post_id;
|
|
304
|
-
}
|
|
305
|
-
seriesCallback();
|
|
306
|
-
}).catch((error) => {
|
|
307
|
-
seriesCallback(error);
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
seriesCallback();
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
(seriesCallback) => {
|
|
315
|
-
if (options.image_id) {
|
|
316
|
-
sequelize.models.Image.findOne({
|
|
317
|
-
where: {
|
|
318
|
-
id: options.image_id
|
|
319
|
-
},
|
|
320
|
-
attributes: ['id', 'user_id'],
|
|
321
|
-
include: [
|
|
322
|
-
{
|
|
323
|
-
model: sequelize.models.Post,
|
|
324
|
-
as: 'PostUserImages',
|
|
325
|
-
attributes: ['id', 'group_id']
|
|
326
|
-
}
|
|
327
|
-
]
|
|
328
|
-
}).then((image) => {
|
|
329
|
-
if (image && image.PostUserImages && image.PostUserImages.length > 0) {
|
|
330
|
-
options.group_id = image.PostUserImages[0].group_id;
|
|
331
|
-
options.post_id = image.PostUserImages[0].id;
|
|
332
|
-
}
|
|
333
|
-
seriesCallback();
|
|
334
|
-
}).catch((error) => {
|
|
335
|
-
seriesCallback(error);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
seriesCallback();
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
(seriesCallback) => {
|
|
343
|
-
setAllActivityGroupingIds(sequelize, options, (error, optionsIn) => {
|
|
344
|
-
if (optionsIn) {
|
|
345
|
-
options = optionsIn;
|
|
346
|
-
}
|
|
347
|
-
seriesCallback(error);
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
(seriesCallback) => {
|
|
351
|
-
options.data = {
|
|
352
|
-
browserId: req.body.pointBaseId,
|
|
353
|
-
browserFingerprint: req.body.pointValCode,
|
|
354
|
-
browserFingerprintConfidence: req.body.pointConf,
|
|
355
|
-
originalQueryString: req.body.originalQueryString,
|
|
356
|
-
userLocale: req.body.userLocale,
|
|
357
|
-
userAutoTranslate: req.body.userAutoTranslate,
|
|
358
|
-
referrer: req.body.referrer,
|
|
359
|
-
url: req.body.url,
|
|
360
|
-
screen_width: req.body.screen_width
|
|
361
|
-
};
|
|
362
|
-
sequelize.models.Point.build(options).save().then((point) => {
|
|
363
|
-
options.point_id = point.id;
|
|
364
|
-
const pointRevision = sequelize.models.PointRevision.build(options);
|
|
365
|
-
pointRevision.save().then(() => {
|
|
366
|
-
log.info("process-moderation point toxicity on comment");
|
|
367
|
-
queue.add('process-moderation', { type: 'estimate-point-toxicity', pointId: point.id }, 'high');
|
|
368
|
-
sequelize.models.AcActivity.createActivity({
|
|
369
|
-
type: 'activity.point.comment.new',
|
|
370
|
-
userId: options.user_id,
|
|
371
|
-
pointId: options.point_id,
|
|
372
|
-
imageId: options.image_id,
|
|
373
|
-
domainId: options.domain_id,
|
|
374
|
-
groupId: options.group_id ? options.group_id : 1,
|
|
375
|
-
communityId: options.community_id,
|
|
376
|
-
postId: options.post_id,
|
|
377
|
-
access: sequelize.models.AcActivity.ACCESS_PUBLIC
|
|
378
|
-
}, (error) => {
|
|
379
|
-
seriesCallback(error);
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
}).catch((error) => {
|
|
383
|
-
seriesCallback(error);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
], (error) => {
|
|
387
|
-
callback(error);
|
|
388
|
-
});
|
|
389
|
-
};
|
|
390
|
-
//TODO Refactor duplicate code with Post
|
|
391
|
-
Point.setOrganizationUsersForPoints = (points, done) => {
|
|
392
|
-
const userIds = points.map(p => {
|
|
393
|
-
return p.user_id;
|
|
394
|
-
});
|
|
395
|
-
sequelize.models.User.findAll({
|
|
396
|
-
attributes: ['id', 'created_at'],
|
|
397
|
-
where: {
|
|
398
|
-
id: {
|
|
399
|
-
$in: userIds
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
|
-
include: [
|
|
403
|
-
{
|
|
404
|
-
model: sequelize.models.Organization,
|
|
405
|
-
as: 'OrganizationUsers',
|
|
406
|
-
required: true,
|
|
407
|
-
attributes: ['id', 'name'],
|
|
408
|
-
include: [
|
|
409
|
-
{
|
|
410
|
-
model: sequelize.models.Image,
|
|
411
|
-
as: 'OrgLogoImgs',
|
|
412
|
-
attributes: ['id', 'formats'],
|
|
413
|
-
required: false
|
|
414
|
-
}
|
|
415
|
-
]
|
|
416
|
-
}
|
|
417
|
-
],
|
|
418
|
-
order: [
|
|
419
|
-
[{ model: sequelize.models.Organization, as: 'OrganizationUsers' }, { model: sequelize.models.Image, as: 'OrgLogoImgs' }, 'created_at', 'asc']
|
|
420
|
-
]
|
|
421
|
-
}).then(users => {
|
|
422
|
-
if (users && users.length > 0) {
|
|
423
|
-
for (let u = 0; u < users.length; u++) {
|
|
424
|
-
for (let p = 0; p < points.length; p++) {
|
|
425
|
-
if (points[p].User.id === users[u].id) {
|
|
426
|
-
points[p].User.OrganizationUsers = users[u].OrganizationUsers;
|
|
427
|
-
points[p].User.setDataValue('OrganizationUsers', users[u].OrganizationUsers);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
done();
|
|
432
|
-
}
|
|
433
|
-
else {
|
|
434
|
-
done();
|
|
435
|
-
}
|
|
436
|
-
}).catch(error => {
|
|
437
|
-
done(error);
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
Point.setVideosForPoints = (points, done) => {
|
|
441
|
-
Point.getVideosForPoints(points.map(p => p.id), (error, videos) => {
|
|
442
|
-
if (error) {
|
|
443
|
-
done(error);
|
|
444
|
-
}
|
|
445
|
-
else if (!videos || videos.length === 0) {
|
|
446
|
-
done();
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
for (let v = 0; v < videos.length; v++) {
|
|
450
|
-
for (let p = 0; p < points.length; p++) {
|
|
451
|
-
if (videos[v].PointVideos &&
|
|
452
|
-
videos[v].PointVideos.length > 0 &&
|
|
453
|
-
points[p].id === videos[v].PointVideos[0].id) {
|
|
454
|
-
if (!points[p].PointVideos) {
|
|
455
|
-
points[p].PointVideos = [];
|
|
456
|
-
}
|
|
457
|
-
points[p].PointVideos.push(videos[v]);
|
|
458
|
-
points[p].setDataValue('PointVideos', points[p].PointVideos);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
done();
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
};
|
|
466
|
-
//TODO Refactor duplicate code with Post
|
|
467
|
-
Point.getVideosForPoints = (pointIds, done) => {
|
|
468
|
-
sequelize.models.Video.findAll({
|
|
469
|
-
attributes: ['id', 'formats', 'viewable', 'created_at', 'public_meta'],
|
|
470
|
-
include: [
|
|
471
|
-
{
|
|
472
|
-
model: sequelize.models.Image,
|
|
473
|
-
as: 'VideoImages',
|
|
474
|
-
attributes: ["formats", 'created_at'],
|
|
475
|
-
required: false
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
model: sequelize.models.Point,
|
|
479
|
-
where: {
|
|
480
|
-
id: {
|
|
481
|
-
$in: pointIds
|
|
482
|
-
}
|
|
483
|
-
},
|
|
484
|
-
as: 'PointVideos',
|
|
485
|
-
required: true,
|
|
486
|
-
attributes: ['id'],
|
|
487
|
-
}
|
|
488
|
-
],
|
|
489
|
-
order: [
|
|
490
|
-
[{ model: sequelize.models.Image, as: 'VideoImages' }, 'created_at', 'asc']
|
|
491
|
-
]
|
|
492
|
-
}).then(videos => {
|
|
493
|
-
videos = _.orderBy(videos, ['created_at'], ['desc']);
|
|
494
|
-
done(null, videos);
|
|
495
|
-
}).catch(error => {
|
|
496
|
-
done(error);
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
Point.addVideosToAllActivityPoints = (activities, videos) => {
|
|
500
|
-
const pointsHash = {};
|
|
501
|
-
for (let i = 0; i < activities.length; i++) {
|
|
502
|
-
if (activities[i].Point) {
|
|
503
|
-
pointsHash[activities[i].Point.id] = activities[i].Point;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
for (let i = 0; i < videos.length; i++) {
|
|
507
|
-
if (videos[i].PointVideos && videos[i].PointVideos.length > 0) {
|
|
508
|
-
const pointId = videos[i].PointVideos[0].id;
|
|
509
|
-
if (pointsHash[pointId]) {
|
|
510
|
-
if (!pointsHash[pointId].dataValues.PointVideos) {
|
|
511
|
-
pointsHash[pointId].dataValues.PointVideos = [];
|
|
512
|
-
}
|
|
513
|
-
pointsHash[pointId].dataValues.PointVideos.push(videos[i]);
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
log.error("Can't find point to add video to");
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
log.error("Can't find PointVideos");
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
Point.createNewsStory = (req, options, callback) => {
|
|
525
|
-
options.content = options.point.content;
|
|
526
|
-
options.embed_data = options.point.embed_data;
|
|
527
|
-
delete options.point;
|
|
528
|
-
async.series([
|
|
529
|
-
(seriesCallback) => {
|
|
530
|
-
setAllActivityGroupingIds(sequelize, options, (error, optionsIn) => {
|
|
531
|
-
if (optionsIn) {
|
|
532
|
-
options = optionsIn;
|
|
533
|
-
}
|
|
534
|
-
seriesCallback(error);
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
], (error) => {
|
|
538
|
-
options.user_id = req.user.id;
|
|
539
|
-
options.content_type = sequelize.models.Point.CONTENT_NEWS_STORY;
|
|
540
|
-
options.value = 0;
|
|
541
|
-
options.status = 'published';
|
|
542
|
-
options.user_agent = req.useragent.source;
|
|
543
|
-
options.ip_address = req.clientIp;
|
|
544
|
-
sequelize.models.Point.build(options).save().then((point) => {
|
|
545
|
-
options.point_id = point.id;
|
|
546
|
-
const pointRevision = sequelize.models.PointRevision.build(options);
|
|
547
|
-
pointRevision.save().then(() => {
|
|
548
|
-
log.info("process-moderation point toxicity on news story");
|
|
549
|
-
if (!options.subType || options.subType != "bulkOperation") {
|
|
550
|
-
queue.add('process-moderation', { type: 'estimate-point-toxicity', pointId: point.id }, 'high');
|
|
551
|
-
}
|
|
552
|
-
sequelize.models.AcActivity.createActivity({
|
|
553
|
-
type: 'activity.point.newsStory.new',
|
|
554
|
-
userId: options.user_id,
|
|
555
|
-
subType: options.subType ? options.subType : null,
|
|
556
|
-
domainId: options.domain_id,
|
|
557
|
-
groupId: options.group_id ? options.group_id : 1,
|
|
558
|
-
pointId: options.point_id,
|
|
559
|
-
context: options.context ? options.context : null,
|
|
560
|
-
communityId: options.community_id,
|
|
561
|
-
postId: options.post_id,
|
|
562
|
-
access: sequelize.models.AcActivity.ACCESS_PUBLIC
|
|
563
|
-
}, (error) => {
|
|
564
|
-
callback(error, point);
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
}).catch((error) => {
|
|
568
|
-
callback(error);
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
};
|
|
572
|
-
Point.prototype.setupModerationData = function () {
|
|
573
|
-
if (!this.data) {
|
|
574
|
-
this.set('data', {});
|
|
575
|
-
}
|
|
576
|
-
if (!this.data.moderation) {
|
|
577
|
-
this.set('data.moderation', {});
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
Point.prototype.report = function (req, source, post, callback) {
|
|
581
|
-
this.setupModerationData();
|
|
582
|
-
async.series([
|
|
583
|
-
(seriesCallback) => {
|
|
584
|
-
if (!this.data.moderation.lastReportedBy) {
|
|
585
|
-
this.set('data.moderation.lastReportedBy', []);
|
|
586
|
-
if ((source === 'user' || source === 'fromUser') && !this.data.moderation.toxicityScore) {
|
|
587
|
-
log.info("process-moderation point toxicity on manual report");
|
|
588
|
-
queue.add('process-moderation', { type: 'estimate-point-toxicity', pointId: this.id }, 'high');
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
this.set('data.moderation.lastReportedBy', [{ date: new Date(), source: source, userId: (req && req.user) ? req.user.id : null, userEmail: (req && req.user) ? req.user.email : 'anonymous' }].concat(this.data.moderation.lastReportedBy));
|
|
592
|
-
this.save().then(() => {
|
|
593
|
-
seriesCallback();
|
|
594
|
-
}).catch((error) => {
|
|
595
|
-
seriesCallback(error);
|
|
596
|
-
});
|
|
597
|
-
},
|
|
598
|
-
(seriesCallback) => {
|
|
599
|
-
if (req && req.disableNotification === true) {
|
|
600
|
-
seriesCallback();
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
sequelize.models.AcActivity.createActivity({
|
|
604
|
-
type: 'activity.report.content',
|
|
605
|
-
userId: (req && req.user) ? req.user.id : null,
|
|
606
|
-
postId: post ? post.id : this.post_id,
|
|
607
|
-
groupId: (post && post.Group) ? post.Group.id : this.group_id,
|
|
608
|
-
pointId: this.id,
|
|
609
|
-
communityId: (post && post.Group && post.Group.Community) ? post.Group.Community.id : null,
|
|
610
|
-
domainId: (post && post.Group && post.Group.Community && post.Group.Community.Domain) ? post.Group.Community.Domain.id : null
|
|
611
|
-
}, (error) => {
|
|
612
|
-
seriesCallback();
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
], (error) => {
|
|
617
|
-
this.increment('counter_flags');
|
|
618
|
-
callback(error);
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
return Point;
|
|
622
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = (sequelize, DataTypes) => {
|
|
3
|
-
const PointQuality = sequelize.define("PointQuality", {
|
|
4
|
-
value: { type: DataTypes.INTEGER, allowNull: false },
|
|
5
|
-
status: { type: DataTypes.STRING, allowNull: false },
|
|
6
|
-
ip_address: { type: DataTypes.STRING, allowNull: false },
|
|
7
|
-
user_agent: { type: DataTypes.TEXT, allowNull: false },
|
|
8
|
-
deleted: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
|
9
|
-
data: { type: DataTypes.JSONB, allowNull: true },
|
|
10
|
-
}, {
|
|
11
|
-
underscored: true,
|
|
12
|
-
tableName: 'point_qualities',
|
|
13
|
-
timestamps: true,
|
|
14
|
-
createdAt: 'created_at',
|
|
15
|
-
updatedAt: 'updated_at',
|
|
16
|
-
defaultScope: {
|
|
17
|
-
where: {
|
|
18
|
-
deleted: false
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
indexes: [
|
|
22
|
-
{
|
|
23
|
-
fields: ['user_id', 'deleted']
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
fields: ['id', 'deleted']
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'point_qualities_idx_deleted',
|
|
30
|
-
fields: ['deleted']
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
PointQuality.associate = (models) => {
|
|
35
|
-
PointQuality.belongsTo(models.Point, { foreignKey: 'point_id' });
|
|
36
|
-
PointQuality.belongsTo(models.User, { foreignKey: 'user_id' });
|
|
37
|
-
};
|
|
38
|
-
return PointQuality;
|
|
39
|
-
};
|