@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,1137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var express = require("express");
|
|
3
|
-
var router = express.Router();
|
|
4
|
-
var models = require("../models/index.cjs");
|
|
5
|
-
var auth = require("../authorization.cjs");
|
|
6
|
-
var log = require("../utils/logger.cjs");
|
|
7
|
-
var toJson = require("../utils/to_json.cjs");
|
|
8
|
-
var async = require("async");
|
|
9
|
-
const ogs = require("open-graph-scraper");
|
|
10
|
-
var _ = require("lodash");
|
|
11
|
-
var queue = require("../active-citizen/workers/queue.cjs");
|
|
12
|
-
var changePointCounter = function (pointId, column, upDown, next) {
|
|
13
|
-
models.Point.findOne({
|
|
14
|
-
where: { id: pointId },
|
|
15
|
-
}).then(function (point) {
|
|
16
|
-
if (point && upDown === 1) {
|
|
17
|
-
point.increment(column).then(function () {
|
|
18
|
-
next();
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
else if (point && upDown === -1) {
|
|
22
|
-
point.decrement(column).then(function () {
|
|
23
|
-
next();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
next();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
var decrementOldPointQualityCountersIfNeeded = function (oldPointQualityValue, pointId, pointQuality, next) {
|
|
32
|
-
if (oldPointQualityValue) {
|
|
33
|
-
if (oldPointQualityValue > 0) {
|
|
34
|
-
changePointCounter(pointId, "counter_quality_up", -1, function () {
|
|
35
|
-
next();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else if (oldPointQualityValue < 0) {
|
|
39
|
-
changePointCounter(pointId, "counter_quality_down", -1, function () {
|
|
40
|
-
next();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
log.error("Strange state of pointQualities");
|
|
45
|
-
next();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
next();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
var sendPointOrError = function (res, point, context, user, error, errorStatus) {
|
|
53
|
-
if (error || !point) {
|
|
54
|
-
if (errorStatus == 404) {
|
|
55
|
-
log.warn("Point Not Found", {
|
|
56
|
-
context: context,
|
|
57
|
-
point: toJson(point),
|
|
58
|
-
user: toJson(user),
|
|
59
|
-
err: error,
|
|
60
|
-
errorStatus: 404,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
log.error("Point Error", {
|
|
65
|
-
context: context,
|
|
66
|
-
point: toJson(point),
|
|
67
|
-
user: toJson(user),
|
|
68
|
-
err: error,
|
|
69
|
-
errorStatus: errorStatus ? errorStatus : 500,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (errorStatus) {
|
|
73
|
-
res.sendStatus(errorStatus);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
res.sendStatus(500);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
res.send(point);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
var validateEmbedUrl = function (urlIn) {
|
|
84
|
-
var urlRegex = /((?:(http|https|Http|Https|rtsp|Rtsp):\/\/(?:(?:[a-zA-Z0-9\$\-\_\.\+\!\*\'\(\)\,\;\?\&\=]|(?:\%[a-fA-F0-9]{2})){1,64}(?:\:(?:[a-zA-Z0-9\$\-\_\.\+\!\*\'\(\)\,\;\?\&\=]|(?:\%[a-fA-F0-9]{2})){1,25})?\@)?)?((?:(?:[a-zA-Z0-9][a-zA-Z0-9\-]{0,64}\.)+(?:(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])|(?:biz|b[abdefghijmnorstvwyz])|(?:cat|com|coop|c[acdfghiklmnoruvxyz])|d[ejkmoz]|(?:edu|e[cegrstu])|f[ijkmor]|(?:gov|g[abdefghilmnpqrstuwy])|h[kmnrtu]|(?:info|int|i[delmnoqrst])|(?:jobs|j[emop])|k[eghimnrwyz]|l[abcikrstuvy]|(?:mil|mobi|museum|m[acdghklmnopqrstuvwxyz])|(?:name|net|n[acefgilopruz])|(?:org|om)|(?:pro|p[aefghklmnrstwy])|qa|r[eouw]|s[abcdeghijklmnortuvyz]|(?:tel|travel|t[cdfghjklmnoprtvwz])|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]))|(?:(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9])))(?:\:\d{1,5})?)(\/(?:(?:[a-zA-Z0-9\;\/\?\:\@\&\=\#\~\-\.\+\!\*\'\(\)\,\_])|(?:\%[a-fA-F0-9]{2}))*)?(?:\b|$)/gi;
|
|
85
|
-
var urls = urlRegex.exec(urlIn);
|
|
86
|
-
return urls != null && urls.length > 0;
|
|
87
|
-
};
|
|
88
|
-
var loadPointWithAll = function (pointId, callback) {
|
|
89
|
-
let outPoint;
|
|
90
|
-
models.Point.findOne({
|
|
91
|
-
where: {
|
|
92
|
-
id: pointId,
|
|
93
|
-
},
|
|
94
|
-
attributes: [
|
|
95
|
-
"id",
|
|
96
|
-
"name",
|
|
97
|
-
"content",
|
|
98
|
-
"status",
|
|
99
|
-
"value",
|
|
100
|
-
"counter_quality_up",
|
|
101
|
-
"counter_quality_down",
|
|
102
|
-
"counter_flags",
|
|
103
|
-
"embed_data",
|
|
104
|
-
"data",
|
|
105
|
-
"public_data",
|
|
106
|
-
"language",
|
|
107
|
-
"group_id",
|
|
108
|
-
"post_id",
|
|
109
|
-
"user_id",
|
|
110
|
-
],
|
|
111
|
-
order: [
|
|
112
|
-
[models.PointRevision, "created_at", "asc"],
|
|
113
|
-
[
|
|
114
|
-
models.User,
|
|
115
|
-
{ model: models.Image, as: "UserProfileImages" },
|
|
116
|
-
"created_at",
|
|
117
|
-
"asc",
|
|
118
|
-
],
|
|
119
|
-
[{ model: models.Audio, as: "PointAudios" }, "updated_at", "desc"],
|
|
120
|
-
],
|
|
121
|
-
include: [
|
|
122
|
-
{
|
|
123
|
-
model: models.User,
|
|
124
|
-
attributes: [
|
|
125
|
-
"id",
|
|
126
|
-
"name",
|
|
127
|
-
"email",
|
|
128
|
-
"facebook_id",
|
|
129
|
-
"twitter_id",
|
|
130
|
-
"google_id",
|
|
131
|
-
"github_id",
|
|
132
|
-
],
|
|
133
|
-
required: false,
|
|
134
|
-
include: [
|
|
135
|
-
{
|
|
136
|
-
model: models.Image,
|
|
137
|
-
as: "UserProfileImages",
|
|
138
|
-
required: false,
|
|
139
|
-
through: { attributes: [] }
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
model: models.PointRevision,
|
|
145
|
-
required: false,
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
model: models.PointQuality,
|
|
149
|
-
required: false,
|
|
150
|
-
include: [
|
|
151
|
-
{
|
|
152
|
-
model: models.User,
|
|
153
|
-
attributes: ["id", "name", "email"],
|
|
154
|
-
required: false,
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
model: models.Audio,
|
|
160
|
-
required: false,
|
|
161
|
-
attributes: ["id", "formats", "updated_at", "listenable"],
|
|
162
|
-
as: "PointAudios",
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
model: models.Post,
|
|
166
|
-
required: false,
|
|
167
|
-
attributes: ["id", "group_id"],
|
|
168
|
-
include: [
|
|
169
|
-
{
|
|
170
|
-
model: models.Group,
|
|
171
|
-
attributes: ["id", "configuration"],
|
|
172
|
-
required: false,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
})
|
|
178
|
-
.then(function (point) {
|
|
179
|
-
if (point) {
|
|
180
|
-
outPoint = point;
|
|
181
|
-
async.parallel([
|
|
182
|
-
(parallelCallback) => {
|
|
183
|
-
models.Point.getVideosForPoints([point.id], (error, videos) => {
|
|
184
|
-
if (error) {
|
|
185
|
-
parallelCallback(error);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
outPoint.setDataValue("PointVideos", videos);
|
|
189
|
-
outPoint.PointVideos = videos;
|
|
190
|
-
parallelCallback();
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
},
|
|
194
|
-
(parallelCallback) => {
|
|
195
|
-
models.Point.setOrganizationUsersForPoints([outPoint], (error) => {
|
|
196
|
-
parallelCallback(error);
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
], (error) => {
|
|
200
|
-
callback(error, outPoint);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
callback("Can't find point");
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
.catch(function (error) {
|
|
208
|
-
callback(error);
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
router.put("/:id/report", auth.can("vote on point"), function (req, res) {
|
|
212
|
-
models.Point.findOne({
|
|
213
|
-
where: {
|
|
214
|
-
id: req.params.id,
|
|
215
|
-
},
|
|
216
|
-
}).then(function (point) {
|
|
217
|
-
if (point) {
|
|
218
|
-
models.Post.findOne({
|
|
219
|
-
where: {
|
|
220
|
-
id: point.post_id,
|
|
221
|
-
},
|
|
222
|
-
include: [
|
|
223
|
-
{
|
|
224
|
-
model: models.Group,
|
|
225
|
-
required: true,
|
|
226
|
-
attributes: ["id"],
|
|
227
|
-
include: [
|
|
228
|
-
{
|
|
229
|
-
model: models.Community,
|
|
230
|
-
required: true,
|
|
231
|
-
attributes: ["id"],
|
|
232
|
-
include: [
|
|
233
|
-
{
|
|
234
|
-
model: models.Domain,
|
|
235
|
-
required: true,
|
|
236
|
-
attributes: ["id"],
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
})
|
|
244
|
-
.then(function (post) {
|
|
245
|
-
if (post) {
|
|
246
|
-
point.report(req, "user", post, function (error) {
|
|
247
|
-
if (error) {
|
|
248
|
-
log.error("Point Report Error", {
|
|
249
|
-
context: "report",
|
|
250
|
-
post: post ? toJson(post) : null,
|
|
251
|
-
user: toJson(req.user),
|
|
252
|
-
err: error,
|
|
253
|
-
});
|
|
254
|
-
res.sendStatus(500);
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
log.info("Point Report Created", {
|
|
258
|
-
postId: post ? post.id : -1,
|
|
259
|
-
userId: req.user ? req.user.id : -1,
|
|
260
|
-
});
|
|
261
|
-
res.sendStatus(200);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
log.error("Point Report", {
|
|
267
|
-
context: "report",
|
|
268
|
-
post: toJson(post),
|
|
269
|
-
user: toJson(req.user),
|
|
270
|
-
err: "Could not created post",
|
|
271
|
-
});
|
|
272
|
-
res.sendStatus(500);
|
|
273
|
-
}
|
|
274
|
-
})
|
|
275
|
-
.catch(function (error) {
|
|
276
|
-
log.error("Point Report", {
|
|
277
|
-
context: "report",
|
|
278
|
-
user: toJson(req.user),
|
|
279
|
-
err: error,
|
|
280
|
-
});
|
|
281
|
-
res.sendStatus(500);
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
res.sendStatus(404);
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
router.get("/:parentPointId/comments", auth.can("view point"), function (req, res) {
|
|
290
|
-
models.Point.findAll({
|
|
291
|
-
where: {
|
|
292
|
-
parent_point_id: req.params.parentPointId,
|
|
293
|
-
},
|
|
294
|
-
order: [
|
|
295
|
-
["created_at", "asc"],
|
|
296
|
-
[
|
|
297
|
-
models.PointRevision,
|
|
298
|
-
models.User,
|
|
299
|
-
{ model: models.Image, as: "UserProfileImages" },
|
|
300
|
-
"created_at",
|
|
301
|
-
"asc",
|
|
302
|
-
],
|
|
303
|
-
[models.PointRevision, "created_at", "asc"],
|
|
304
|
-
],
|
|
305
|
-
include: [
|
|
306
|
-
{
|
|
307
|
-
model: models.PointRevision,
|
|
308
|
-
include: [
|
|
309
|
-
{
|
|
310
|
-
model: models.User,
|
|
311
|
-
attributes: models.User.defaultAttributesWithSocialMediaPublic,
|
|
312
|
-
include: [
|
|
313
|
-
{
|
|
314
|
-
model: models.Image,
|
|
315
|
-
as: "UserProfileImages",
|
|
316
|
-
required: false,
|
|
317
|
-
through: { attributes: [] }
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
},
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
|
-
],
|
|
324
|
-
})
|
|
325
|
-
.then(function (comments) {
|
|
326
|
-
log.info("Point Comment for Parent Point", {
|
|
327
|
-
context: "comment",
|
|
328
|
-
user: req.user ? toJson(req.user.simple()) : null,
|
|
329
|
-
});
|
|
330
|
-
res.send(comments);
|
|
331
|
-
})
|
|
332
|
-
.catch(function (error) {
|
|
333
|
-
log.error("Could not get comments for parent point", {
|
|
334
|
-
err: error,
|
|
335
|
-
context: "comment",
|
|
336
|
-
user: req.user ? toJson(req.user.simple()) : null,
|
|
337
|
-
});
|
|
338
|
-
res.sendStatus(500);
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
router.get("/:parentPointId/commentsCount", auth.can("view point"), function (req, res) {
|
|
342
|
-
models.Point.count({
|
|
343
|
-
where: {
|
|
344
|
-
parent_point_id: req.params.parentPointId,
|
|
345
|
-
},
|
|
346
|
-
include: [
|
|
347
|
-
{
|
|
348
|
-
model: models.PointRevision,
|
|
349
|
-
include: [
|
|
350
|
-
{
|
|
351
|
-
model: models.User,
|
|
352
|
-
attributes: ["id", "name", "created_at"],
|
|
353
|
-
},
|
|
354
|
-
],
|
|
355
|
-
},
|
|
356
|
-
],
|
|
357
|
-
order: [["created_at", "asc"]],
|
|
358
|
-
})
|
|
359
|
-
.then(function (commentsCount) {
|
|
360
|
-
log.info("Point Comment Count for Parent Point", {
|
|
361
|
-
context: "comment",
|
|
362
|
-
user: req.user ? toJson(req.user.simple()) : null,
|
|
363
|
-
});
|
|
364
|
-
res.send({ count: commentsCount });
|
|
365
|
-
})
|
|
366
|
-
.catch(function (error) {
|
|
367
|
-
log.error("Could not get comments count for parent point", {
|
|
368
|
-
err: error,
|
|
369
|
-
context: "comment",
|
|
370
|
-
user: req.user ? toJson(req.user.simple()) : null,
|
|
371
|
-
});
|
|
372
|
-
res.sendStatus(500);
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
router.post("/:parentPointId/comment", auth.isLoggedInNoAnonymousCheck, auth.can("add to point"), function (req, res) {
|
|
376
|
-
models.Point.createComment(req, { parent_point_id: req.params.parentPointId, comment: req.body.comment }, function (error) {
|
|
377
|
-
if (error) {
|
|
378
|
-
log.error("Could not save comment point on parent point", {
|
|
379
|
-
err: error,
|
|
380
|
-
context: "comment",
|
|
381
|
-
user: toJson(req.user.simple()),
|
|
382
|
-
});
|
|
383
|
-
res.sendStatus(500);
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
log.info("Point Comment Created on Parent Point", {
|
|
387
|
-
context: "news_story",
|
|
388
|
-
user: toJson(req.user.simple()),
|
|
389
|
-
});
|
|
390
|
-
res.sendStatus(200);
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
router.put("/:pointId", auth.can("edit point"), function (req, res) {
|
|
395
|
-
if (!req.body.content) {
|
|
396
|
-
req.body.content = "";
|
|
397
|
-
}
|
|
398
|
-
var point = models.Point.findOne({
|
|
399
|
-
where: {
|
|
400
|
-
id: req.params.pointId,
|
|
401
|
-
},
|
|
402
|
-
})
|
|
403
|
-
.then(function (point) {
|
|
404
|
-
var maxNumberOfPointsBeforeEditFrozen = 5;
|
|
405
|
-
if (point.counter_quality_up + point.counter_quality_down <=
|
|
406
|
-
maxNumberOfPointsBeforeEditFrozen) {
|
|
407
|
-
var pointRevision = models.PointRevision.build({
|
|
408
|
-
group_id: point.group_id,
|
|
409
|
-
post_id: point.post_id,
|
|
410
|
-
content: req.body.content,
|
|
411
|
-
user_id: req.user.id,
|
|
412
|
-
status: point.status,
|
|
413
|
-
value: point.value,
|
|
414
|
-
point_id: point.id,
|
|
415
|
-
user_agent: req.useragent.source,
|
|
416
|
-
ip_address: req.clientIp,
|
|
417
|
-
});
|
|
418
|
-
pointRevision.save().then(function () {
|
|
419
|
-
log.info("PointRevision Created", {
|
|
420
|
-
pointRevisionId: pointRevision ? pointRevision.id : -1,
|
|
421
|
-
context: "create",
|
|
422
|
-
userId: req.user ? req.user.id : -1,
|
|
423
|
-
});
|
|
424
|
-
queue.add("process-similarities", { type: "update-collection", pointId: point.id }, "low");
|
|
425
|
-
models.AcActivity.createActivity({
|
|
426
|
-
type: "activity.point.edited",
|
|
427
|
-
userId: point.user_id,
|
|
428
|
-
domainId: req.ypDomain.id,
|
|
429
|
-
// communityId: req.ypCommunity ? req.ypCommunity.id : null,
|
|
430
|
-
groupId: point.group_id,
|
|
431
|
-
postId: point.post_id,
|
|
432
|
-
pointId: point.id,
|
|
433
|
-
access: models.AcActivity.ACCESS_PUBLIC,
|
|
434
|
-
}, function (error) {
|
|
435
|
-
loadPointWithAll(point.id, function (error, loadedPoint) {
|
|
436
|
-
if (error) {
|
|
437
|
-
log.error("Could not reload point point", {
|
|
438
|
-
err: error,
|
|
439
|
-
context: "createPoint",
|
|
440
|
-
user: toJson(req.user.simple()),
|
|
441
|
-
});
|
|
442
|
-
res.sendStatus(500);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
if (loadedPoint.PointRevisions &&
|
|
446
|
-
loadedPoint.PointRevisions.length > 0 &&
|
|
447
|
-
loadedPoint.PointRevisions[loadedPoint.PointRevisions.length - 1].content !== "") {
|
|
448
|
-
log.info("process-moderation point toxicity after create point");
|
|
449
|
-
queue.add("process-moderation", {
|
|
450
|
-
type: "estimate-point-toxicity",
|
|
451
|
-
pointId: loadedPoint.id,
|
|
452
|
-
}, "high");
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
log.info("No process-moderation toxicity for empty text on point");
|
|
456
|
-
}
|
|
457
|
-
res.send(loadedPoint);
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
log.error("Trying to edit point with too many point qualities", {
|
|
465
|
-
point: toJson(point),
|
|
466
|
-
context: "edit",
|
|
467
|
-
user: toJson(req.user),
|
|
468
|
-
});
|
|
469
|
-
res.sendStatus(401);
|
|
470
|
-
}
|
|
471
|
-
})
|
|
472
|
-
.catch(function (error) {
|
|
473
|
-
sendPointOrError(res, null, "edit", req.user, error);
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
router.get("/:id/translatedText", auth.can("view point"), function (req, res) {
|
|
477
|
-
if (req.query.textType.indexOf("point") > -1) {
|
|
478
|
-
models.Point.findOne({
|
|
479
|
-
where: {
|
|
480
|
-
id: req.params.id,
|
|
481
|
-
},
|
|
482
|
-
order: [[models.PointRevision, "created_at", "asc"]],
|
|
483
|
-
attributes: ["id", "public_data"],
|
|
484
|
-
include: [
|
|
485
|
-
{
|
|
486
|
-
model: models.PointRevision,
|
|
487
|
-
attributes: ["id", "content"],
|
|
488
|
-
},
|
|
489
|
-
],
|
|
490
|
-
})
|
|
491
|
-
.then(function (point) {
|
|
492
|
-
if (point) {
|
|
493
|
-
models.AcTranslationCache.getTranslation(req, point, function (error, translation) {
|
|
494
|
-
if (error) {
|
|
495
|
-
sendPointOrError(res, req.params.id, "translated", req.user, error, 500);
|
|
496
|
-
}
|
|
497
|
-
else {
|
|
498
|
-
res.send(translation);
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
sendPointOrError(res, req.params.id, "translated", req.user, "Not found", 404);
|
|
504
|
-
}
|
|
505
|
-
})
|
|
506
|
-
.catch(function (error) {
|
|
507
|
-
sendPointOrError(res, null, "translated", req.user, error);
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
sendPointOrError(res, req.params.id, "translated", req.user, "Wrong textType", 401);
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
router.get("/:id/videoTranscriptStatus", auth.can("view point"), function (req, res) {
|
|
515
|
-
loadPointWithAll(req.params.id, (error, point) => {
|
|
516
|
-
if (error) {
|
|
517
|
-
sendPointOrError(res, req.params.id, "videoTranscriptStatus", req.user, error, 500);
|
|
518
|
-
}
|
|
519
|
-
else if (point.PointVideos && point.PointVideos.length > 0) {
|
|
520
|
-
models.Video.findOne({
|
|
521
|
-
where: {
|
|
522
|
-
id: point.PointVideos[0].id,
|
|
523
|
-
},
|
|
524
|
-
})
|
|
525
|
-
.then((video) => {
|
|
526
|
-
if (video.meta.transcript && video.meta.transcript.text) {
|
|
527
|
-
point
|
|
528
|
-
.save()
|
|
529
|
-
.then((savedPoint) => {
|
|
530
|
-
var pointRevision = models.PointRevision.build({
|
|
531
|
-
group_id: savedPoint.group_id,
|
|
532
|
-
post_id: savedPoint.post_id,
|
|
533
|
-
content: video.meta.transcript.text,
|
|
534
|
-
user_id: req.user.id,
|
|
535
|
-
status: savedPoint.status,
|
|
536
|
-
value: savedPoint.value,
|
|
537
|
-
point_id: savedPoint.id,
|
|
538
|
-
user_agent: req.useragent.source,
|
|
539
|
-
ip_address: req.clientIp,
|
|
540
|
-
});
|
|
541
|
-
pointRevision
|
|
542
|
-
.save()
|
|
543
|
-
.then(() => {
|
|
544
|
-
loadPointWithAll(point.id, function (error, loadedPoint) {
|
|
545
|
-
if (error) {
|
|
546
|
-
log.error("Could not reload point point", {
|
|
547
|
-
err: error,
|
|
548
|
-
context: "createPoint",
|
|
549
|
-
user: toJson(req.user.simple()),
|
|
550
|
-
});
|
|
551
|
-
res.sendStatus(500);
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
log.info("process-moderation point toxicity after video transcript");
|
|
555
|
-
queue.add("process-moderation", {
|
|
556
|
-
type: "estimate-point-toxicity",
|
|
557
|
-
pointId: loadedPoint.id,
|
|
558
|
-
}, "high");
|
|
559
|
-
res.send({ point: loadedPoint });
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
})
|
|
563
|
-
.catch((error) => {
|
|
564
|
-
sendPointOrError(res, req.params.id, "videoTranscriptStatus", req.user, error, 500);
|
|
565
|
-
});
|
|
566
|
-
})
|
|
567
|
-
.catch((error) => {
|
|
568
|
-
sendPointOrError(res, req.params.id, "videoTranscriptStatus", req.user, error, 500);
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
else if (video.meta.transcript && video.meta.transcript.error) {
|
|
572
|
-
res.send({ error: video.meta.transcript.error });
|
|
573
|
-
}
|
|
574
|
-
else {
|
|
575
|
-
res.send({ inProgress: true });
|
|
576
|
-
}
|
|
577
|
-
})
|
|
578
|
-
.catch((error) => {
|
|
579
|
-
sendPointOrError(res, req.params.id, "videoTranscriptStatus", req.user, error, 500);
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
sendPointOrError(res, req.params.id, "videoTranscriptStatus", req.user, "No video for videoTranscriptStatus", 500);
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
router.get("/:id/audioTranscriptStatus", auth.can("view point"), function (req, res) {
|
|
588
|
-
loadPointWithAll(req.params.id, (error, point) => {
|
|
589
|
-
if (error) {
|
|
590
|
-
sendPointOrError(res, req.params.id, "audioTranscriptStatus", req.user, error, 500);
|
|
591
|
-
}
|
|
592
|
-
else if (point.PointAudios && point.PointAudios.length > 0) {
|
|
593
|
-
models.Audio.findOne({
|
|
594
|
-
where: {
|
|
595
|
-
id: point.PointAudios[0].id,
|
|
596
|
-
},
|
|
597
|
-
})
|
|
598
|
-
.then((audio) => {
|
|
599
|
-
if (audio.meta.transcript && audio.meta.transcript.text) {
|
|
600
|
-
point
|
|
601
|
-
.save()
|
|
602
|
-
.then((savedPoint) => {
|
|
603
|
-
var pointRevision = models.PointRevision.build({
|
|
604
|
-
group_id: savedPoint.group_id,
|
|
605
|
-
post_id: savedPoint.post_id,
|
|
606
|
-
content: audio.meta.transcript.text,
|
|
607
|
-
user_id: req.user.id,
|
|
608
|
-
status: savedPoint.status,
|
|
609
|
-
value: savedPoint.value,
|
|
610
|
-
point_id: savedPoint.id,
|
|
611
|
-
user_agent: req.useragent.source,
|
|
612
|
-
ip_address: req.clientIp,
|
|
613
|
-
});
|
|
614
|
-
pointRevision
|
|
615
|
-
.save()
|
|
616
|
-
.then(() => {
|
|
617
|
-
loadPointWithAll(point.id, function (error, loadedPoint) {
|
|
618
|
-
if (error) {
|
|
619
|
-
log.error("Could not reload point", {
|
|
620
|
-
err: error,
|
|
621
|
-
context: "createPoint",
|
|
622
|
-
user: toJson(req.user.simple()),
|
|
623
|
-
});
|
|
624
|
-
res.sendStatus(500);
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
log.info("process-moderation point toxicity after audio transcript");
|
|
628
|
-
queue.add("process-moderation", {
|
|
629
|
-
type: "estimate-point-toxicity",
|
|
630
|
-
pointId: loadedPoint.id,
|
|
631
|
-
}, "high");
|
|
632
|
-
res.send({ point: loadedPoint });
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
})
|
|
636
|
-
.catch((error) => {
|
|
637
|
-
sendPointOrError(res, req.params.id, "audioTranscriptStatus", req.user, error, 500);
|
|
638
|
-
});
|
|
639
|
-
})
|
|
640
|
-
.catch((error) => {
|
|
641
|
-
sendPointOrError(res, req.params.id, "audioTranscriptStatus", req.user, error, 500);
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
else if (audio.meta.transcript && audio.meta.transcript.error) {
|
|
645
|
-
res.send({ error: audio.meta.transcript.error });
|
|
646
|
-
}
|
|
647
|
-
else {
|
|
648
|
-
res.send({ inProgress: true });
|
|
649
|
-
}
|
|
650
|
-
})
|
|
651
|
-
.catch((error) => {
|
|
652
|
-
sendPointOrError(res, req.params.id, "audioTranscriptStatus", req.user, error, 500);
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
else {
|
|
656
|
-
sendPointOrError(res, req.params.id, "audioTranscriptStatus", req.user, "No audio for audioTranscriptStatus", 500);
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
router.post("/:groupId", auth.can("create point"), function (req, res) {
|
|
661
|
-
log.info("In POST createPoint");
|
|
662
|
-
if (!req.body.content) {
|
|
663
|
-
req.body.content = "";
|
|
664
|
-
}
|
|
665
|
-
var point = models.Point.build({
|
|
666
|
-
group_id: req.params.groupId,
|
|
667
|
-
post_id: req.body.postId,
|
|
668
|
-
content: req.body.content,
|
|
669
|
-
value: req.body.value,
|
|
670
|
-
user_id: req.user.id,
|
|
671
|
-
status: "published",
|
|
672
|
-
user_agent: req.useragent.source,
|
|
673
|
-
ip_address: req.clientIp,
|
|
674
|
-
data: {
|
|
675
|
-
browserId: req.body.pointBaseId,
|
|
676
|
-
browserFingerprint: req.body.pointValCode,
|
|
677
|
-
browserFingerprintConfidence: req.body.pointConf,
|
|
678
|
-
originalQueryString: req.body.originalQueryString,
|
|
679
|
-
userLocale: req.body.userLocale,
|
|
680
|
-
userAutoTranslate: req.body.userAutoTranslate,
|
|
681
|
-
referrer: req.body.referrer,
|
|
682
|
-
url: req.body.url,
|
|
683
|
-
screen_width: req.body.screen_width,
|
|
684
|
-
},
|
|
685
|
-
});
|
|
686
|
-
point
|
|
687
|
-
.save()
|
|
688
|
-
.then(function () {
|
|
689
|
-
log.info("Point Created", {
|
|
690
|
-
pointId: point ? point.id : -1,
|
|
691
|
-
context: "create",
|
|
692
|
-
userId: req.user ? req.user.id : -1,
|
|
693
|
-
});
|
|
694
|
-
async.parallel([
|
|
695
|
-
(parallelCallback) => {
|
|
696
|
-
var pointRevision = models.PointRevision.build({
|
|
697
|
-
group_id: point.group_id,
|
|
698
|
-
post_id: point.post_id,
|
|
699
|
-
content: point.content,
|
|
700
|
-
user_id: req.user.id,
|
|
701
|
-
status: point.status,
|
|
702
|
-
value: point.value,
|
|
703
|
-
point_id: point.id,
|
|
704
|
-
user_agent: req.useragent.source,
|
|
705
|
-
ip_address: req.clientIp,
|
|
706
|
-
});
|
|
707
|
-
pointRevision.save().then(function () {
|
|
708
|
-
log.info("PointRevision Created", {
|
|
709
|
-
pointRevisionId: pointRevision ? pointRevision.id : -1,
|
|
710
|
-
context: "create",
|
|
711
|
-
userId: req.user ? req.user.id : -1,
|
|
712
|
-
});
|
|
713
|
-
parallelCallback();
|
|
714
|
-
});
|
|
715
|
-
},
|
|
716
|
-
(parallelCallback) => {
|
|
717
|
-
models.AcActivity.createActivity({
|
|
718
|
-
type: "activity.point.new",
|
|
719
|
-
userId: point.user_id,
|
|
720
|
-
domainId: req.ypDomain.id,
|
|
721
|
-
// communityId: req.ypCommunity ? req.ypCommunity.id : null,
|
|
722
|
-
groupId: point.group_id,
|
|
723
|
-
postId: point.post_id,
|
|
724
|
-
pointId: point.id,
|
|
725
|
-
access: models.AcActivity.ACCESS_PUBLIC,
|
|
726
|
-
}, function (error) {
|
|
727
|
-
parallelCallback(error);
|
|
728
|
-
});
|
|
729
|
-
},
|
|
730
|
-
(parallelCallback) => {
|
|
731
|
-
models.Group.addUserToGroupIfNeeded(point.group_id, req, function () {
|
|
732
|
-
parallelCallback();
|
|
733
|
-
});
|
|
734
|
-
},
|
|
735
|
-
(parallelCallback) => {
|
|
736
|
-
models.Post.findOne({
|
|
737
|
-
where: { id: point.post_id },
|
|
738
|
-
attributes: ["id", "counter_points", "group_id"],
|
|
739
|
-
}).then(function (post) {
|
|
740
|
-
if (post) {
|
|
741
|
-
post.updateAllExternalCounters(req, "up", "counter_points", function () {
|
|
742
|
-
post.increment("counter_points");
|
|
743
|
-
parallelCallback();
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
parallelCallback("Post not found for point");
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
},
|
|
751
|
-
(parallelCallback) => {
|
|
752
|
-
if (req.body.videoId) {
|
|
753
|
-
models.Video.completeUploadAndAddToPoint(req, res, { pointId: point.id, videoId: req.body.videoId }, (error) => {
|
|
754
|
-
if (error) {
|
|
755
|
-
parallelCallback(error);
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
if (process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON) {
|
|
759
|
-
const workPackage = {
|
|
760
|
-
browserLanguage: req.headers["accept-language"]
|
|
761
|
-
? req.headers["accept-language"].split(",")[0]
|
|
762
|
-
: "en-US",
|
|
763
|
-
appLanguage: req.body.appLanguage,
|
|
764
|
-
videoId: req.body.videoId,
|
|
765
|
-
type: "create-video-transcript",
|
|
766
|
-
};
|
|
767
|
-
queue.add("process-voice-to-text", workPackage, "high");
|
|
768
|
-
}
|
|
769
|
-
parallelCallback();
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
parallelCallback();
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
(parallelCallback) => {
|
|
778
|
-
if (req.body.audioId) {
|
|
779
|
-
models.Audio.completeUploadAndAddToPoint(req, res, { pointId: point.id, audioId: req.body.audioId }, (error) => {
|
|
780
|
-
if (error) {
|
|
781
|
-
parallelCallback(error);
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
if (process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON) {
|
|
785
|
-
const workPackage = {
|
|
786
|
-
browserLanguage: req.headers["accept-language"]
|
|
787
|
-
? req.headers["accept-language"].split(",")[0]
|
|
788
|
-
: "en-US",
|
|
789
|
-
appLanguage: req.body.appLanguage,
|
|
790
|
-
audioId: req.body.audioId,
|
|
791
|
-
type: "create-audio-transcript",
|
|
792
|
-
};
|
|
793
|
-
queue.add("process-voice-to-text", workPackage, "high");
|
|
794
|
-
}
|
|
795
|
-
parallelCallback();
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
else {
|
|
800
|
-
parallelCallback();
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
], (error) => {
|
|
804
|
-
if (error) {
|
|
805
|
-
log.error(error);
|
|
806
|
-
res.sendStatus(500);
|
|
807
|
-
}
|
|
808
|
-
else {
|
|
809
|
-
if (point.content && point.content !== "") {
|
|
810
|
-
log.info("process-moderation point toxicity after create point");
|
|
811
|
-
queue.add("process-moderation", { type: "estimate-point-toxicity", pointId: point.id }, "high");
|
|
812
|
-
queue.add("process-similarities", { type: "update-collection", pointId: point.id }, "low");
|
|
813
|
-
}
|
|
814
|
-
else {
|
|
815
|
-
log.info("No process-moderation toxicity for empty text on point");
|
|
816
|
-
}
|
|
817
|
-
queue.add("process-moderation", { type: "point-review-and-annotate-images", pointId: point.id }, "medium");
|
|
818
|
-
loadPointWithAll(point.id, function (error, loadedPoint) {
|
|
819
|
-
if (error) {
|
|
820
|
-
log.error("Could not reload point point", {
|
|
821
|
-
err: error,
|
|
822
|
-
context: "createPoint",
|
|
823
|
-
user: toJson(req.user.simple()),
|
|
824
|
-
});
|
|
825
|
-
res.sendStatus(500);
|
|
826
|
-
}
|
|
827
|
-
else {
|
|
828
|
-
const newPointRedisKey = `newUserPoint_${req.user.id}`;
|
|
829
|
-
req.redisClient.setEx(newPointRedisKey, 30, JSON.stringify({}));
|
|
830
|
-
res.send(loadedPoint);
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
})
|
|
836
|
-
.catch(function (error) {
|
|
837
|
-
sendPointOrError(res, null, "create", req.user, error);
|
|
838
|
-
});
|
|
839
|
-
});
|
|
840
|
-
router.delete("/:id", auth.can("delete point"), function (req, res) {
|
|
841
|
-
models.Point.findOne({
|
|
842
|
-
where: { id: req.params.id },
|
|
843
|
-
include: [
|
|
844
|
-
{
|
|
845
|
-
model: models.Post,
|
|
846
|
-
required: false,
|
|
847
|
-
},
|
|
848
|
-
],
|
|
849
|
-
})
|
|
850
|
-
.then(function (point) {
|
|
851
|
-
point.deleted = true;
|
|
852
|
-
point.save().then(function () {
|
|
853
|
-
log.info("Point Deleted", {
|
|
854
|
-
point: toJson(point),
|
|
855
|
-
context: "delete",
|
|
856
|
-
user: toJson(req.user),
|
|
857
|
-
});
|
|
858
|
-
queue.add("process-similarities", { type: "update-collection", pointId: point.id }, "low");
|
|
859
|
-
queue.add("process-deletion", {
|
|
860
|
-
type: "delete-point-content",
|
|
861
|
-
pointId: point.id,
|
|
862
|
-
userId: req.user.id,
|
|
863
|
-
}, "critical");
|
|
864
|
-
if (point.Post) {
|
|
865
|
-
point.Post.updateAllExternalCounters(req, "down", "counter_points", function () {
|
|
866
|
-
point.Post.decrement("counter_points");
|
|
867
|
-
res.sendStatus(200);
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
else {
|
|
871
|
-
res.sendStatus(200);
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
})
|
|
875
|
-
.catch(function (error) {
|
|
876
|
-
sendPointOrError(res, null, "delete", req.user, error);
|
|
877
|
-
});
|
|
878
|
-
});
|
|
879
|
-
router.post("/:id/pointQuality", auth.can("vote on point"), function (req, res) {
|
|
880
|
-
var point, post;
|
|
881
|
-
models.PointQuality.findOne({
|
|
882
|
-
where: { point_id: req.params.id, user_id: req.user.id },
|
|
883
|
-
include: [
|
|
884
|
-
{
|
|
885
|
-
model: models.Point,
|
|
886
|
-
attributes: ["id", "group_id", "post_id"],
|
|
887
|
-
include: [
|
|
888
|
-
{
|
|
889
|
-
model: models.Post,
|
|
890
|
-
attributes: ["id", "group_id"],
|
|
891
|
-
required: false,
|
|
892
|
-
},
|
|
893
|
-
],
|
|
894
|
-
},
|
|
895
|
-
],
|
|
896
|
-
}).then(function (pointQuality) {
|
|
897
|
-
var oldPointQualityValue;
|
|
898
|
-
if (pointQuality) {
|
|
899
|
-
point = pointQuality.Point;
|
|
900
|
-
if (pointQuality.value > 0)
|
|
901
|
-
oldPointQualityValue = 1;
|
|
902
|
-
else if (pointQuality.value < 0)
|
|
903
|
-
oldPointQualityValue = -1;
|
|
904
|
-
pointQuality.value = req.body.value;
|
|
905
|
-
pointQuality.status = "active";
|
|
906
|
-
pointQuality.set("data", {
|
|
907
|
-
browserId: req.body.qualityBaseId,
|
|
908
|
-
browserFingerprint: req.body.qualityValCode,
|
|
909
|
-
browserFingerprintConfidence: req.body.qualityConf,
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
else {
|
|
913
|
-
pointQuality = models.PointQuality.build({
|
|
914
|
-
point_id: req.params.id,
|
|
915
|
-
value: req.body.value,
|
|
916
|
-
user_id: req.user.id,
|
|
917
|
-
data: {
|
|
918
|
-
browserId: req.body.qualityBaseId,
|
|
919
|
-
browserFingerprint: req.body.qualityValCode,
|
|
920
|
-
browserFingerprintConfidence: req.body.qualityConf,
|
|
921
|
-
},
|
|
922
|
-
status: "active",
|
|
923
|
-
user_agent: req.useragent.source,
|
|
924
|
-
ip_address: req.clientIp,
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
pointQuality.save().then(function () {
|
|
928
|
-
log.info("PointQuality Created or Updated", {
|
|
929
|
-
pointQualityId: pointQuality ? pointQuality.id : -1,
|
|
930
|
-
userId: req.user ? req.user.id : -1,
|
|
931
|
-
});
|
|
932
|
-
async.series([
|
|
933
|
-
function (seriesCallback) {
|
|
934
|
-
if (point) {
|
|
935
|
-
seriesCallback();
|
|
936
|
-
}
|
|
937
|
-
else {
|
|
938
|
-
models.Point.findOne({
|
|
939
|
-
where: { id: pointQuality.point_id },
|
|
940
|
-
attributes: ["id", "post_id", "group_id"],
|
|
941
|
-
}).then(function (results) {
|
|
942
|
-
if (results) {
|
|
943
|
-
point = results;
|
|
944
|
-
seriesCallback();
|
|
945
|
-
}
|
|
946
|
-
else {
|
|
947
|
-
seriesCallback("Can't find point");
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
},
|
|
952
|
-
function (seriesCallback) {
|
|
953
|
-
models.AcActivity.createActivity({
|
|
954
|
-
type: pointQuality.value > 0
|
|
955
|
-
? "activity.point.helpful.new"
|
|
956
|
-
: "activity.point.unhelpful.new",
|
|
957
|
-
userId: pointQuality.user_id,
|
|
958
|
-
domainId: req.ypDomain.id,
|
|
959
|
-
// communityId: req.ypCommunity ? req.ypCommunity.id : null,
|
|
960
|
-
pointQualityId: pointQuality.id,
|
|
961
|
-
groupId: point.group_id,
|
|
962
|
-
postId: point.post_id,
|
|
963
|
-
pointId: point.id,
|
|
964
|
-
access: models.AcActivity.ACCESS_PUBLIC,
|
|
965
|
-
}, function (error) {
|
|
966
|
-
seriesCallback(error);
|
|
967
|
-
});
|
|
968
|
-
},
|
|
969
|
-
function (seriesCallback) {
|
|
970
|
-
if (point && point.group_id) {
|
|
971
|
-
models.Group.addUserToGroupIfNeeded(point.group_id, req, function () {
|
|
972
|
-
seriesCallback();
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
else {
|
|
976
|
-
seriesCallback();
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
], function (error) {
|
|
980
|
-
if (error) {
|
|
981
|
-
log.error("Point Quality Error", {
|
|
982
|
-
context: "create",
|
|
983
|
-
pointQuality: toJson(pointQuality),
|
|
984
|
-
user: toJson(req.user),
|
|
985
|
-
err: error,
|
|
986
|
-
errorStatus: 500,
|
|
987
|
-
});
|
|
988
|
-
res.sendStatus(500);
|
|
989
|
-
}
|
|
990
|
-
else {
|
|
991
|
-
decrementOldPointQualityCountersIfNeeded(oldPointQualityValue, req.params.id, pointQuality, function () {
|
|
992
|
-
if (pointQuality.value > 0) {
|
|
993
|
-
changePointCounter(req.params.id, "counter_quality_up", 1, function () {
|
|
994
|
-
res.send({
|
|
995
|
-
pointQuality: pointQuality,
|
|
996
|
-
oldPointQualityValue: oldPointQualityValue,
|
|
997
|
-
});
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
else if (pointQuality.value < 0) {
|
|
1001
|
-
changePointCounter(req.params.id, "counter_quality_down", 1, function () {
|
|
1002
|
-
res.send({
|
|
1003
|
-
pointQuality: pointQuality,
|
|
1004
|
-
oldPointQualityValue: oldPointQualityValue,
|
|
1005
|
-
});
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
else {
|
|
1009
|
-
log.error("PointQuality Error", {
|
|
1010
|
-
pointQuality: toJson(pointQuality),
|
|
1011
|
-
context: "createOrUpdate",
|
|
1012
|
-
user: toJson(req.user),
|
|
1013
|
-
});
|
|
1014
|
-
res.status(500);
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
});
|
|
1021
|
-
});
|
|
1022
|
-
router.delete("/:id/pointQuality", auth.can("vote on point"), function (req, res) {
|
|
1023
|
-
models.PointQuality.findOne({
|
|
1024
|
-
where: { point_id: req.params.id, user_id: req.user.id },
|
|
1025
|
-
}).then(function (pointQuality) {
|
|
1026
|
-
if (pointQuality) {
|
|
1027
|
-
var oldPointQualityValue;
|
|
1028
|
-
if (pointQuality.value > 0)
|
|
1029
|
-
oldPointQualityValue = 1;
|
|
1030
|
-
else if (pointQuality.value < 0)
|
|
1031
|
-
oldPointQualityValue = -1;
|
|
1032
|
-
pointQuality.value = 0;
|
|
1033
|
-
//pointQuality.deleted = true;
|
|
1034
|
-
pointQuality.save().then(function () {
|
|
1035
|
-
log.info("PointQuality Deleted", {
|
|
1036
|
-
pointQualityId: pointQuality ? pointQuality.id : -1,
|
|
1037
|
-
userId: req.user ? req.user.id : -1,
|
|
1038
|
-
});
|
|
1039
|
-
if (oldPointQualityValue > 0) {
|
|
1040
|
-
changePointCounter(req.params.id, "counter_quality_up", -1, function () {
|
|
1041
|
-
res.status(200).send({
|
|
1042
|
-
pointQuality: pointQuality,
|
|
1043
|
-
oldPointQualityValue: oldPointQualityValue,
|
|
1044
|
-
});
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
else if (oldPointQualityValue < 0) {
|
|
1048
|
-
changePointCounter(req.params.id, "counter_quality_down", -1, function () {
|
|
1049
|
-
res.status(200).send({
|
|
1050
|
-
pointQuality: pointQuality,
|
|
1051
|
-
oldPointQualityValue: oldPointQualityValue,
|
|
1052
|
-
});
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
else {
|
|
1056
|
-
console.error("Strange state of pointQualities");
|
|
1057
|
-
res.status(200).send({
|
|
1058
|
-
pointQuality: pointQuality,
|
|
1059
|
-
oldPointQualityValue: oldPointQualityValue,
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
else {
|
|
1065
|
-
log.error("PointQuality Not Found", {
|
|
1066
|
-
pointQuality: toJson(pointQuality),
|
|
1067
|
-
context: "delete",
|
|
1068
|
-
user: toJson(req.user),
|
|
1069
|
-
});
|
|
1070
|
-
res.sendStatus(404);
|
|
1071
|
-
}
|
|
1072
|
-
});
|
|
1073
|
-
});
|
|
1074
|
-
const translateToObsFormat = (json) => {
|
|
1075
|
-
return [
|
|
1076
|
-
{
|
|
1077
|
-
url: json.ogUrl,
|
|
1078
|
-
type: json.ogType,
|
|
1079
|
-
title: json.ogTitle,
|
|
1080
|
-
version: "1.0",
|
|
1081
|
-
description: json.ogDescription,
|
|
1082
|
-
provider_url: json.ogUrl,
|
|
1083
|
-
request_url: json.requestUrl,
|
|
1084
|
-
provider_name: json.ogSiteName,
|
|
1085
|
-
thumbnail_url: json.ogImage ? json.ogImage[0].url : "",
|
|
1086
|
-
thumbnail_width: json.ogImage ? json.ogImage[0].width : "",
|
|
1087
|
-
thumbnail_height: json.ogImage ? json.ogImage[0].height : "",
|
|
1088
|
-
},
|
|
1089
|
-
];
|
|
1090
|
-
};
|
|
1091
|
-
router.get("/url_preview", auth.isLoggedInNoAnonymousCheck, function (req, res) {
|
|
1092
|
-
if (req.query.url && validateEmbedUrl(req.query.url)) {
|
|
1093
|
-
log.info("Before ogs", { url: req.query.url });
|
|
1094
|
-
const userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36";
|
|
1095
|
-
ogs({
|
|
1096
|
-
url: req.query.url,
|
|
1097
|
-
fetchOptions: { headers: { "user-agent": userAgent } },
|
|
1098
|
-
}).then((data) => {
|
|
1099
|
-
const { error, html, result, response } = data;
|
|
1100
|
-
log.info("After ogs", { url: req.query.url });
|
|
1101
|
-
if (error && result && result.error === "Page not found") {
|
|
1102
|
-
res.sendStatus(404);
|
|
1103
|
-
}
|
|
1104
|
-
else if (error) {
|
|
1105
|
-
log.error("Open graph not working", {
|
|
1106
|
-
err: error,
|
|
1107
|
-
url: req.query.url,
|
|
1108
|
-
context: "url_preview"
|
|
1109
|
-
});
|
|
1110
|
-
res.sendStatus(500);
|
|
1111
|
-
}
|
|
1112
|
-
else {
|
|
1113
|
-
log.info("Before translateToObsFormat", {
|
|
1114
|
-
url: req.query.url,
|
|
1115
|
-
result: result,
|
|
1116
|
-
});
|
|
1117
|
-
res.send(translateToObsFormat(result));
|
|
1118
|
-
}
|
|
1119
|
-
}).catch((error) => {
|
|
1120
|
-
log.error("Open graph not working", {
|
|
1121
|
-
err: error,
|
|
1122
|
-
url: req.query.url,
|
|
1123
|
-
context: "url_preview"
|
|
1124
|
-
});
|
|
1125
|
-
res.send([{}]);
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
log.error("Url not found or not valid", {
|
|
1130
|
-
url: req.params.url,
|
|
1131
|
-
context: "url_preview",
|
|
1132
|
-
user: toJson(req.user),
|
|
1133
|
-
});
|
|
1134
|
-
res.sendStatus(404);
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
module.exports = router;
|