@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,1341 +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 _ = require('lodash');
|
|
9
|
-
var async = require('async');
|
|
10
|
-
var queue = require('../active-citizen/workers/queue.cjs');
|
|
11
|
-
var performSingleModerationAction = require('../active-citizen/engine/moderation/process_moderation_items.cjs').performSingleModerationAction;
|
|
12
|
-
const getAllModeratedItemsByDomain = require('../active-citizen/engine/moderation/get_moderation_items.cjs').getAllModeratedItemsByDomain;
|
|
13
|
-
const getLoginsExportDataForDomain = require('../utils/export_utils.cjs').getLoginsExportDataForDomain;
|
|
14
|
-
var sanitizeFilename = require("sanitize-filename");
|
|
15
|
-
var moment = require('moment');
|
|
16
|
-
const { plausibleStatsProxy } = require("../active-citizen/engine/analytics/plausible/manager.cjs");
|
|
17
|
-
const { countAllModeratedItemsByDomain } = require("../active-citizen/engine/moderation/get_moderation_items.cjs");
|
|
18
|
-
const { isValidDbId } = require("../utils/is_valid_db_id.cjs");
|
|
19
|
-
const getFromAnalyticsApi = require('../active-citizen/engine/analytics/manager.cjs').getFromAnalyticsApi;
|
|
20
|
-
const triggerSimilaritiesTraining = require('../active-citizen/engine/analytics/manager.cjs').triggerSimilaritiesTraining;
|
|
21
|
-
const sendBackAnalyticsResultsOrError = require('../active-citizen/engine/analytics/manager.cjs').sendBackAnalyticsResultsOrError;
|
|
22
|
-
const countModelRowsByTimePeriod = require('../active-citizen/engine/analytics/statsCalc.cjs').countModelRowsByTimePeriod;
|
|
23
|
-
const getDomainIncludes = require('../active-citizen/engine/analytics/statsCalc.cjs').getDomainIncludes;
|
|
24
|
-
const getPointDomainIncludes = require('../active-citizen/engine/analytics/statsCalc.cjs').getPointDomainIncludes;
|
|
25
|
-
const getParsedSimilaritiesContent = require('../active-citizen/engine/analytics/manager.cjs').getParsedSimilaritiesContent;
|
|
26
|
-
const crypto = require('crypto');
|
|
27
|
-
var sendDomainOrError = function (res, domain, context, user, error, errorStatus) {
|
|
28
|
-
if (error || !domain) {
|
|
29
|
-
if (errorStatus === 404 || (error && error.message && error.message.indexOf("invalid input syntax for type integer") > -1)) {
|
|
30
|
-
log.warn("Domain Not Found", { context: context, domain: toJson(domain), user: toJson(user), err: error,
|
|
31
|
-
errorStatus: 404 });
|
|
32
|
-
errorStatus = 404;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
log.error("Domain Error", { context: context, domain: toJson(domain), user: toJson(user), err: error,
|
|
36
|
-
errorStatus: errorStatus ? errorStatus : 500 });
|
|
37
|
-
}
|
|
38
|
-
if (errorStatus) {
|
|
39
|
-
res.sendStatus(errorStatus);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
res.sendStatus(500);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
res.send(domain);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var truthValueFromBody = function (bodyParameter) {
|
|
50
|
-
return (bodyParameter && bodyParameter !== "");
|
|
51
|
-
};
|
|
52
|
-
var getAvailableCommunityFolders = function (req, domainId, done) {
|
|
53
|
-
let adminCommunities = [];
|
|
54
|
-
async.series([
|
|
55
|
-
function (seriesCallback) {
|
|
56
|
-
if (req.user) {
|
|
57
|
-
async.parallel([
|
|
58
|
-
function (parallelCallback) {
|
|
59
|
-
models.Community.findAll({
|
|
60
|
-
where: {
|
|
61
|
-
is_community_folder: true,
|
|
62
|
-
domain_id: domainId
|
|
63
|
-
},
|
|
64
|
-
attributes: ['id', 'name'],
|
|
65
|
-
include: [
|
|
66
|
-
{
|
|
67
|
-
model: models.User,
|
|
68
|
-
as: 'CommunityAdmins',
|
|
69
|
-
attributes: ['id'],
|
|
70
|
-
required: true,
|
|
71
|
-
where: {
|
|
72
|
-
id: req.user.id
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}).then(function (communities) {
|
|
77
|
-
adminCommunities = communities;
|
|
78
|
-
parallelCallback();
|
|
79
|
-
}).catch(function (error) {
|
|
80
|
-
parallelCallback(error);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
], function (error) {
|
|
84
|
-
seriesCallback(error);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
seriesCallback();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
], function (error) {
|
|
92
|
-
if (!error) {
|
|
93
|
-
done(error, adminCommunities);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
done(error);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
var getDomain = function (req, domainId, done) {
|
|
101
|
-
var domain;
|
|
102
|
-
var attributes = null;
|
|
103
|
-
async.series([
|
|
104
|
-
function (seriesCallback) {
|
|
105
|
-
auth.hasDomainAdmin(domainId, req, function (error, isAdmin) {
|
|
106
|
-
if (!isAdmin) {
|
|
107
|
-
attributes = models.Domain.defaultAttributesPublic;
|
|
108
|
-
}
|
|
109
|
-
seriesCallback(error);
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
function (seriesCallback) {
|
|
113
|
-
models.Domain.findOne({
|
|
114
|
-
where: { id: domainId },
|
|
115
|
-
attributes: attributes,
|
|
116
|
-
order: [
|
|
117
|
-
[{ model: models.Image, as: 'DomainLogoImages' }, 'created_at', 'asc'],
|
|
118
|
-
[{ model: models.Image, as: 'DomainHeaderImages' }, 'created_at', 'asc'],
|
|
119
|
-
[{ model: models.Video, as: "DomainLogoVideos" }, 'updated_at', 'desc'],
|
|
120
|
-
[{ model: models.Video, as: "DomainLogoVideos" }, { model: models.Image, as: 'VideoImages' }, 'updated_at', 'asc']
|
|
121
|
-
],
|
|
122
|
-
include: [
|
|
123
|
-
{
|
|
124
|
-
model: models.Image,
|
|
125
|
-
as: 'DomainLogoImages',
|
|
126
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
127
|
-
required: false
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
model: models.Video,
|
|
131
|
-
as: 'DomainLogoVideos',
|
|
132
|
-
attributes: ['id', 'formats', 'viewable', 'public_meta'],
|
|
133
|
-
required: false,
|
|
134
|
-
include: [
|
|
135
|
-
{
|
|
136
|
-
model: models.Image,
|
|
137
|
-
as: 'VideoImages',
|
|
138
|
-
attributes: ["formats", 'updated_at'],
|
|
139
|
-
required: false
|
|
140
|
-
},
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
model: models.Image,
|
|
145
|
-
as: 'DomainHeaderImages',
|
|
146
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
147
|
-
required: false
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}).then(function (domainIn) {
|
|
151
|
-
domain = domainIn;
|
|
152
|
-
if (domain) {
|
|
153
|
-
models.Community.findAll({
|
|
154
|
-
where: {
|
|
155
|
-
domain_id: domain.id,
|
|
156
|
-
access: {
|
|
157
|
-
$ne: models.Community.ACCESS_SECRET
|
|
158
|
-
},
|
|
159
|
-
configuration: {
|
|
160
|
-
[models.Sequelize.Op.or]: [
|
|
161
|
-
{
|
|
162
|
-
customBackURL: {
|
|
163
|
-
[models.Sequelize.Op.is]: null
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
alwaysShowOnDomainPage: true
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
},
|
|
171
|
-
$or: [
|
|
172
|
-
{
|
|
173
|
-
counter_users: {
|
|
174
|
-
$gt: process.env.MINIMUM_USERS_FOR_COMMUNITY_TO_SHOW ? parseInt(process.env.MINIMUM_USERS_FOR_COMMUNITY_TO_SHOW) : 21
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
status: "featured"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
is_community_folder: {
|
|
182
|
-
$ne: false
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
],
|
|
186
|
-
status: {
|
|
187
|
-
$ne: 'hidden'
|
|
188
|
-
},
|
|
189
|
-
in_community_folder_id: null
|
|
190
|
-
},
|
|
191
|
-
limit: 500,
|
|
192
|
-
attributes: models.Community.defaultAttributesPublic,
|
|
193
|
-
order: [
|
|
194
|
-
['counter_users', 'desc'],
|
|
195
|
-
[{ model: models.Image, as: 'CommunityLogoImages' }, 'created_at', 'asc']
|
|
196
|
-
],
|
|
197
|
-
include: [
|
|
198
|
-
{
|
|
199
|
-
model: models.Image,
|
|
200
|
-
as: 'CommunityLogoImages',
|
|
201
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
202
|
-
required: false
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
model: models.Community,
|
|
206
|
-
as: 'CommunityFolders',
|
|
207
|
-
attributes: ['id', 'name', 'counter_users', 'counter_posts', 'counter_groups'],
|
|
208
|
-
required: false,
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
model: models.Domain,
|
|
212
|
-
as: 'Domain',
|
|
213
|
-
attributes: ['id', 'configuration', 'name'],
|
|
214
|
-
required: false
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
model: models.Image,
|
|
218
|
-
as: 'CommunityHeaderImages',
|
|
219
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
220
|
-
required: false
|
|
221
|
-
}
|
|
222
|
-
]
|
|
223
|
-
}).then(function (communities) {
|
|
224
|
-
log.info('Domain Viewed', { domainId: domain ? domain.id : -1, userId: req.user ? req.user.id : -1 });
|
|
225
|
-
if (req.ypDomain && req.ypDomain.secret_api_keys &&
|
|
226
|
-
req.ypDomain.secret_api_keys.saml && req.ypDomain.secret_api_keys.saml.entryPoint &&
|
|
227
|
-
req.ypDomain.secret_api_keys.saml.entryPoint.length > 6) {
|
|
228
|
-
domain.dataValues.samlLoginProvided = true;
|
|
229
|
-
}
|
|
230
|
-
if (req.ypDomain && req.ypDomain.secret_api_keys &&
|
|
231
|
-
req.ypDomain.secret_api_keys.facebook && req.ypDomain.secret_api_keys.facebook.client_secret &&
|
|
232
|
-
req.ypDomain.secret_api_keys.facebook.client_secret.length > 6) {
|
|
233
|
-
domain.dataValues.facebookLoginProvided = true;
|
|
234
|
-
}
|
|
235
|
-
if (req.ypDomain && process.env.GOOGLE_MAPS_API_KEY) {
|
|
236
|
-
domain.dataValues.googleMapsApiKey = process.env.GOOGLE_MAPS_API_KEY;
|
|
237
|
-
}
|
|
238
|
-
if (req.ypDomain && process.env.ZIGGEO_ENABLED) {
|
|
239
|
-
domain.dataValues.ziggeoEnabled = process.env.ZIGGEO_ENABLED;
|
|
240
|
-
}
|
|
241
|
-
if (req.ypDomain && process.env.OPENAI_API_KEY) {
|
|
242
|
-
domain.dataValues.hasLlm = true;
|
|
243
|
-
}
|
|
244
|
-
domain.dataValues.Communities = communities;
|
|
245
|
-
if (process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME) {
|
|
246
|
-
domain.dataValues.loginCallbackCustomHostName = process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME;
|
|
247
|
-
}
|
|
248
|
-
seriesCallback(null);
|
|
249
|
-
return null;
|
|
250
|
-
}).catch(function (error) {
|
|
251
|
-
seriesCallback(error);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
seriesCallback("Not found");
|
|
256
|
-
}
|
|
257
|
-
return null;
|
|
258
|
-
}).catch(function (error) {
|
|
259
|
-
seriesCallback(error);
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
function (seriesCallback) {
|
|
263
|
-
if (req.user && domain) {
|
|
264
|
-
var adminCommunities, userCommunities;
|
|
265
|
-
async.parallel([
|
|
266
|
-
function (parallelCallback) {
|
|
267
|
-
models.Community.findAll({
|
|
268
|
-
where: {
|
|
269
|
-
domain_id: domain.id,
|
|
270
|
-
in_community_folder_id: null,
|
|
271
|
-
configuration: {
|
|
272
|
-
[models.Sequelize.Op.or]: [
|
|
273
|
-
{
|
|
274
|
-
customBackURL: {
|
|
275
|
-
[models.Sequelize.Op.is]: null
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
alwaysShowOnDomainPage: true
|
|
280
|
-
}
|
|
281
|
-
]
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
limit: 500,
|
|
285
|
-
attributes: models.Community.defaultAttributesPublic,
|
|
286
|
-
order: [
|
|
287
|
-
['counter_users', 'desc'],
|
|
288
|
-
[{ model: models.Image, as: 'CommunityLogoImages' }, 'created_at', 'asc']
|
|
289
|
-
],
|
|
290
|
-
include: [
|
|
291
|
-
{
|
|
292
|
-
model: models.Image, as: 'CommunityLogoImages',
|
|
293
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
294
|
-
required: false
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
model: models.Image, as: 'CommunityHeaderImages',
|
|
298
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
299
|
-
required: false
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
model: models.Community,
|
|
303
|
-
as: 'CommunityFolders',
|
|
304
|
-
attributes: ['id', 'name', 'counter_users', 'counter_posts', 'counter_groups'],
|
|
305
|
-
required: false,
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
model: models.Domain,
|
|
309
|
-
as: 'Domain',
|
|
310
|
-
attributes: ['id', 'configuration', 'name'],
|
|
311
|
-
required: false
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
model: models.User,
|
|
315
|
-
as: 'CommunityAdmins',
|
|
316
|
-
attributes: ['id'],
|
|
317
|
-
required: true,
|
|
318
|
-
where: {
|
|
319
|
-
id: req.user.id
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
}).then(function (communities) {
|
|
324
|
-
adminCommunities = communities;
|
|
325
|
-
parallelCallback();
|
|
326
|
-
}).catch(function (error) {
|
|
327
|
-
parallelCallback(error);
|
|
328
|
-
});
|
|
329
|
-
},
|
|
330
|
-
function (parallelCallback) {
|
|
331
|
-
models.Community.findAll({
|
|
332
|
-
where: {
|
|
333
|
-
domain_id: domain.id,
|
|
334
|
-
in_community_folder_id: null,
|
|
335
|
-
configuration: {
|
|
336
|
-
[models.Sequelize.Op.or]: [
|
|
337
|
-
{
|
|
338
|
-
customBackURL: {
|
|
339
|
-
[models.Sequelize.Op.is]: null
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
alwaysShowOnDomainPage: true
|
|
344
|
-
}
|
|
345
|
-
]
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
limit: 500,
|
|
349
|
-
attributes: models.Community.defaultAttributesPublic,
|
|
350
|
-
order: [
|
|
351
|
-
['counter_users', 'desc'],
|
|
352
|
-
[{ model: models.Image, as: 'CommunityLogoImages' }, 'created_at', 'asc']
|
|
353
|
-
],
|
|
354
|
-
include: [
|
|
355
|
-
{
|
|
356
|
-
model: models.Image, as: 'CommunityLogoImages',
|
|
357
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
358
|
-
required: false
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
model: models.Community,
|
|
362
|
-
as: 'CommunityFolders',
|
|
363
|
-
attributes: ['id', 'name', 'counter_users', 'counter_posts', 'counter_groups'],
|
|
364
|
-
required: false,
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
model: models.Image, as: 'CommunityHeaderImages',
|
|
368
|
-
required: false
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
model: models.User,
|
|
372
|
-
as: 'CommunityUsers',
|
|
373
|
-
attributes: ['id'],
|
|
374
|
-
required: true,
|
|
375
|
-
where: {
|
|
376
|
-
id: req.user.id
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
]
|
|
380
|
-
}).then(function (communities) {
|
|
381
|
-
userCommunities = communities;
|
|
382
|
-
parallelCallback();
|
|
383
|
-
}).catch(function (error) {
|
|
384
|
-
parallelCallback(error);
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
], function (error) {
|
|
388
|
-
var combinedCommunities = _.concat(adminCommunities, userCommunities);
|
|
389
|
-
combinedCommunities = _.concat(domain.dataValues.Communities, combinedCommunities);
|
|
390
|
-
combinedCommunities = _.uniqBy(combinedCommunities, function (community) {
|
|
391
|
-
return community.id;
|
|
392
|
-
});
|
|
393
|
-
domain.dataValues.Communities = combinedCommunities;
|
|
394
|
-
seriesCallback(error);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
seriesCallback();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
], function (error) {
|
|
402
|
-
done(error, domain);
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
var getDomainAndUser = function (domainId, userId, userEmail, callback) {
|
|
406
|
-
var user, domain;
|
|
407
|
-
async.series([
|
|
408
|
-
function (seriesCallback) {
|
|
409
|
-
models.Domain.findOne({
|
|
410
|
-
where: {
|
|
411
|
-
id: domainId
|
|
412
|
-
}
|
|
413
|
-
}).then(function (domainIn) {
|
|
414
|
-
if (domainIn) {
|
|
415
|
-
domain = domainIn;
|
|
416
|
-
}
|
|
417
|
-
seriesCallback();
|
|
418
|
-
}).catch(function (error) {
|
|
419
|
-
seriesCallback(error);
|
|
420
|
-
});
|
|
421
|
-
},
|
|
422
|
-
function (seriesCallback) {
|
|
423
|
-
if (userId) {
|
|
424
|
-
models.User.findOne({
|
|
425
|
-
where: {
|
|
426
|
-
id: userId
|
|
427
|
-
},
|
|
428
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
429
|
-
}).then(function (userIn) {
|
|
430
|
-
if (userIn) {
|
|
431
|
-
user = userIn;
|
|
432
|
-
}
|
|
433
|
-
seriesCallback();
|
|
434
|
-
}).catch(function (error) {
|
|
435
|
-
seriesCallback(error);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
seriesCallback();
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
function (seriesCallback) {
|
|
443
|
-
if (userEmail) {
|
|
444
|
-
models.User.findOne({
|
|
445
|
-
where: {
|
|
446
|
-
email: userEmail
|
|
447
|
-
},
|
|
448
|
-
attributes: ['id', 'email', 'name', 'created_at']
|
|
449
|
-
}).then(function (userIn) {
|
|
450
|
-
if (userIn) {
|
|
451
|
-
user = userIn;
|
|
452
|
-
}
|
|
453
|
-
seriesCallback();
|
|
454
|
-
}).catch(function (error) {
|
|
455
|
-
seriesCallback(error);
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
seriesCallback();
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
], function (error) {
|
|
463
|
-
if (error) {
|
|
464
|
-
callback(error);
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
callback(null, domain, user);
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
};
|
|
471
|
-
router.get('/:domainId/availableCommunityFolders', auth.can('view domain'), function (req, res) {
|
|
472
|
-
getAvailableCommunityFolders(req, req.params.domainId, function (error, availableCommunityFolders) {
|
|
473
|
-
if (error) {
|
|
474
|
-
log.error('Could not get availableCommunityFolders', { err: error, user: req.user ? toJson(req.user.simple()) : null });
|
|
475
|
-
res.sendStatus(500);
|
|
476
|
-
}
|
|
477
|
-
else if (availableCommunityFolders) {
|
|
478
|
-
res.send(availableCommunityFolders);
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
res.sendStatus(404);
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
router.delete('/:domainId/:activityId/delete_activity', auth.can('edit domain'), function (req, res) {
|
|
486
|
-
models.AcActivity.findOne({
|
|
487
|
-
where: {
|
|
488
|
-
domain_id: req.params.domainId,
|
|
489
|
-
id: req.params.activityId
|
|
490
|
-
}
|
|
491
|
-
}).then(function (activity) {
|
|
492
|
-
activity.deleted = true;
|
|
493
|
-
activity.save().then(function () {
|
|
494
|
-
res.send({ activityId: activity.id });
|
|
495
|
-
});
|
|
496
|
-
}).catch(function (error) {
|
|
497
|
-
log.error('Could not delete activity for domain', {
|
|
498
|
-
err: error,
|
|
499
|
-
context: 'delete_activity',
|
|
500
|
-
user: toJson(req.user.simple())
|
|
501
|
-
});
|
|
502
|
-
res.sendStatus(500);
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
router.get('/:domainId/pages', auth.can('view domain'), function (req, res) {
|
|
506
|
-
models.Page.getPages(req, { domain_id: req.params.domainId }, function (error, pages) {
|
|
507
|
-
if (error) {
|
|
508
|
-
log.error('Could not get pages for domain', { err: error, context: 'pages', user: req.user ? toJson(req.user.simple()) : null });
|
|
509
|
-
res.sendStatus(500);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
log.info('Got Pages', { userId: req.user ? req.user.id : null });
|
|
513
|
-
res.send(pages);
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
router.get('/:domainId/pages_for_admin', auth.can('edit domain'), function (req, res) {
|
|
518
|
-
models.Page.getPagesForAdmin(req, { domain_id: req.params.domainId }, function (error, pages) {
|
|
519
|
-
if (error) {
|
|
520
|
-
log.error('Could not get page for admin for domain', { err: error, context: 'pages_for_admin', user: toJson(req.user.simple()) });
|
|
521
|
-
res.sendStatus(500);
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
log.info('Got Pages For Admin', { userId: req.user ? req.user.id : null });
|
|
525
|
-
res.send(pages);
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
router.post('/:domainId/add_page', auth.can('edit domain'), function (req, res) {
|
|
530
|
-
models.Page.newPage(req, { domain_id: req.params.domainId, content: {}, title: {} }, function (error, pages) {
|
|
531
|
-
if (error) {
|
|
532
|
-
log.error('Could not create page for admin for domain', { err: error, context: 'new_page', user: toJson(req.user.simple()) });
|
|
533
|
-
res.sendStatus(500);
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
log.info('New Community Page', { context: 'new_page', user: toJson(req.user.simple()) });
|
|
537
|
-
res.sendStatus(200);
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
router.get('/:domainId/users', auth.can('edit domain'), function (req, res) {
|
|
542
|
-
models.Domain.findOne({
|
|
543
|
-
where: {
|
|
544
|
-
id: req.params.domainId
|
|
545
|
-
},
|
|
546
|
-
include: [
|
|
547
|
-
{
|
|
548
|
-
model: models.User,
|
|
549
|
-
attributes: _.concat(models.User.defaultAttributesWithSocialMediaPublicAndEmail, ['created_at', 'last_login_at']),
|
|
550
|
-
as: 'DomainUsers',
|
|
551
|
-
required: true,
|
|
552
|
-
include: [
|
|
553
|
-
{
|
|
554
|
-
model: models.Organization,
|
|
555
|
-
attributes: ['id', 'name'],
|
|
556
|
-
as: 'OrganizationUsers',
|
|
557
|
-
required: false
|
|
558
|
-
}
|
|
559
|
-
]
|
|
560
|
-
}
|
|
561
|
-
]
|
|
562
|
-
}).then(function (domain) {
|
|
563
|
-
log.info('Got users for domain', { context: 'users', user: toJson(req.user.simple()) });
|
|
564
|
-
if (domain) {
|
|
565
|
-
res.send(domain.DomainUsers);
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
res.send([]);
|
|
569
|
-
}
|
|
570
|
-
}).catch(function (error) {
|
|
571
|
-
log.error('Could not get users for domain', { err: error, context: 'users', user: toJson(req.user.simple()) });
|
|
572
|
-
res.sendStatus(500);
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
router.get('/:domainId/admin_users', auth.can('edit domain'), function (req, res) {
|
|
576
|
-
models.Domain.findOne({
|
|
577
|
-
where: {
|
|
578
|
-
id: req.params.domainId
|
|
579
|
-
},
|
|
580
|
-
include: [
|
|
581
|
-
{
|
|
582
|
-
model: models.User,
|
|
583
|
-
attributes: _.concat(models.User.defaultAttributesWithSocialMediaPublicAndEmail, ['created_at', 'last_login_at']),
|
|
584
|
-
as: 'DomainAdmins',
|
|
585
|
-
required: true,
|
|
586
|
-
include: [
|
|
587
|
-
{
|
|
588
|
-
model: models.Organization,
|
|
589
|
-
attributes: ['id', 'name'],
|
|
590
|
-
as: 'OrganizationUsers',
|
|
591
|
-
required: false
|
|
592
|
-
}
|
|
593
|
-
]
|
|
594
|
-
}
|
|
595
|
-
]
|
|
596
|
-
}).then(function (domain) {
|
|
597
|
-
log.info('Got admins for domain', { context: 'users', user: toJson(req.user.simple()) });
|
|
598
|
-
if (domain) {
|
|
599
|
-
res.send(domain.DomainAdmins);
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
res.send([]);
|
|
603
|
-
}
|
|
604
|
-
}).catch(function (error) {
|
|
605
|
-
log.error('Could not get admin users for domain', { err: error, context: 'users', user: toJson(req.user.simple()) });
|
|
606
|
-
res.sendStatus(500);
|
|
607
|
-
});
|
|
608
|
-
});
|
|
609
|
-
router.put('/:domainId/:pageId/update_page_locale', auth.can('edit domain'), function (req, res) {
|
|
610
|
-
models.Page.updatePageLocale(req, { domain_id: req.params.domainId, id: req.params.pageId }, function (error) {
|
|
611
|
-
if (error) {
|
|
612
|
-
log.error('Could not update locale for admin for domain', { err: error, context: 'update_page_locale', user: toJson(req.user.simple()) });
|
|
613
|
-
res.sendStatus(500);
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
log.info('Community Page Locale Updated', { context: 'update_page_locale', user: toJson(req.user.simple()) });
|
|
617
|
-
res.sendStatus(200);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
});
|
|
621
|
-
router.put('/:domainId/:pageId/update_page_weight', auth.can('edit domain'), function (req, res) {
|
|
622
|
-
models.Page.updatePageWeight(req, { domain_id: req.params.domainId, id: req.params.pageId }, function (error) {
|
|
623
|
-
if (error) {
|
|
624
|
-
log.error('Could not update weight for admin for domain', { err: error, context: 'update_page_weight', user: toJson(req.user.simple()) });
|
|
625
|
-
res.sendStatus(500);
|
|
626
|
-
}
|
|
627
|
-
else {
|
|
628
|
-
log.info('Community Page Weight Updated', { context: 'update_page_weight', user: toJson(req.user.simple()) });
|
|
629
|
-
res.sendStatus(200);
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
router.put('/:domainId/:pageId/publish_page', auth.can('edit domain'), function (req, res) {
|
|
634
|
-
models.Page.publishPage(req, { domain_id: req.params.domainId, id: req.params.pageId }, function (error) {
|
|
635
|
-
if (error) {
|
|
636
|
-
log.error('Could not publish page for admin for domain', { err: error, context: 'publish_page', user: toJson(req.user.simple()) });
|
|
637
|
-
res.sendStatus(500);
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
log.info('Community Page Published', { context: 'publish_page', user: toJson(req.user.simple()) });
|
|
641
|
-
res.sendStatus(200);
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
router.put('/:domainId/:pageId/un_publish_page', auth.can('edit domain'), function (req, res) {
|
|
646
|
-
models.Page.unPublishPage(req, { domain_id: req.params.domainId, id: req.params.pageId }, function (error) {
|
|
647
|
-
if (error) {
|
|
648
|
-
log.error('Could not un-publish page for admin for domain', { err: error, context: 'un_publish_page', user: toJson(req.user.simple()) });
|
|
649
|
-
res.sendStatus(500);
|
|
650
|
-
}
|
|
651
|
-
else {
|
|
652
|
-
log.info('Community Page Un-Published', { context: 'un_publish_page', user: toJson(req.user.simple()) });
|
|
653
|
-
res.sendStatus(200);
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
});
|
|
657
|
-
router.delete('/:domainId/:pageId/delete_page', auth.can('edit domain'), function (req, res) {
|
|
658
|
-
models.Page.deletePage(req, { domain_id: req.params.domainId, id: req.params.pageId }, function (error) {
|
|
659
|
-
if (error) {
|
|
660
|
-
log.error('Could not delete page for admin for domain', { err: error, context: 'delete_page', user: toJson(req.user.simple()) });
|
|
661
|
-
res.sendStatus(500);
|
|
662
|
-
}
|
|
663
|
-
else {
|
|
664
|
-
log.info('Commuity Page Published', { context: 'delete_page', user: toJson(req.user.simple()) });
|
|
665
|
-
res.sendStatus(200);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
});
|
|
669
|
-
router.post('/:domainId/news_story', auth.isLoggedInNoAnonymousCheck, auth.can('view domain'), function (req, res) {
|
|
670
|
-
models.Point.createNewsStory(req, req.body, function (error) {
|
|
671
|
-
if (error) {
|
|
672
|
-
log.error('Could not save news story point on domain', { err: error, context: 'news_story', user: toJson(req.user.simple()) });
|
|
673
|
-
res.sendStatus(500);
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
log.info('Point News Story Created', { context: 'news_story', user: toJson(req.user.simple()) });
|
|
677
|
-
res.sendStatus(200);
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
router.get('/oldBoot', function (req, res) {
|
|
682
|
-
getDomain(req, req.ypDomain.id, function (error, domain) {
|
|
683
|
-
if (error) {
|
|
684
|
-
if (error == 'Not found')
|
|
685
|
-
sendDomainOrError(res, null, 'view', req.user, error, 404);
|
|
686
|
-
else
|
|
687
|
-
sendDomainOrError(res, null, 'view', req.user, error);
|
|
688
|
-
}
|
|
689
|
-
else {
|
|
690
|
-
if (req.ypCommunity && req.ypCommunity.id) {
|
|
691
|
-
log.info('Domain Lookup Found Community', { community: req.ypCommunity.hostname, context: 'index', user: toJson(req.user) });
|
|
692
|
-
res.send({ community: req.ypCommunity, domain: domain });
|
|
693
|
-
}
|
|
694
|
-
else {
|
|
695
|
-
log.info('Domain Lookup Found Domain', { domainId: domain ? domain.id : -1, context: 'index', userId: req.user ? req.user.id : -1 });
|
|
696
|
-
res.send({ domain: domain });
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
});
|
|
701
|
-
router.get('/', function (req, res) {
|
|
702
|
-
if (req.ypDomain.secret_api_keys &&
|
|
703
|
-
req.ypDomain.secret_api_keys.saml && req.ypDomain.secret_api_keys.saml.entryPoint &&
|
|
704
|
-
req.ypDomain.secret_api_keys.saml.entryPoint.length > 6) {
|
|
705
|
-
req.ypDomain.dataValues.samlLoginProvided = true;
|
|
706
|
-
}
|
|
707
|
-
if (req.ypDomain.secret_api_keys &&
|
|
708
|
-
req.ypDomain.secret_api_keys.facebook && req.ypDomain.secret_api_keys.facebook.client_secret &&
|
|
709
|
-
req.ypDomain.secret_api_keys.facebook.client_secret.length > 6) {
|
|
710
|
-
req.ypDomain.dataValues.facebookLoginProvided = true;
|
|
711
|
-
}
|
|
712
|
-
if (process.env.GOOGLE_MAPS_API_KEY) {
|
|
713
|
-
req.ypDomain.dataValues.googleMapsApiKey = process.env.GOOGLE_MAPS_API_KEY;
|
|
714
|
-
}
|
|
715
|
-
if (process.env.ZIGGEO_ENABLED) {
|
|
716
|
-
req.ypDomain.dataValues.ziggeoEnabled = process.env.ZIGGEO_ENABLED;
|
|
717
|
-
}
|
|
718
|
-
if (process.env.OPENAI_API_KEY) {
|
|
719
|
-
req.ypDomain.dataValues.hasLlm = true;
|
|
720
|
-
}
|
|
721
|
-
if (process.env.CESIUM_ACCESS_TOKEN) {
|
|
722
|
-
req.ypDomain.dataValues.ionToken = process.env.CESIUM_ACCESS_TOKEN;
|
|
723
|
-
}
|
|
724
|
-
if (process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME) {
|
|
725
|
-
req.ypDomain.dataValues.loginCallbackCustomHostName = process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME;
|
|
726
|
-
}
|
|
727
|
-
const domain = { ...req.ypDomain.dataValues };
|
|
728
|
-
delete domain["secret_api_keys"];
|
|
729
|
-
delete domain["user_agent"];
|
|
730
|
-
delete domain["ip_address"];
|
|
731
|
-
res.send({ community: (req.ypCommunity && req.ypCommunity.id) ? req.ypCommunity : undefined, domain: domain });
|
|
732
|
-
});
|
|
733
|
-
router.get('/:id/translatedText', auth.can('view domain'), function (req, res) {
|
|
734
|
-
if (req.query.textType.indexOf("domain") > -1) {
|
|
735
|
-
models.Domain.findOne({
|
|
736
|
-
where: {
|
|
737
|
-
id: req.params.id
|
|
738
|
-
},
|
|
739
|
-
attributes: ['id', 'name', 'description', 'configuration']
|
|
740
|
-
}).then(function (domain) {
|
|
741
|
-
if (domain) {
|
|
742
|
-
models.AcTranslationCache.getTranslation(req, domain, function (error, translation) {
|
|
743
|
-
if (error) {
|
|
744
|
-
sendDomainOrError(res, req.params.id, 'translated', req.user, error, 500);
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
res.send(translation);
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
log.info('Domain translatedTitle', { context: 'translated' });
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
sendDomainOrError(res, req.params.id, 'translated', req.user, 'Not found', 404);
|
|
754
|
-
}
|
|
755
|
-
}).catch(function (error) {
|
|
756
|
-
sendDomainOrError(res, null, 'translated', req.user, error);
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
sendDomainOrError(res, req.params.id, 'translated', req.user, 'Wrong textType', 401);
|
|
761
|
-
}
|
|
762
|
-
});
|
|
763
|
-
router.get('/:id', auth.can('view domain'), function (req, res) {
|
|
764
|
-
if (isValidDbId(req.params.id)) {
|
|
765
|
-
getDomain(req, req.params.id, function (error, domain) {
|
|
766
|
-
if (error) {
|
|
767
|
-
sendDomainOrError(res, null, 'view', req.user, error);
|
|
768
|
-
}
|
|
769
|
-
else {
|
|
770
|
-
log.info('Domain Viewed', { id: domain ? domain.id : -1, userId: req.user ? req.user.id : null });
|
|
771
|
-
res.send(domain);
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
else {
|
|
776
|
-
res.sendStatus(404);
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
// Function to update domain properties
|
|
780
|
-
function updateDomainProperties(domain, req) {
|
|
781
|
-
domain.ensureApiKeySetup();
|
|
782
|
-
domain.set('secret_api_keys.facebook.client_id', req.body.facebookClientId);
|
|
783
|
-
domain.set('secret_api_keys.facebook.client_secret', req.body.facebookClientSecret);
|
|
784
|
-
domain.set('secret_api_keys.google.client_id', req.body.googleClientId);
|
|
785
|
-
domain.set('secret_api_keys.google.client_secret', req.body.googleClientSecret);
|
|
786
|
-
domain.set('secret_api_keys.twitter.client_id', req.body.twitterClientId);
|
|
787
|
-
domain.set('secret_api_keys.twitter.client_secret', req.body.twitterClientSecret);
|
|
788
|
-
domain.set('secret_api_keys.github.client_id', req.body.githubClientId);
|
|
789
|
-
domain.set('secret_api_keys.github.client_secret', req.body.githubClientSecret);
|
|
790
|
-
domain.set('configuration.welcomeHtmlInsteadOfCommunitiesList', (req.body.welcomeHtmlInsteadOfCommunitiesList && req.body.welcomeHtmlInsteadOfCommunitiesList !== "") ? req.body.welcomeHtmlInsteadOfCommunitiesList : null);
|
|
791
|
-
domain.set('configuration.hideAppBarIfWelcomeHtml', truthValueFromBody(req.body.hideAppBarIfWelcomeHtml));
|
|
792
|
-
if (req.body.samlEntryPoint) {
|
|
793
|
-
domain.set('secret_api_keys.saml.entryPoint', req.body.samlEntryPoint);
|
|
794
|
-
domain.set('secret_api_keys.saml.callbackUrl', req.body.samlCallbackUrl);
|
|
795
|
-
domain.set('secret_api_keys.saml.cert', req.body.samlCert);
|
|
796
|
-
domain.set('secret_api_keys.saml.issuer', req.body.samlIssuer);
|
|
797
|
-
domain.set('secret_api_keys.saml.identifierFormat', req.body.samlIdentifierFormat);
|
|
798
|
-
}
|
|
799
|
-
if (!domain.configuration) {
|
|
800
|
-
domain.set('configuration', {});
|
|
801
|
-
}
|
|
802
|
-
domain.set('configuration.customSamlLoginText', (req.body.customSamlLoginText && req.body.customSamlLoginText !== "") ? req.body.customSamlLoginText : null);
|
|
803
|
-
domain.set('configuration.samlLoginButtonUrl', (req.body.samlLoginButtonUrl && req.body.samlLoginButtonUrl !== "") ? req.body.samlLoginButtonUrl : null);
|
|
804
|
-
domain.set('configuration.customSAMLErrorHTML', (req.body.customSAMLErrorHTML && req.body.customSAMLErrorHTML !== "") ? req.body.customSAMLErrorHTML : null);
|
|
805
|
-
domain.set('configuration.preloadCssUrl', (req.body.preloadCssUrl && req.body.preloadCssUrl !== "") ? req.body.preloadCssUrl : null);
|
|
806
|
-
domain.set('configuration.plausibleDataDomains', (req.body.plausibleDataDomains && req.body.plausibleDataDomains !== "") ? req.body.plausibleDataDomains : null);
|
|
807
|
-
domain.set('configuration.ziggeoApplicationToken', (req.body.ziggeoApplicationToken && req.body.ziggeoApplicationToken !== "") ? req.body.ziggeoApplicationToken : null);
|
|
808
|
-
domain.set('configuration.ga4Tag', (req.body.ga4Tag && req.body.ga4Tag !== "") ? req.body.ga4Tag : null);
|
|
809
|
-
domain.set('configuration.useLoginOnDomainIfNotLoggedIn', truthValueFromBody(req.body.useLoginOnDomainIfNotLoggedIn));
|
|
810
|
-
if (req.body.google_analytics_code && req.body.google_analytics_code !== "") {
|
|
811
|
-
domain.google_analytics_code = req.body.google_analytics_code;
|
|
812
|
-
}
|
|
813
|
-
else {
|
|
814
|
-
domain.google_analytics_code = null;
|
|
815
|
-
}
|
|
816
|
-
const ltpConfigText = (req.body.ltp && req.body.ltp !== "") ? req.body.ltp : null;
|
|
817
|
-
if (ltpConfigText) {
|
|
818
|
-
try {
|
|
819
|
-
const cleaned = ltpConfigText.trim().replace(/\n/g, '').replace(/\r/g, '');
|
|
820
|
-
const parsedJson = JSON.parse(cleaned);
|
|
821
|
-
domain.set('configuration.ltp', parsedJson);
|
|
822
|
-
}
|
|
823
|
-
catch (error) {
|
|
824
|
-
domain.set('configuration.ltp', null);
|
|
825
|
-
log.error("Error in parsing ltp", { error });
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
else {
|
|
829
|
-
domain.set('configuration.ltp', null);
|
|
830
|
-
}
|
|
831
|
-
const theme = (req.body.theme && req.body.theme !== "") ? req.body.theme : null;
|
|
832
|
-
if (theme) {
|
|
833
|
-
try {
|
|
834
|
-
const cleaned = theme.trim().replace(/\n/g, '').replace(/\r/g, '');
|
|
835
|
-
const parsedJson = JSON.parse(cleaned);
|
|
836
|
-
domain.set('configuration.theme', parsedJson);
|
|
837
|
-
}
|
|
838
|
-
catch (error) {
|
|
839
|
-
domain.set('configuration.theme', null);
|
|
840
|
-
log.error("Error in parsing theme", { error });
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
else {
|
|
844
|
-
domain.set('configuration.theme', null);
|
|
845
|
-
}
|
|
846
|
-
domain.set('configuration.customUserRegistrationText', (req.body.customUserRegistrationText && req.body.customUserRegistrationText !== "") ? req.body.customUserRegistrationText : null);
|
|
847
|
-
domain.set('configuration.forceSecureSamlEmployeeLogin', truthValueFromBody(req.body.forceSecureSamlEmployeeLogin));
|
|
848
|
-
domain.set('configuration.disableNameAutoTranslation', truthValueFromBody(req.body.disableNameAutoTranslation));
|
|
849
|
-
if (req.body.appHomeScreenIconImageId && req.body.appHomeScreenIconImageId !== "") {
|
|
850
|
-
domain.set('configuration.appHomeScreenIconImageId', req.body.appHomeScreenIconImageId);
|
|
851
|
-
}
|
|
852
|
-
domain.set('configuration.appHomeScreenShortName', (req.body.appHomeScreenShortName && req.body.appHomeScreenShortName !== "") ? req.body.appHomeScreenShortName : null);
|
|
853
|
-
domain.set('configuration.useVideoCover', truthValueFromBody(req.body.useVideoCover));
|
|
854
|
-
domain.set('configuration.hideDomainNews', truthValueFromBody(req.body.hideDomainNews));
|
|
855
|
-
domain.set('configuration.hideDomainTabs', truthValueFromBody(req.body.hideDomainTabs));
|
|
856
|
-
domain.set('configuration.hideAllTabs', truthValueFromBody(req.body.hideAllTabs));
|
|
857
|
-
domain.set('configuration.useFixedTopAppBar', truthValueFromBody(req.body.useFixedTopAppBar));
|
|
858
|
-
domain.set('configuration.disableArrowBasedTopNavigation', truthValueFromBody(req.body.disableArrowBasedTopNavigation));
|
|
859
|
-
domain.set('configuration.onlyAllowCreateUserOnInvite', truthValueFromBody(req.body.onlyAllowCreateUserOnInvite));
|
|
860
|
-
domain.name = req.body.name;
|
|
861
|
-
domain.description = req.body.description;
|
|
862
|
-
domain.only_admins_can_create_communities = truthValueFromBody(req.body.onlyAdminsCanCreateCommunities);
|
|
863
|
-
domain.theme_id = req.body.themeId ? parseInt(req.body.themeId) : null;
|
|
864
|
-
if (req.body.defaultLocale && req.body.defaultLocale !== "") {
|
|
865
|
-
domain.default_locale = req.body.defaultLocale;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
// Update existing domain
|
|
869
|
-
router.put('/:id', auth.can('edit domain'), function (req, res) {
|
|
870
|
-
models.Domain.findOne({
|
|
871
|
-
where: { id: req.params.id }
|
|
872
|
-
}).then(function (domain) {
|
|
873
|
-
if (domain) {
|
|
874
|
-
updateDomainProperties(domain, req);
|
|
875
|
-
domain.save().then(function () {
|
|
876
|
-
queue.add('process-similarities', { type: 'update-collection', domainId: domain.id }, 'low');
|
|
877
|
-
log.info('Domain Updated', { domain: toJson(domain), user: toJson(req.user) });
|
|
878
|
-
domain.setupImages(req.body, function (err) {
|
|
879
|
-
if (err) {
|
|
880
|
-
res.sendStatus(500);
|
|
881
|
-
log.error('Domain Error Setup images', { domain: toJson(domain), user: toJson(req.user), err: err });
|
|
882
|
-
}
|
|
883
|
-
else {
|
|
884
|
-
res.send(domain);
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
sendDomainOrError(res, req.params.id, 'update', req.user, 'Not found', 404);
|
|
891
|
-
}
|
|
892
|
-
}).catch(function (error) {
|
|
893
|
-
sendDomainOrError(res, null, 'update', req.user, error);
|
|
894
|
-
});
|
|
895
|
-
});
|
|
896
|
-
router.get('/:id/my_domains', auth.can('view domain'), function (req, res) {
|
|
897
|
-
models.Domain.findAll({
|
|
898
|
-
attributes: ['id', 'name'],
|
|
899
|
-
include: [
|
|
900
|
-
{
|
|
901
|
-
model: models.User,
|
|
902
|
-
as: 'DomainUsers',
|
|
903
|
-
attributes: [],
|
|
904
|
-
where: { id: req.user.id },
|
|
905
|
-
required: false
|
|
906
|
-
},
|
|
907
|
-
{
|
|
908
|
-
model: models.User,
|
|
909
|
-
as: 'DomainAdmins',
|
|
910
|
-
attributes: [],
|
|
911
|
-
where: { id: req.user.id },
|
|
912
|
-
required: false
|
|
913
|
-
}
|
|
914
|
-
],
|
|
915
|
-
where: {
|
|
916
|
-
[models.Sequelize.Op.or]: [
|
|
917
|
-
{ '$DomainUsers.id$': { [models.Sequelize.Op.eq]: req.user.id } },
|
|
918
|
-
{ '$DomainAdmins.id$': { [models.Sequelize.Op.eq]: req.user.id } }
|
|
919
|
-
]
|
|
920
|
-
}
|
|
921
|
-
}).then(function (domains) {
|
|
922
|
-
// Deduplicate the domains in case the user is both an admin and a user
|
|
923
|
-
const uniqueDomains = _.uniqBy(domains, 'id');
|
|
924
|
-
const domainList = uniqueDomains.map(domain => ({ id: domain.id, name: domain.name }));
|
|
925
|
-
log.info('Retrieved user domains', { userId: req.user.id });
|
|
926
|
-
res.send(domainList);
|
|
927
|
-
}).catch(function (error) {
|
|
928
|
-
log.error('Could not retrieve user domains', { err: error, context: 'my_domains', user: toJson(req.user.simple()) });
|
|
929
|
-
res.sendStatus(500);
|
|
930
|
-
});
|
|
931
|
-
});
|
|
932
|
-
router.post('/:id', auth.can('edit domain'), function (req, res) {
|
|
933
|
-
const randomDomainName = crypto.randomBytes(16).toString('hex'); // Generate 32 character random string
|
|
934
|
-
var domain = models.Domain.build({
|
|
935
|
-
name: req.body.name,
|
|
936
|
-
description: req.body.description,
|
|
937
|
-
user_id: req.user.id,
|
|
938
|
-
user_agent: req.useragent.source,
|
|
939
|
-
ip_address: req.clientIp,
|
|
940
|
-
access: req.body.access ? req.body.access : 2,
|
|
941
|
-
status: "active",
|
|
942
|
-
domain_name: randomDomainName
|
|
943
|
-
});
|
|
944
|
-
updateDomainProperties(domain, req);
|
|
945
|
-
domain.save()
|
|
946
|
-
.then(function () {
|
|
947
|
-
return domain.addDomainUsers(req.user);
|
|
948
|
-
})
|
|
949
|
-
.then(function () {
|
|
950
|
-
return domain.addDomainAdmins(req.user);
|
|
951
|
-
})
|
|
952
|
-
.then(function () {
|
|
953
|
-
// Success path
|
|
954
|
-
queue.add('process-similarities', { type: 'update-collection', domainId: domain.id }, 'low');
|
|
955
|
-
log.info('Domain Created', { domain: toJson(domain), context: 'create', user: toJson(req.user) });
|
|
956
|
-
domain.setupImages(req.body, function (err) {
|
|
957
|
-
if (err) {
|
|
958
|
-
res.sendStatus(500);
|
|
959
|
-
log.error('Domain Error Setup images', { domain: toJson(domain), user: toJson(req.user), err: err });
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
res.send(domain);
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
})
|
|
966
|
-
.catch(function (error) {
|
|
967
|
-
// Handle any error that occurred in any of the previous promises
|
|
968
|
-
log.error('Error during domain creation', { err: error, domainId: domain.id, user: toJson(req.user) });
|
|
969
|
-
res.sendStatus(500);
|
|
970
|
-
});
|
|
971
|
-
});
|
|
972
|
-
router.delete('/:id', auth.can('edit domain'), function (req, res) {
|
|
973
|
-
models.Domain.findOne({
|
|
974
|
-
where: { id: req.params.id }
|
|
975
|
-
}).then(function (domain) {
|
|
976
|
-
if (domain) {
|
|
977
|
-
domain.deleted = true;
|
|
978
|
-
domain.save().then(function () {
|
|
979
|
-
log.info('Domain Deleted', { group: toJson(group), context: 'delete', user: toJson(req.user) });
|
|
980
|
-
queue.add('process-similarities', { type: 'update-collection', domainId: domain.id }, 'low');
|
|
981
|
-
res.sendStatus(200);
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
else {
|
|
985
|
-
sendDomainOrError(res, req.params.id, 'delete', req.user, 'Not found', 404);
|
|
986
|
-
}
|
|
987
|
-
}).catch(function (error) {
|
|
988
|
-
sendDomainOrError(res, null, 'delete', req.user, error);
|
|
989
|
-
});
|
|
990
|
-
});
|
|
991
|
-
router.get(':id/news', auth.can('view domain'), function (req, res) {
|
|
992
|
-
models.AcActivity.findOne({
|
|
993
|
-
where: { domain_id: req.params.id },
|
|
994
|
-
order: [
|
|
995
|
-
[{ model: models.Domain }, 'created_at', 'asc']
|
|
996
|
-
],
|
|
997
|
-
limit: 200
|
|
998
|
-
}).then(function (news) {
|
|
999
|
-
if (news) {
|
|
1000
|
-
log.info('Domain News', { domain: toJson(news), context: 'get', user: toJson(req.user) });
|
|
1001
|
-
res.send(news);
|
|
1002
|
-
}
|
|
1003
|
-
else {
|
|
1004
|
-
log.warn("Domain News Not Found", {
|
|
1005
|
-
context: context, domain: toJson(domain), user: toJson(user), err: "Not found",
|
|
1006
|
-
errorStatus: errorStatus ? errorStatus : 404
|
|
1007
|
-
});
|
|
1008
|
-
res.sendStatus(404);
|
|
1009
|
-
}
|
|
1010
|
-
}).catch(function (error) {
|
|
1011
|
-
log.error("Domain News Error", { context: context, domain: toJson(domain), user: toJson(user), err: error,
|
|
1012
|
-
errorStatus: errorStatus ? errorStatus : 500 });
|
|
1013
|
-
res.sendStatus(500);
|
|
1014
|
-
});
|
|
1015
|
-
});
|
|
1016
|
-
// MODERATION
|
|
1017
|
-
router.delete('/:domainId/:itemId/:itemType/:actionType/process_one_moderation_item', auth.can('edit domain'), (req, res) => {
|
|
1018
|
-
performSingleModerationAction(req, res, {
|
|
1019
|
-
domainId: req.params.domainId,
|
|
1020
|
-
itemId: req.params.itemId,
|
|
1021
|
-
itemType: req.params.itemType,
|
|
1022
|
-
actionType: req.params.actionType
|
|
1023
|
-
});
|
|
1024
|
-
});
|
|
1025
|
-
router.delete('/:domainId/:actionType/process_many_moderation_item', auth.can('edit domain'), (req, res) => {
|
|
1026
|
-
queue.add('process-moderation', {
|
|
1027
|
-
type: 'perform-many-moderation-actions',
|
|
1028
|
-
items: req.body.items,
|
|
1029
|
-
actionType: req.params.actionType,
|
|
1030
|
-
domainId: req.params.domainId
|
|
1031
|
-
}, 'critical');
|
|
1032
|
-
res.send({});
|
|
1033
|
-
});
|
|
1034
|
-
router.get('/:domainId/flagged_content', auth.can('edit domain'), (req, res) => {
|
|
1035
|
-
getAllModeratedItemsByDomain({ domainId: req.params.domainId }, (error, items) => {
|
|
1036
|
-
if (error) {
|
|
1037
|
-
log.error("Error getting items for moderation", { error });
|
|
1038
|
-
res.sendStatus(500);
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
res.send(items);
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
});
|
|
1045
|
-
router.get('/:domainId/moderate_all_content', auth.can('edit domain'), (req, res) => {
|
|
1046
|
-
getAllModeratedItemsByDomain({ domainId: req.params.domainId, allContent: true }, (error, items) => {
|
|
1047
|
-
if (error) {
|
|
1048
|
-
log.error("Error getting items for moderation", { error });
|
|
1049
|
-
res.sendStatus(500);
|
|
1050
|
-
}
|
|
1051
|
-
else {
|
|
1052
|
-
res.send(items);
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
});
|
|
1056
|
-
router.get('/:domainId/flagged_content_count', auth.can('edit domain'), (req, res) => {
|
|
1057
|
-
countAllModeratedItemsByDomain({ domainId: req.params.domainId }, (error, count) => {
|
|
1058
|
-
if (error) {
|
|
1059
|
-
log.error("Error getting items for moderation", { error });
|
|
1060
|
-
res.sendStatus(500);
|
|
1061
|
-
}
|
|
1062
|
-
else {
|
|
1063
|
-
res.send({ count });
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
});
|
|
1067
|
-
router.delete('/:domainId/remove_many_admins', auth.can('edit domain'), (req, res) => {
|
|
1068
|
-
queue.add('process-deletion', { type: 'remove-many-domain-admins', userIds: req.body.userIds, domainId: req.params.domainId }, 'high');
|
|
1069
|
-
log.info('Remove many domain admins started', { context: 'remove_many_admins', domainId: req.params.domainId, user: toJson(req.user.simple()) });
|
|
1070
|
-
res.sendStatus(200);
|
|
1071
|
-
});
|
|
1072
|
-
router.delete('/:domainId/remove_many_users_and_delete_content', auth.can('edit domain'), function (req, res) {
|
|
1073
|
-
queue.add('process-deletion', { type: 'remove-many-domain-users-and-delete-content', userIds: req.body.userIds, domainId: req.params.domainId }, 'high');
|
|
1074
|
-
log.info('Remove many and delete many domain users content', { context: 'remove_many_users_and_delete_content', domainId: req.params.domainId, user: toJson(req.user.simple()) });
|
|
1075
|
-
res.sendStatus(200);
|
|
1076
|
-
});
|
|
1077
|
-
router.delete('/:domainId/remove_many_users', auth.can('edit domain'), function (req, res) {
|
|
1078
|
-
queue.add('process-deletion', { type: 'remove-many-domain-users', userIds: req.body.userIds, domainId: req.params.domainId }, 'high');
|
|
1079
|
-
log.info('Remove many domain admins started', { context: 'remove_many_users', domainId: req.params.domainId, user: toJson(req.user.simple()) });
|
|
1080
|
-
res.sendStatus(200);
|
|
1081
|
-
});
|
|
1082
|
-
router.delete('/:domainId/:userId/remove_and_delete_user_content', auth.can('edit domain'), function (req, res) {
|
|
1083
|
-
getDomainAndUser(req.params.domainId, req.params.userId, null, function (error, domain, user) {
|
|
1084
|
-
if (error) {
|
|
1085
|
-
log.error('Could not remove_user', { err: error, domainId: req.params.domainId, userRemovedId: req.params.userId, context: 'remove_user', user: toJson(req.user.simple()) });
|
|
1086
|
-
res.sendStatus(500);
|
|
1087
|
-
}
|
|
1088
|
-
else if (user && domain) {
|
|
1089
|
-
domain.removeDomainUsers(user).then(function (results) {
|
|
1090
|
-
queue.add('process-deletion', { type: 'delete-domain-user-content', userId: req.params.userId, domainId: req.params.domainId }, 'high');
|
|
1091
|
-
log.info('User removed from domain', { context: 'remove_and_delete_user_content', domainId: req.params.domainId, userRemovedId: req.params.userId, user: toJson(req.user.simple()) });
|
|
1092
|
-
res.sendStatus(200);
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
res.sendStatus(404);
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
});
|
|
1100
|
-
router.delete('/:domainId/:userId/remove_admin', auth.can('edit domain'), function (req, res) {
|
|
1101
|
-
getDomainAndUser(req.params.domainId, req.params.userId, null, function (error, domain, user) {
|
|
1102
|
-
if (error) {
|
|
1103
|
-
log.error('Could not remove admin', { err: error, domainId: req.params.domainId, userRemovedId: req.params.userId, context: 'remove_admin', user: req.user ? toJson(req.user.simple()) : null });
|
|
1104
|
-
res.sendStatus(500);
|
|
1105
|
-
}
|
|
1106
|
-
else if (user && domain) {
|
|
1107
|
-
domain.removeDomainAdmins(user).then(function (results) {
|
|
1108
|
-
log.info('Admin removed', { context: 'remove_admin', domainId: req.params.domainId, userRemovedId: req.params.userId, user: req.user ? toJson(req.user.simple()) : null });
|
|
1109
|
-
res.sendStatus(200);
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
else {
|
|
1113
|
-
res.sendStatus(404);
|
|
1114
|
-
}
|
|
1115
|
-
});
|
|
1116
|
-
});
|
|
1117
|
-
router.post('/:domainId/:email/add_admin', auth.can('edit domain'), function (req, res) {
|
|
1118
|
-
getDomainAndUser(req.params.domainId, null, req.params.email, function (error, domain, user) {
|
|
1119
|
-
if (error) {
|
|
1120
|
-
log.error('Could not add admin', { err: error, domainId: req.params.domainId, userAddEmail: req.params.email, context: 'remove_admin', user: req.user ? toJson(req.user.simple()) : null });
|
|
1121
|
-
res.sendStatus(500);
|
|
1122
|
-
}
|
|
1123
|
-
else if (user && domain) {
|
|
1124
|
-
domain.addDomainAdmins(user).then(function (results) {
|
|
1125
|
-
log.info('Admin Added', { context: 'add_admin', domainId: req.params.domainId, userAddEmail: req.params.email, user: req.user ? toJson(req.user.simple()) : null });
|
|
1126
|
-
res.sendStatus(200);
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
else {
|
|
1130
|
-
res.sendStatus(404);
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
});
|
|
1134
|
-
router.delete('/:domainId/:userId/remove_user', auth.can('edit domain'), function (req, res) {
|
|
1135
|
-
getDomainAndUser(req.params.domainId, req.params.userId, null, function (error, domain, user) {
|
|
1136
|
-
if (error) {
|
|
1137
|
-
log.error('Could not remove_user', { err: error, domainId: req.params.domainId, userRemovedId: req.params.userId, context: 'remove_user', user: req.user ? toJson(req.user.simple()) : null });
|
|
1138
|
-
res.sendStatus(500);
|
|
1139
|
-
}
|
|
1140
|
-
else if (user && domain) {
|
|
1141
|
-
domain.removeDomainUsers(user).then(function (results) {
|
|
1142
|
-
if (domain.counter_users > 0) {
|
|
1143
|
-
domain.decrement("counter_users");
|
|
1144
|
-
}
|
|
1145
|
-
log.info('User removed', { context: 'remove_user', domainId: req.params.domainId, userRemovedId: req.params.userId, user: req.user ? toJson(req.user.simple()) : null });
|
|
1146
|
-
res.sendStatus(200);
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
else {
|
|
1150
|
-
res.sendStatus(404);
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1153
|
-
});
|
|
1154
|
-
router.get('/:domainId/export_logins', auth.can('edit domain'), function (req, res) {
|
|
1155
|
-
getLoginsExportDataForDomain(req.params.domainId, req.ypDomain.domain_name, function (error, fileData) {
|
|
1156
|
-
if (error) {
|
|
1157
|
-
log.error('Could not export logins for domain', { err: error, context: 'export_group', user: toJson(req.user.simple()) });
|
|
1158
|
-
res.sendStatus(500);
|
|
1159
|
-
}
|
|
1160
|
-
else {
|
|
1161
|
-
models.Domain.findOne({
|
|
1162
|
-
where: {
|
|
1163
|
-
id: req.params.domainId
|
|
1164
|
-
},
|
|
1165
|
-
attributes: ["id", "name"]
|
|
1166
|
-
}).then(function (model) {
|
|
1167
|
-
if (model) {
|
|
1168
|
-
log.info('Got Login Exports', { context: 'export_logins', user: toJson(req.user.simple()) });
|
|
1169
|
-
var domainName = sanitizeFilename(model.name).replace(/ /g, '');
|
|
1170
|
-
var dateString = moment(new Date()).format("DD_MM_YY_HH_mm");
|
|
1171
|
-
var filename = 'logins_export_for_domain_id_' + model.id + '_' +
|
|
1172
|
-
domainName + '_' + dateString + '.csv';
|
|
1173
|
-
res.set({ 'content-type': 'application/octet-stream; charset=utf-8' });
|
|
1174
|
-
res.charset = 'utf-8';
|
|
1175
|
-
res.attachment(filename);
|
|
1176
|
-
res.send(fileData);
|
|
1177
|
-
}
|
|
1178
|
-
else {
|
|
1179
|
-
log.error('Cant find domain', { err: error, context: 'export_logins', user: toJson(req.user.simple()) });
|
|
1180
|
-
res.sendStatus(404);
|
|
1181
|
-
}
|
|
1182
|
-
}).catch(function (error) {
|
|
1183
|
-
log.error('Could not export for domain', { err: error, context: 'export_logins', user: toJson(req.user.simple()) });
|
|
1184
|
-
res.sendStatus(500);
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
});
|
|
1189
|
-
// WORD CLOUD
|
|
1190
|
-
router.get('/:id/wordcloud', auth.can('edit domain'), function (req, res) {
|
|
1191
|
-
getFromAnalyticsApi(req, "wordclouds", "domain", req.params.id, function (error, content) {
|
|
1192
|
-
sendBackAnalyticsResultsOrError(req, res, error, content);
|
|
1193
|
-
});
|
|
1194
|
-
});
|
|
1195
|
-
// SIMILARITIES
|
|
1196
|
-
router.get('/:id/similarities_weights', auth.can('edit domain'), function (req, res) {
|
|
1197
|
-
getFromAnalyticsApi(req, "similarities_weights", "domain", req.params.id, function (error, content) {
|
|
1198
|
-
sendBackAnalyticsResultsOrError(req, res, error ? error : content.body ? null : 'noBody', getParsedSimilaritiesContent(content));
|
|
1199
|
-
});
|
|
1200
|
-
});
|
|
1201
|
-
// STATS
|
|
1202
|
-
router.get('/:id/stats_posts', auth.can('edit domain'), function (req, res) {
|
|
1203
|
-
countModelRowsByTimePeriod(req, "stats_posts" + req.params.id + "_domain", models.Post, {}, getDomainIncludes(req.params.id), (error, results) => {
|
|
1204
|
-
sendBackAnalyticsResultsOrError(req, res, error, results);
|
|
1205
|
-
});
|
|
1206
|
-
});
|
|
1207
|
-
router.get('/:id/stats_points', auth.can('edit domain'), function (req, res) {
|
|
1208
|
-
countModelRowsByTimePeriod(req, "stats_points" + req.params.id + "_domain", models.Point, {}, getPointDomainIncludes(req.params.id), (error, results) => {
|
|
1209
|
-
sendBackAnalyticsResultsOrError(req, res, error, results);
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
router.get('/:id/stats_votes', auth.can('edit domain'), function (req, res) {
|
|
1213
|
-
countModelRowsByTimePeriod(req, "stats_votes_" + req.params.id + "_domain", models.AcActivity, {
|
|
1214
|
-
type: {
|
|
1215
|
-
$in: [
|
|
1216
|
-
"activity.post.opposition.new", "activity.post.endorsement.new",
|
|
1217
|
-
"activity.point.helpful.new", "activity.point.unhelpful.new"
|
|
1218
|
-
]
|
|
1219
|
-
}
|
|
1220
|
-
}, getDomainIncludes(req.params.id), (error, results) => {
|
|
1221
|
-
sendBackAnalyticsResultsOrError(req, res, error, results);
|
|
1222
|
-
});
|
|
1223
|
-
});
|
|
1224
|
-
router.put('/:domainId/plausibleStatsProxy', auth.can('edit domain'), async (req, res) => {
|
|
1225
|
-
try {
|
|
1226
|
-
const plausibleData = await plausibleStatsProxy(req.body.plausibleUrl, { domainId: req.params.domainId });
|
|
1227
|
-
res.send(plausibleData);
|
|
1228
|
-
}
|
|
1229
|
-
catch (error) {
|
|
1230
|
-
log.error('Could not get plausibleStatsProxy', { err: error, context: 'getPlausibleSeries', user: toJson(req.user.simple()) });
|
|
1231
|
-
res.sendStatus(500);
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1234
|
-
router.get('/:domainId/get_campaigns', auth.can('edit domain'), async (req, res) => {
|
|
1235
|
-
try {
|
|
1236
|
-
const campaigns = await models.Campaign.findAll({
|
|
1237
|
-
where: {
|
|
1238
|
-
domain_id: req.params.domainId,
|
|
1239
|
-
active: true
|
|
1240
|
-
},
|
|
1241
|
-
order: [
|
|
1242
|
-
['created_at', 'desc']
|
|
1243
|
-
],
|
|
1244
|
-
attributes: ['id', 'configuration']
|
|
1245
|
-
});
|
|
1246
|
-
res.send(campaigns);
|
|
1247
|
-
}
|
|
1248
|
-
catch (error) {
|
|
1249
|
-
log.error('Could not get campaigns', { err: error, context: 'get_campaigns', user: toJson(req.user.simple()) });
|
|
1250
|
-
res.sendStatus(500);
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
router.post('/:domainId/create_campaign', auth.can('edit domain'), async (req, res) => {
|
|
1254
|
-
try {
|
|
1255
|
-
const campaign = models.Campaign.build({
|
|
1256
|
-
domain_id: req.params.domainId,
|
|
1257
|
-
configuration: req.body.configuration,
|
|
1258
|
-
user_id: req.user.id
|
|
1259
|
-
});
|
|
1260
|
-
await campaign.save();
|
|
1261
|
-
//TODO: Toxicity check
|
|
1262
|
-
res.send(campaign);
|
|
1263
|
-
}
|
|
1264
|
-
catch (error) {
|
|
1265
|
-
log.error('Could not create_campaign campaigns', { err: error, context: 'create_campaign', user: toJson(req.user.simple()) });
|
|
1266
|
-
res.sendStatus(500);
|
|
1267
|
-
}
|
|
1268
|
-
});
|
|
1269
|
-
router.put('/:domainId/:campaignId/update_campaign', auth.can('edit domain'), async (req, res) => {
|
|
1270
|
-
try {
|
|
1271
|
-
const campaign = await models.Campaign.findOne({
|
|
1272
|
-
where: {
|
|
1273
|
-
id: req.params.campaignId,
|
|
1274
|
-
domain_id: req.params.domainId
|
|
1275
|
-
},
|
|
1276
|
-
attributes: ['id', 'configuration']
|
|
1277
|
-
});
|
|
1278
|
-
campaign.configuration = req.body.configuration;
|
|
1279
|
-
await campaign.save();
|
|
1280
|
-
//TODO: Toxicity check
|
|
1281
|
-
res.send(campaign);
|
|
1282
|
-
}
|
|
1283
|
-
catch (error) {
|
|
1284
|
-
log.error('Could not create_campaign campaigns', { err: error, context: 'create_campaign', user: toJson(req.user.simple()) });
|
|
1285
|
-
res.sendStatus(500);
|
|
1286
|
-
}
|
|
1287
|
-
});
|
|
1288
|
-
router.delete('/:domainId/:campaignId/delete_campaign', auth.can('edit domain'), async (req, res) => {
|
|
1289
|
-
try {
|
|
1290
|
-
const campaign = await models.Campaign.findOne({
|
|
1291
|
-
where: {
|
|
1292
|
-
id: req.params.campaignId,
|
|
1293
|
-
domain_id: req.params.domainId
|
|
1294
|
-
},
|
|
1295
|
-
attributes: ['id']
|
|
1296
|
-
});
|
|
1297
|
-
campaign.deleted = true;
|
|
1298
|
-
await campaign.save();
|
|
1299
|
-
res.sendStatus(200);
|
|
1300
|
-
}
|
|
1301
|
-
catch (error) {
|
|
1302
|
-
log.error('Could not delete_campaign campaigns', { err: error, context: 'delete_campaign', user: toJson(req.user.simple()) });
|
|
1303
|
-
res.sendStatus(500);
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
//TODO: Move permission back to edit after figuring out how
|
|
1307
|
-
router.post('/:domainId/:start_generating/ai_image', auth.can('view domain'), function (req, res) {
|
|
1308
|
-
models.AcBackgroundJob.createJob({}, {}, (error, jobId) => {
|
|
1309
|
-
if (error) {
|
|
1310
|
-
log.error('Could not create backgroundJob', { err: error, context: 'start_generating_ai_image', user: toJson(req.user.simple()) });
|
|
1311
|
-
res.sendStatus(500);
|
|
1312
|
-
}
|
|
1313
|
-
else {
|
|
1314
|
-
queue.add('process-generative-ai', {
|
|
1315
|
-
type: "collection-image",
|
|
1316
|
-
userId: req.user.id,
|
|
1317
|
-
jobId: jobId,
|
|
1318
|
-
collectionId: req.params.domainId,
|
|
1319
|
-
collectionType: "domain",
|
|
1320
|
-
prompt: req.body.prompt,
|
|
1321
|
-
imageType: req.body.imageType
|
|
1322
|
-
}, 'critical');
|
|
1323
|
-
res.send({ jobId });
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
});
|
|
1327
|
-
//TODO: Move permission back to edit after figuring out how
|
|
1328
|
-
router.get('/:domainId/:jobId/poll_for_generating_ai_image', auth.can('view domain'), function (req, res) {
|
|
1329
|
-
models.AcBackgroundJob.findOne({
|
|
1330
|
-
where: {
|
|
1331
|
-
id: req.params.jobId
|
|
1332
|
-
},
|
|
1333
|
-
attributes: ['id', 'progress', 'error', 'data']
|
|
1334
|
-
}).then(job => {
|
|
1335
|
-
res.send(job);
|
|
1336
|
-
}).catch(error => {
|
|
1337
|
-
log.error('Could not get backgroundJob', { err: error, context: 'poll_for_generating_ai_image', user: toJson(req.user.simple()) });
|
|
1338
|
-
res.sendStatus(500);
|
|
1339
|
-
});
|
|
1340
|
-
});
|
|
1341
|
-
module.exports = router;
|