@yrpri/api 9.0.101 → 9.0.103
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/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +11 -1
- package/active-citizen/llms/baseChatBot.js +8 -75
- package/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
- package/active-citizen/llms/imageGeneration/collectionImageGenerator.js +6 -0
- package/agents/assistants/agentAssistant.js +3 -2
- package/agents/assistants/baseAssistant.js +7 -30
- package/agents/assistants/baseAssistantWithVoice.js +3 -3
- package/agents/assistants/voiceAssistant.js +2 -2
- package/agents/controllers/agentProductController.js +2 -1
- package/agents/controllers/agentSubscriptionController.js +20 -11
- package/agents/controllers/assistantsController.js +171 -127
- package/agents/controllers/policySynthAgents.js +33 -12
- package/agents/managers/newAiModelSetup.js +96 -0
- package/agents/managers/subscriptionManager.js +2 -2
- package/app.js +12 -12
- package/authorization.cjs +4 -0
- package/controllers/allOurIdeas.js +2 -1
- package/controllers/communities.cjs +47 -1
- package/controllers/groups.cjs +67 -4
- package/controllers/index.cjs +7 -7
- package/controllers/nonSpa.cjs +1 -1
- package/dist/active-citizen/controllers/activities.cjs +174 -0
- package/dist/active-citizen/controllers/news_feeds.cjs +96 -0
- package/dist/active-citizen/controllers/notifications.cjs +243 -0
- package/dist/active-citizen/controllers/recommendations.cjs +280 -0
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +204 -0
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +66 -0
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +38 -0
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +334 -0
- package/dist/active-citizen/engine/analytics/importer.js +308 -0
- package/dist/active-citizen/engine/analytics/manager.cjs +377 -0
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +500 -0
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +194 -0
- package/dist/active-citizen/engine/analytics/utils.cjs +369 -0
- package/dist/active-citizen/engine/marketing/campaign.cjs +90 -0
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +313 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +239 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +211 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +120 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +114 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +101 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +84 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +15 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +133 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +185 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +184 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +170 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +109 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +140 -0
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +279 -0
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +386 -0
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +49 -0
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +68 -0
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +288 -0
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +33 -0
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +56 -0
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +106 -0
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +344 -0
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +810 -0
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +15 -0
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +362 -0
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +268 -0
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +439 -0
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +569 -0
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +233 -0
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +118 -0
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +41 -0
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +148 -0
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +54 -0
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +31 -0
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +471 -0
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +212 -0
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +153 -0
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +80 -0
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +157 -0
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +139 -0
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +212 -0
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +83 -0
- package/dist/active-citizen/engine/reports/commonUtils.js +75 -0
- package/dist/active-citizen/engine/reports/common_utils.cjs +740 -0
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +596 -0
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +232 -0
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +277 -0
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +718 -0
- package/dist/active-citizen/llms/baseChatBot.js +183 -0
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +56 -0
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +109 -0
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +84 -0
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +49 -0
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +64 -0
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +107 -0
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +110 -0
- package/dist/active-citizen/llms/llmTranslation.js +472 -0
- package/dist/active-citizen/models/ac_activity.cjs +216 -0
- package/dist/active-citizen/models/ac_background_job.cjs +109 -0
- package/dist/active-citizen/models/ac_campaign.cjs +97 -0
- package/dist/active-citizen/models/ac_client_activity.cjs +23 -0
- package/dist/active-citizen/models/ac_delayed_notification.cjs +43 -0
- package/dist/active-citizen/models/ac_following.cjs +43 -0
- package/dist/active-citizen/models/ac_list.cjs +68 -0
- package/dist/active-citizen/models/ac_list_users.cjs +19 -0
- package/dist/active-citizen/models/ac_mute.cjs +27 -0
- package/dist/active-citizen/models/ac_news_feed_item.cjs +57 -0
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +59 -0
- package/dist/active-citizen/models/ac_notification.cjs +292 -0
- package/dist/active-citizen/models/ac_translation_cache.cjs +750 -0
- package/dist/active-citizen/models/ac_watching.cjs +31 -0
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +13 -0
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +63 -0
- package/dist/active-citizen/scripts/kue_status.js +31 -0
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +24 -0
- package/dist/active-citizen/scripts/translation_clear_language.js +117 -0
- package/dist/active-citizen/scripts/translation_delete.js +27 -0
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +180 -0
- package/dist/active-citizen/scripts/translation_update.js +28 -0
- package/dist/active-citizen/scripts/translations_list.js +27 -0
- package/{active-citizen/utils/airbrake.js → dist/active-citizen/utils/airbrake.cjs} +1 -1
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +21 -0
- package/dist/active-citizen/utils/i18n.cjs +3 -0
- package/dist/active-citizen/utils/logger.cjs +25 -0
- package/dist/active-citizen/utils/redisConnection.cjs +29 -0
- package/dist/active-citizen/utils/to_json.cjs +9 -0
- package/dist/active-citizen/utils/translation_cloning.cjs +171 -0
- package/dist/active-citizen/utils/translation_helpers.cjs +534 -0
- package/dist/active-citizen/utils/truncate_text.cjs +21 -0
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +253 -0
- package/dist/active-citizen/utils/updateLocaleFolders.js +34 -0
- package/dist/active-citizen/workers/activity.cjs +189 -0
- package/dist/active-citizen/workers/anonymizations.cjs +734 -0
- package/dist/active-citizen/workers/bulk_status_update.cjs +458 -0
- package/dist/active-citizen/workers/delayed_jobs.cjs +244 -0
- package/dist/active-citizen/workers/deletions.cjs +1911 -0
- package/dist/active-citizen/workers/email.cjs +9 -0
- package/dist/active-citizen/workers/fraud_management.cjs +109 -0
- package/dist/active-citizen/workers/generativeAi.js +56 -0
- package/dist/active-citizen/workers/main.cjs +89 -0
- package/dist/active-citizen/workers/marketing.cjs +25 -0
- package/dist/active-citizen/workers/moderation.cjs +73 -0
- package/dist/active-citizen/workers/notification_delivery.cjs +368 -0
- package/dist/active-citizen/workers/notification_news_feed.cjs +142 -0
- package/dist/active-citizen/workers/queue.cjs +99 -0
- package/dist/active-citizen/workers/recount.cjs +74 -0
- package/dist/active-citizen/workers/reports.cjs +42 -0
- package/dist/active-citizen/workers/similarities.cjs +21 -0
- package/dist/active-citizen/workers/speech_to_text.cjs +482 -0
- package/dist/agents/assistants/agentAssistant.js +88 -0
- package/dist/agents/assistants/baseAssistant.js +888 -0
- package/dist/agents/assistants/baseAssistantWithVoice.js +150 -0
- package/dist/agents/assistants/modes/agentDirectConnection.js +84 -0
- package/dist/agents/assistants/modes/agentSelectionMode.js +44 -0
- package/dist/agents/assistants/modes/baseAssistantMode.js +54 -0
- package/dist/agents/assistants/modes/tools/agentTools.js +447 -0
- package/dist/agents/assistants/modes/tools/baseTools.js +58 -0
- package/dist/agents/assistants/modes/tools/loginTools.js +156 -0
- package/dist/agents/assistants/modes/tools/models/agents.js +146 -0
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +332 -0
- package/dist/agents/assistants/modes/tools/models/users.js +11 -0
- package/dist/agents/assistants/modes/tools/navigationTools.js +166 -0
- package/{agents/assistants/modes/tools/workflowConversationTools.js → dist/agents/assistants/modes/tools/subscriptionTools.js} +1 -4
- package/{agents/assistants/modes/tools/workflowTools.js → dist/agents/assistants/modes/tools/workflowConverstationTools.js} +1 -1
- package/dist/agents/assistants/voiceAssistant.js +619 -0
- package/dist/agents/controllers/agentProductController.js +103 -0
- package/dist/agents/controllers/agentSubscriptionController.js +261 -0
- package/dist/agents/controllers/assistantsController.js +511 -0
- package/dist/agents/controllers/policySynthAgents.js +395 -0
- package/{agents → dist/agents/managers}/agentProductManager.js +2 -2
- package/dist/agents/managers/emailInvitesManager.js +55 -0
- package/dist/agents/managers/emailTemplateRenderer.js +362 -0
- package/dist/agents/managers/newAiModelSetup.js +650 -0
- package/dist/agents/managers/notificationAgentQueueManager.js +510 -0
- package/dist/agents/managers/subscriptionManager.js +535 -0
- package/dist/agents/managers/workflowConversationManager.js +79 -0
- package/dist/agents/models/agentProduct.js +116 -0
- package/dist/agents/models/agentProductBoosterPurchase.js +58 -0
- package/dist/agents/models/agentProductBundle.js +68 -0
- package/dist/agents/models/agentProductRun.js +52 -0
- package/dist/agents/models/discount.js +88 -0
- package/dist/agents/models/subscription.js +79 -0
- package/dist/agents/models/subscriptionPlan.js +46 -0
- package/dist/agents/models/subscriptionUser.js +27 -0
- package/dist/agents/models/testData/createEvolyAgentProduct.js +477 -0
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +230 -0
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +233 -0
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +230 -0
- package/{agents/models/workflowConverstation.js → dist/agents/models/workflowConversation.js} +1 -1
- package/{agents/tools/updateTemplateWorkflow.js → dist/agents/tools/setTemplateWorkflowCommunityId.js} +1 -0
- package/dist/app.js +943 -0
- package/dist/authorization.cjs +1860 -0
- package/dist/bot_control.js +1930 -0
- package/dist/config/config.cjs +14 -0
- package/dist/config/config.js +14 -0
- package/dist/controllers/allOurIdeas.js +696 -0
- package/dist/controllers/audios.cjs +100 -0
- package/dist/controllers/bulkStatusUpdates.cjs +202 -0
- package/dist/controllers/categories.cjs +199 -0
- package/dist/controllers/communities.cjs +2996 -0
- package/dist/controllers/domains.cjs +1341 -0
- package/dist/controllers/externalIds.cjs +223 -0
- package/dist/controllers/groups.cjs +4309 -0
- package/dist/controllers/images.cjs +499 -0
- package/dist/controllers/index.cjs +449 -0
- package/dist/controllers/legacyPages.cjs +35 -0
- package/dist/controllers/legacyPosts.cjs +56 -0
- package/dist/controllers/legacyUsers.cjs +36 -0
- package/dist/controllers/nonSpa.cjs +574 -0
- package/dist/controllers/organizations.cjs +250 -0
- package/dist/controllers/points.cjs +1137 -0
- package/dist/controllers/posts.cjs +2036 -0
- package/dist/controllers/ratings.cjs +234 -0
- package/dist/controllers/users.cjs +2255 -0
- package/dist/controllers/videos.cjs +226 -0
- package/dist/deleteUnwantedDeclerations.cjs +55 -0
- package/dist/migrations/agentAuditLogs.cjs +46 -0
- package/dist/migrations/agentClasses.cjs +60 -0
- package/dist/migrations/agentConnectorClasses.cjs +61 -0
- package/dist/migrations/agentConnectors.cjs +50 -0
- package/dist/migrations/agentEvals.cjs +45 -0
- package/dist/migrations/agentRegistries.cjs +40 -0
- package/dist/migrations/agents.cjs +54 -0
- package/dist/migrations/aiModels.cjs +49 -0
- package/dist/migrations/apiUsage.cjs +47 -0
- package/dist/migrations/apis.cjs +49 -0
- package/dist/migrations/groupPrivateData.cjs +30 -0
- package/dist/migrations/modelUsage.cjs +60 -0
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +23 -0
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +360 -0
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +29 -0
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +43 -0
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +24 -0
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +29 -0
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +22 -0
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +23 -0
- package/{migrations/200824_create_embeddings_and_org_update.cjs → dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js} +6 -3
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +43 -0
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +36 -0
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +41 -0
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +88 -0
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +33 -0
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +38 -0
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +19 -0
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +19 -0
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +127 -0
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +68 -0
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +63 -0
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +14 -0
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +71 -0
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +12 -0
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +46 -0
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +46 -0
- package/dist/migrations/privateAccessStore.cjs +55 -0
- package/dist/migrations/zzz_associations.cjs +154 -0
- package/dist/migrations/zzzzz_create_agent_runs.cjs +606 -0
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +11 -0
- package/dist/migrations/zzzzzzz_create_trees.cjs +81 -0
- package/dist/models/audio.cjs +430 -0
- package/dist/models/bulk_status_update.cjs +58 -0
- package/dist/models/campaign.cjs +78 -0
- package/dist/models/category.cjs +94 -0
- package/dist/models/community.cjs +337 -0
- package/dist/models/domain.cjs +486 -0
- package/dist/models/endorsement.cjs +39 -0
- package/dist/models/general_data_store.cjs +20 -0
- package/dist/models/group.cjs +728 -0
- package/dist/models/image.cjs +579 -0
- package/dist/models/index.cjs +186 -0
- package/dist/models/invite.cjs +48 -0
- package/dist/models/iso_country.cjs +16 -0
- package/dist/models/organization.cjs +122 -0
- package/dist/models/page.cjs +273 -0
- package/dist/models/point.cjs +622 -0
- package/dist/models/point_quality.cjs +39 -0
- package/dist/models/point_revision.cjs +47 -0
- package/dist/models/post.cjs +680 -0
- package/dist/models/post_revision.cjs +38 -0
- package/dist/models/post_status_change.cjs +35 -0
- package/dist/models/promotion.cjs +34 -0
- package/dist/models/rating.cjs +51 -0
- package/dist/models/relationship.cjs +19 -0
- package/dist/models/request_to_join.cjs +20 -0
- package/dist/models/user.cjs +604 -0
- package/dist/models/user_legacy_password.cjs +13 -0
- package/dist/models/video.cjs +1137 -0
- package/dist/publish.js +40 -0
- package/dist/repack.js +53 -0
- package/dist/scripts/addRatingUsersToGroup.js +51 -0
- package/dist/scripts/addUserToOrganization.js +71 -0
- package/dist/scripts/analyseRatingsForCommunity.js +150 -0
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +28 -0
- package/dist/scripts/analyzeEndorsementsByCountry.js +70 -0
- package/dist/scripts/analyzePostsForCommunity.js +185 -0
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +14 -0
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +110 -0
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +116 -0
- package/{scripts/bulkStatusUpdates/performUpdateForGroup.js → dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs} +1 -2
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +141 -0
- package/dist/scripts/change/changeVideoAspectTo.js +34 -0
- package/dist/scripts/change/setUseNewVersion.cjs +22 -0
- package/dist/scripts/changeCommunityGroupcount.js +30 -0
- package/dist/scripts/changeCommunityPostCount.js +30 -0
- package/dist/scripts/changeGroupPostCount.js +30 -0
- package/dist/scripts/changeLanguage.js +50 -0
- package/dist/scripts/changeOfficalStatus.js +30 -0
- package/{scripts/cleanups/deleteAnonNotifications.js → dist/scripts/cleanups/deleteAnonNotifications.cjs} +1 -1
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +62 -0
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +72 -0
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +43 -0
- package/dist/scripts/clearAllEndorsementInGroup.js +50 -0
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +129 -0
- package/dist/scripts/cloning/cloneFromUrlScript.js +65 -0
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +140 -0
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +140 -0
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +131 -0
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +173 -0
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +18 -0
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +17 -0
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +17 -0
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +26 -0
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +205 -0
- package/dist/scripts/cloning/copyPostToGroupOld.js +397 -0
- package/dist/scripts/cloning/copyPostVideosFromURL.js +236 -0
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +17 -0
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +131 -0
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +139 -0
- package/dist/scripts/cloning/setAdminsFromURL.js +161 -0
- package/dist/scripts/cloning/setExternalIdsFromURL.js +129 -0
- package/dist/scripts/countCommunity.js +291 -0
- package/dist/scripts/countCommunityUsers.js +152 -0
- package/dist/scripts/countDelayedNotifications.js +18 -0
- package/dist/scripts/countGroup.js +246 -0
- package/dist/scripts/countStuff.js +67 -0
- package/dist/scripts/countUniqueVotersInAGroup.js +48 -0
- package/dist/scripts/createInvitesAndShow.js +75 -0
- package/dist/scripts/database/sync_database.js +14 -0
- package/dist/scripts/database/sync_dev_database.js +17 -0
- package/dist/scripts/debugNotifications.js +58 -0
- package/dist/scripts/deleteAllNewsFeeds.js +10 -0
- package/dist/scripts/deleteCategory.js +13 -0
- package/dist/scripts/deleteOldAppActivities.js +40 -0
- package/dist/scripts/deletePostContactDataForCommunity.js +53 -0
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +1026 -0
- package/dist/scripts/displayAuthorForPost.js +16 -0
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +183 -0
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +208 -0
- package/dist/scripts/exportAllStatusChanges.js +36 -0
- package/dist/scripts/exportClientAcitivity.js +36 -0
- package/dist/scripts/exportEndorsementsForCommunity.js +79 -0
- package/dist/scripts/exportPointQualitiesForCommunity.js +84 -0
- package/dist/scripts/exportPostsAndPointsForCommunity.js +147 -0
- package/dist/scripts/exportPostsDataSetForDomain.js +244 -0
- package/dist/scripts/exportPostsForGroup.js +173 -0
- package/dist/scripts/exportRatingsForPost.js +15 -0
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +123 -0
- package/dist/scripts/exportUsersForCommunity.js +24 -0
- package/dist/scripts/exportUsersForDomain.js +24 -0
- package/dist/scripts/exportUsersForGroup.js +24 -0
- package/dist/scripts/exports/ratingDistribution.js +71 -0
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +56 -0
- package/dist/scripts/findUnusedClientImports.js +56 -0
- package/dist/scripts/fixAllPostPointCounts.js +22 -0
- package/dist/scripts/fixAnonNotificationsSettings.js +48 -0
- package/dist/scripts/fixCountKopavogur.js +9 -0
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +190 -0
- package/dist/scripts/fixExternalUserId.js +24 -0
- package/dist/scripts/fixGroupAccess.js +16 -0
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +49 -0
- package/dist/scripts/fixNotificationSettings.js +39 -0
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +64 -0
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +49 -0
- package/dist/scripts/gallery/exportGalleryData.js +40 -0
- package/dist/scripts/gallery/importGalleryForCommunity.js +168 -0
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +55 -0
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +58 -0
- package/dist/scripts/genderAnalysis.js +63 -0
- package/dist/scripts/genderAnalysisByStatus.js +62 -0
- package/dist/scripts/importAllLocalesFromLocalFolders.js +55 -0
- package/dist/scripts/importDomain.js +1652 -0
- package/dist/scripts/keys/addOidcToDomain.cjs +61 -0
- package/dist/scripts/landUseGame/export3Ddata.js +162 -0
- package/dist/scripts/listLanguagesForGroup.js +54 -0
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +27 -0
- package/dist/scripts/makeRecursiveMapData.js +103 -0
- package/dist/scripts/mapping/community_map_csv.js +145 -0
- package/dist/scripts/moveCommunityToDomain.js +22 -0
- package/dist/scripts/moveGroupToCommunity.js +23 -0
- package/dist/scripts/movePostToGroup.js +101 -0
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +297 -0
- package/dist/scripts/oldMovePostToGroup.js +153 -0
- package/dist/scripts/processCsvForPdfUrls.js +37 -0
- package/dist/scripts/processCsvForTranslationAndToxicity.js +125 -0
- package/dist/scripts/recount/recount_recursive_communities.js +125 -0
- package/dist/scripts/recountALLCommunityGroupCounts.js +37 -0
- package/dist/scripts/recountAll.js +97 -0
- package/dist/scripts/recountCommunitesFromUrl.js +58 -0
- package/dist/scripts/recountCommunity.js +19 -0
- package/dist/scripts/recountGroup.js +218 -0
- package/dist/scripts/recountGroupNoUserChange.js +219 -0
- package/dist/scripts/resetAllEndorsementsForGroup.js +57 -0
- package/dist/scripts/resetEnTranslationForGroup.js +45 -0
- package/dist/scripts/setAdminOnAll.cjs +107 -0
- package/{scripts/change → dist/scripts}/setDomainAdmin.cjs +0 -2
- package/dist/scripts/setDomainLocales.js +33 -0
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +29 -0
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +86 -0
- package/dist/scripts/setMemberOfAll.js +101 -0
- package/dist/scripts/setNewUserForContentOfCommunity.js +189 -0
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +35 -0
- package/dist/scripts/setUserOnAll.js +101 -0
- package/dist/scripts/showCategoryForGroup.js +18 -0
- package/dist/scripts/showOldActivityTypes.js +14 -0
- package/dist/scripts/showPostsMissingCategoryForGroup.js +17 -0
- package/dist/scripts/showStatuses.js +17 -0
- package/dist/scripts/showUniqueVotersInCommunity.js +61 -0
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +66 -0
- package/dist/scripts/simpleExportForGroupsForCommunity.js +46 -0
- package/dist/scripts/simpleExportForPointsForCommunity.js +82 -0
- package/dist/scripts/simpleExportForPostsForCommunity.js +61 -0
- package/dist/scripts/testForEndorsments.js +21 -0
- package/dist/scripts/undeleteGroupAndAllContent.js +151 -0
- package/dist/scripts/undeletePost.js +135 -0
- package/dist/scripts/unlinkSsn.js +23 -0
- package/dist/scripts/updateFromAlthingi.js +303 -0
- package/dist/server.js +3 -0
- package/dist/utils/airbrake.cjs +17 -0
- package/dist/utils/cjsCodeReview.js +99 -0
- package/dist/utils/community_mapping_tools.cjs +124 -0
- package/dist/utils/copy_utils.cjs +1399 -0
- package/dist/utils/docx_utils.cjs +464 -0
- package/dist/utils/export_utils.cjs +491 -0
- package/dist/utils/i18n.cjs +17 -0
- package/dist/utils/is_valid_db_id.cjs +28 -0
- package/dist/utils/logger.cjs +25 -0
- package/dist/utils/loggerTs.js +26 -0
- package/dist/utils/manifest_generator.cjs +104 -0
- package/dist/utils/parse_domain.cjs +16 -0
- package/dist/utils/recount_utils.cjs +415 -0
- package/dist/utils/sharing_parameters.cjs +111 -0
- package/dist/utils/sitemap_generator.cjs +286 -0
- package/dist/utils/to_json.cjs +14 -0
- package/dist/utils/ypLanguages.js +747 -0
- package/dist/webSockets.js +77 -0
- package/package.json +46 -44
- package/server.d.ts +104 -2
- package/utils/copy_utils.cjs +7 -1
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts +0 -21
- package/active-citizen/engine/allOurIdeas/aiHelper.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/explainAnswersAssistant.d.ts.map +0 -1
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts +0 -12
- package/active-citizen/engine/allOurIdeas/iconGenerator.d.ts.map +0 -1
- package/active-citizen/engine/analytics/export_anon_community_activities.d.ts.map +0 -1
- package/active-citizen/engine/analytics/importer.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/categories_dataset.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/dataset_tools.d.ts.map +0 -1
- package/active-citizen/engine/old/exporters/sentiment_dataset.d.ts.map +0 -1
- package/active-citizen/engine/reports/xls_all_our_ideas_export.js +0 -141
- package/active-citizen/llms/baseChatBot.d.ts +0 -51
- package/active-citizen/llms/baseChatBot.d.ts.map +0 -1
- package/active-citizen/llms/collectionImageGenerator.js +0 -357
- package/active-citizen/llms/llmTranslation.d.ts +0 -24
- package/active-citizen/llms/llmTranslation.d.ts.map +0 -1
- package/active-citizen/scripts/fix_old_delayed_notifications.d.ts.map +0 -1
- package/active-citizen/scripts/kue_status.d.ts.map +0 -1
- package/active-citizen/scripts/kue_watch_stuck_jobs.d.ts.map +0 -1
- package/active-citizen/scripts/translation_clear_language.d.ts.map +0 -1
- package/active-citizen/scripts/translation_delete.d.ts.map +0 -1
- package/active-citizen/scripts/translation_replace_text_from_url.d.ts.map +0 -1
- package/active-citizen/scripts/translation_update.d.ts.map +0 -1
- package/active-citizen/scripts/translations_list.d.ts.map +0 -1
- package/active-citizen/utils/airbrake.d.ts.map +0 -1
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts +0 -21
- package/active-citizen/utils/updateAllLocalesFromEn.d.ts.map +0 -1
- package/active-citizen/utils/updateLocaleFolders.d.ts +0 -2
- package/active-citizen/utils/updateLocaleFolders.d.ts.map +0 -1
- package/active-citizen/workers/cloudflare/voiceSession/worker.js +0 -213
- package/active-citizen/workers/generativeAi.d.ts.map +0 -1
- package/agents/assistants/agentAssistantOld.js +0 -863
- package/agents/assistants/modes/agentConfigurationMode.js +0 -63
- package/agents/assistants/modes/agentOperationsMode.js +0 -195
- package/agents/assistants/modes/commonTools.js +0 -58
- package/agents/assistants/modes/directConversationMode.js +0 -14
- package/agents/assistants/modes/toolHandlers/accountHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/commonHandlers.js +0 -57
- package/agents/assistants/modes/toolHandlers/commonTools.js +0 -58
- package/agents/assistants/modes/toolHandlers/loginHandlers.js +0 -46
- package/agents/assistants/modes/toolHandlers/subscriptionHandlers.js +0 -469
- package/agents/assistants/modes/tools/agentConnectionTools.js +0 -326
- package/agents/assistants/modes/tools/commonHandlers.js +0 -57
- package/agents/assistants/modes/tools/loginHandlers.js +0 -46
- package/agents/assistants/modes/tools/subscriptionHandlers.js +0 -469
- package/agents/controllers/assistantController.js +0 -243
- package/agents/managers/workflowManager.js +0 -76
- package/agents/models/testData/setupConfig.js +0 -140
- package/agents/models/workflow.js +0 -53
- package/agents/subscriptionManager.js +0 -218
- package/app.d.ts +0 -40
- package/app.d.ts.map +0 -1
- package/bot_control.d.ts.map +0 -1
- package/publish.d.ts.map +0 -1
- package/repack.d.ts.map +0 -1
- package/scripts/addRatingUsersToGroup.d.ts.map +0 -1
- package/scripts/addUserToOrganization.d.ts.map +0 -1
- package/scripts/analyseRatingsForCommunity.d.ts.map +0 -1
- package/scripts/analyzeAndFixBrokenPointUsers.d.ts.map +0 -1
- package/scripts/analyzeEndorsementsByCountry.d.ts.map +0 -1
- package/scripts/analyzePostsForCommunity.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/listUpdates.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdate.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForGroup.d.ts.map +0 -1
- package/scripts/bulkStatusUpdates/performUpdateForStatus.d.ts.map +0 -1
- package/scripts/change/changeVideoAspectTo.d.ts.map +0 -1
- package/scripts/changeCommunityGroupcount.d.ts.map +0 -1
- package/scripts/changeCommunityPostCount.d.ts.map +0 -1
- package/scripts/changeGroupPostCount.d.ts.map +0 -1
- package/scripts/changeLanguage.d.ts.map +0 -1
- package/scripts/changeOfficalStatus.d.ts.map +0 -1
- package/scripts/cleanups/deleteAnonNotifications.d.ts.map +0 -1
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.d.ts.map +0 -1
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.d.ts.map +0 -1
- package/scripts/clearAllEndorsementInGroup.d.ts.map +0 -1
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.d.ts.map +0 -1
- package/scripts/cloning/cloneFromUrlScript.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.d.ts.map +0 -1
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithEverything.d.ts.map +0 -1
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.d.ts.map +0 -1
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostToGroupOld.d.ts.map +0 -1
- package/scripts/cloning/copyPostVideosFromURL.d.ts.map +0 -1
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.d.ts.map +0 -1
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.d.ts.map +0 -1
- package/scripts/cloning/setAdminsFromURL.d.ts.map +0 -1
- package/scripts/cloning/setExternalIdsFromURL.d.ts.map +0 -1
- package/scripts/countCommunity.d.ts.map +0 -1
- package/scripts/countCommunityUsers.d.ts.map +0 -1
- package/scripts/countDelayedNotifications.d.ts.map +0 -1
- package/scripts/countGroup.d.ts.map +0 -1
- package/scripts/countStuff.d.ts.map +0 -1
- package/scripts/countUniqueVotersInAGroup.d.ts.map +0 -1
- package/scripts/createInvitesAndShow.d.ts.map +0 -1
- package/scripts/database/seedTestAiModels.js +0 -64
- package/scripts/database/sync_database.d.ts.map +0 -1
- package/scripts/database/sync_dev_database.d.ts.map +0 -1
- package/scripts/debugNotifications.d.ts.map +0 -1
- package/scripts/deleteAllNewsFeeds.d.ts.map +0 -1
- package/scripts/deleteCategory.d.ts.map +0 -1
- package/scripts/deleteOldAppActivities.d.ts.map +0 -1
- package/scripts/deletePostContactDataForCommunity.d.ts.map +0 -1
- package/scripts/destroy/destroy_all_but_one_domain.d.ts.map +0 -1
- package/scripts/displayAuthorForPost.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.d.ts.map +0 -1
- package/scripts/exportAllStatusChanges.d.ts.map +0 -1
- package/scripts/exportClientAcitivity.d.ts.map +0 -1
- package/scripts/exportEndorsementsForCommunity.d.ts.map +0 -1
- package/scripts/exportPointQualitiesForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsAndPointsForCommunity.d.ts.map +0 -1
- package/scripts/exportPostsDataSetForDomain.d.ts.map +0 -1
- package/scripts/exportPostsForGroup.d.ts.map +0 -1
- package/scripts/exportRatingsForPost.d.ts.map +0 -1
- package/scripts/exportUserEndorsementsWithUserAnalysis.d.ts.map +0 -1
- package/scripts/exportUsersForCommunity.d.ts.map +0 -1
- package/scripts/exportUsersForDomain.d.ts.map +0 -1
- package/scripts/exportUsersForGroup.d.ts.map +0 -1
- package/scripts/exports/ratingDistribution.d.ts.map +0 -1
- package/scripts/exports/whoEndorsedWhatByCommunity.d.ts.map +0 -1
- package/scripts/findUnusedClientImports.d.ts.map +0 -1
- package/scripts/fixAllPostPointCounts.d.ts.map +0 -1
- package/scripts/fixAnonNotificationsSettings.d.ts.map +0 -1
- package/scripts/fixCountKopavogur.d.ts.map +0 -1
- package/scripts/fixEndorsementsAfterCopyPostToGroup.d.ts.map +0 -1
- package/scripts/fixExternalUserId.d.ts.map +0 -1
- package/scripts/fixGroupAccess.d.ts.map +0 -1
- package/scripts/fixGroupIdeasAndPointsCount.d.ts.map +0 -1
- package/scripts/fixNotificationSettings.d.ts.map +0 -1
- package/scripts/fixSurveyRadioBakedInSubCodes.d.ts.map +0 -1
- package/scripts/fixWrongUserIdForStatusUpdates.d.ts.map +0 -1
- package/scripts/gallery/exportGalleryData.d.ts.map +0 -1
- package/scripts/gallery/importGalleryForCommunity.d.ts.map +0 -1
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.d.ts.map +0 -1
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.d.ts.map +0 -1
- package/scripts/genderAnalysis.d.ts.map +0 -1
- package/scripts/genderAnalysisByStatus.d.ts.map +0 -1
- package/scripts/importAllLocalesFromLocalFolders.d.ts.map +0 -1
- package/scripts/importDomain.d.ts.map +0 -1
- package/scripts/landUseGame/export3Ddata.d.ts.map +0 -1
- package/scripts/listLanguagesForGroup.d.ts.map +0 -1
- package/scripts/loadTestCreateDummyContentForGroup.d.ts.map +0 -1
- package/scripts/makeRecursiveMapData.d.ts.map +0 -1
- package/scripts/mapping/community_map_csv.d.ts.map +0 -1
- package/scripts/moveCommunityToDomain.d.ts.map +0 -1
- package/scripts/moveGroupToCommunity.d.ts.map +0 -1
- package/scripts/movePostToGroup.d.ts.map +0 -1
- package/scripts/movePostsToGroupsRecountGroupFromUrl.d.ts.map +0 -1
- package/scripts/oldMovePostToGroup.d.ts.map +0 -1
- package/scripts/processCsvForPdfUrls.d.ts.map +0 -1
- package/scripts/processCsvForTranslationAndToxicity.d.ts.map +0 -1
- package/scripts/recount/recount_recursive_communities.d.ts.map +0 -1
- package/scripts/recountALLCommunityGroupCounts.d.ts.map +0 -1
- package/scripts/recountAll.d.ts.map +0 -1
- package/scripts/recountCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/recountCommunity.d.ts.map +0 -1
- package/scripts/recountGroup.d.ts.map +0 -1
- package/scripts/recountGroupNoUserChange.d.ts.map +0 -1
- package/scripts/resetAllEndorsementsForGroup.d.ts.map +0 -1
- package/scripts/resetEnTranslationForGroup.d.ts.map +0 -1
- package/scripts/setDomainLocales.d.ts.map +0 -1
- package/scripts/setLanguageOnGroupCommunitesFromUrl.d.ts.map +0 -1
- package/scripts/setMemberOfAll.d.ts.map +0 -1
- package/scripts/setNewUserForContentOfCommunity.d.ts.map +0 -1
- package/scripts/setOfficialStatusOnAllPostsForCommunity.d.ts.map +0 -1
- package/scripts/setUserOnAll.d.ts.map +0 -1
- package/scripts/showCategoryForGroup.d.ts.map +0 -1
- package/scripts/showOldActivityTypes.d.ts.map +0 -1
- package/scripts/showPostsMissingCategoryForGroup.d.ts.map +0 -1
- package/scripts/showStatuses.d.ts.map +0 -1
- package/scripts/showUniqueVotersInCommunity.d.ts.map +0 -1
- package/scripts/showUserAgentsAndIpsForEmails.d.ts.map +0 -1
- package/scripts/simpleExportForGroupsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPointsForCommunity.d.ts.map +0 -1
- package/scripts/simpleExportForPostsForCommunity.d.ts.map +0 -1
- package/scripts/testForEndorsments.d.ts.map +0 -1
- package/scripts/undeleteGroupAndAllContent.d.ts.map +0 -1
- package/scripts/undeletePost.d.ts.map +0 -1
- package/scripts/unlinkSsn.d.ts.map +0 -1
- package/scripts/updateFromAlthingi.d.ts.map +0 -1
- package/server.d.ts.map +0 -1
- package/utils/copyGroup.js +0 -246
- package/utils/loggerTs.d.ts +0 -4
- package/utils/loggerTs.d.ts.map +0 -1
- package/utils/ypLanguages.d.ts +0 -18
- package/utils/ypLanguages.d.ts.map +0 -1
- /package/{agents/tools/updateCommunityWorkflow.js → dist/active-citizen/llms/imageGeneration/iImageGenerator.js} +0 -0
- /package/{migrations/270724_createUsersAndAdminsForClasses.cjs → dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs} +0 -0
package/dist/app.js
ADDED
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import session from "express-session";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import morgan from "morgan";
|
|
5
|
+
import bodyParser from "body-parser";
|
|
6
|
+
import { RedisStore } from "connect-redis";
|
|
7
|
+
import useragent from "express-useragent";
|
|
8
|
+
import requestIp from "request-ip";
|
|
9
|
+
import compression from "compression";
|
|
10
|
+
import { isbot } from "isbot";
|
|
11
|
+
import rateLimit from "express-rate-limit";
|
|
12
|
+
import passport from "passport";
|
|
13
|
+
import models from "./models/index.cjs";
|
|
14
|
+
if (process.env.NEW_RELIC_APP_NAME) {
|
|
15
|
+
import("newrelic")
|
|
16
|
+
.then((newrelic) => {
|
|
17
|
+
console.log("New Relic imported", newrelic);
|
|
18
|
+
})
|
|
19
|
+
.catch((err) => {
|
|
20
|
+
console.error("Failed to import New Relic", err);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
import auth from "./authorization.cjs";
|
|
24
|
+
import index from "./controllers/index.cjs";
|
|
25
|
+
import news_feeds from "./active-citizen/controllers/news_feeds.cjs";
|
|
26
|
+
import activities from "./active-citizen/controllers/activities.cjs";
|
|
27
|
+
import notifications from "./active-citizen/controllers/notifications.cjs";
|
|
28
|
+
import recommendations from "./active-citizen/controllers/recommendations.cjs";
|
|
29
|
+
import posts from "./controllers/posts.cjs";
|
|
30
|
+
import groups from "./controllers/groups.cjs";
|
|
31
|
+
import communities from "./controllers/communities.cjs";
|
|
32
|
+
import domains from "./controllers/domains.cjs";
|
|
33
|
+
import organizations from "./controllers/organizations.cjs";
|
|
34
|
+
import points from "./controllers/points.cjs";
|
|
35
|
+
import users from "./controllers/users.cjs";
|
|
36
|
+
import categories from "./controllers/categories.cjs";
|
|
37
|
+
import images from "./controllers/images.cjs";
|
|
38
|
+
import externalIds from "./controllers/externalIds.cjs";
|
|
39
|
+
import ratings from "./controllers/ratings.cjs";
|
|
40
|
+
import bulkStatusUpdates from "./controllers/bulkStatusUpdates.cjs";
|
|
41
|
+
import videos from "./controllers/videos.cjs";
|
|
42
|
+
import audios from "./controllers/audios.cjs";
|
|
43
|
+
import legacyPosts from "./controllers/legacyPosts.cjs";
|
|
44
|
+
import legacyUsers from "./controllers/legacyUsers.cjs";
|
|
45
|
+
import legacyPages from "./controllers/legacyPages.cjs";
|
|
46
|
+
import nonSPArouter from "./controllers/nonSpa.cjs";
|
|
47
|
+
import generateSitemap from "./utils/sitemap_generator.cjs";
|
|
48
|
+
import generateManifest from "./utils/manifest_generator.cjs";
|
|
49
|
+
import toJson from "./utils/to_json.cjs";
|
|
50
|
+
//@ts-ignore
|
|
51
|
+
import sso from "passport-sso";
|
|
52
|
+
import cors from "cors";
|
|
53
|
+
import log from "./utils/loggerTs.js";
|
|
54
|
+
import { createClient } from "redis";
|
|
55
|
+
import { Notifier } from "@airbrake/node";
|
|
56
|
+
import { fileURLToPath } from "url";
|
|
57
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
58
|
+
let airbrake;
|
|
59
|
+
if (process.env.AIRBRAKE_PROJECT_ID && process.env.AIRBRAKE_API_KEY) {
|
|
60
|
+
airbrake = new Notifier({
|
|
61
|
+
projectId: parseInt(process.env.AIRBRAKE_PROJECT_ID),
|
|
62
|
+
projectKey: process.env.AIRBRAKE_API_KEY,
|
|
63
|
+
performanceStats: false,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
process.on("uncaughtException", (err) => {
|
|
67
|
+
console.error("There was an uncaught error", err);
|
|
68
|
+
log.error("There was an uncaught error", err);
|
|
69
|
+
if (err.stack) {
|
|
70
|
+
console.error(err.stack);
|
|
71
|
+
log.error(err.stack);
|
|
72
|
+
}
|
|
73
|
+
if (airbrake) {
|
|
74
|
+
airbrake.notify(err).then((airbrakeErr) => {
|
|
75
|
+
if (airbrakeErr.error) {
|
|
76
|
+
log.error("AirBrake Error Internal", {
|
|
77
|
+
context: "airbrake",
|
|
78
|
+
err: airbrakeErr.error,
|
|
79
|
+
errorStatus: 500,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//TODO: What else do we want to do here? We need to exit but can we restart it right away?
|
|
85
|
+
process.exit(1);
|
|
86
|
+
});
|
|
87
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
88
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
89
|
+
log.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
90
|
+
if (reason.stack) {
|
|
91
|
+
console.error(reason.stack);
|
|
92
|
+
log.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
93
|
+
}
|
|
94
|
+
if (airbrake) {
|
|
95
|
+
airbrake.notify(reason).then((airbrakeErr) => {
|
|
96
|
+
if (airbrakeErr.error) {
|
|
97
|
+
log.error("AirBrake Error", {
|
|
98
|
+
context: "airbrake",
|
|
99
|
+
err: airbrakeErr.error,
|
|
100
|
+
errorStatus: 500,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//TODO: Look if this is safe to do in production, should be
|
|
106
|
+
if (process.env.NODE_ENV !== "production") {
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
import { botsWithJavascript, isBadBot, } from "./bot_control.js";
|
|
111
|
+
import { Op } from "sequelize";
|
|
112
|
+
import { WebSocketsManager } from "./webSockets.js";
|
|
113
|
+
export class YourPrioritiesApi {
|
|
114
|
+
constructor(port = undefined) {
|
|
115
|
+
this.determineVersion = (req) => {
|
|
116
|
+
// Check query parameter first
|
|
117
|
+
if (req.query.useNewVersion === "true")
|
|
118
|
+
return true;
|
|
119
|
+
if (req.query.useNewVersion === "false")
|
|
120
|
+
return false;
|
|
121
|
+
// Then check session
|
|
122
|
+
if (req.session.useNewVersion === true)
|
|
123
|
+
return true;
|
|
124
|
+
if (req.session.useNewVersion === false)
|
|
125
|
+
return false;
|
|
126
|
+
// Finally, check domain configuration
|
|
127
|
+
if (req.ypDomain?.configuration?.useNewVersion === true)
|
|
128
|
+
return true;
|
|
129
|
+
// Default to false (old version)
|
|
130
|
+
return false;
|
|
131
|
+
};
|
|
132
|
+
this.bearerCallback = function () {
|
|
133
|
+
return console.log("The user has tried to authenticate with a bearer token");
|
|
134
|
+
};
|
|
135
|
+
this.completeRegisterUserLogin = (user, // Replace 'any' with the actual user type
|
|
136
|
+
loginType, req, // Replace 'any' with 'YpRequest' if it's the correct type
|
|
137
|
+
done) => {
|
|
138
|
+
user.last_login_at = new Date().getTime(); // Assuming your database expects a timestamp
|
|
139
|
+
user
|
|
140
|
+
.save()
|
|
141
|
+
.then(() => {
|
|
142
|
+
models.AcActivity.createActivity({
|
|
143
|
+
type: "activity.user.login",
|
|
144
|
+
userId: user.id,
|
|
145
|
+
domainId: req.ypDomain.id,
|
|
146
|
+
communityId: req.ypCommunity ? req.ypCommunity.id : null,
|
|
147
|
+
object: {
|
|
148
|
+
loginType: loginType,
|
|
149
|
+
userDepartment: user.private_profile_data
|
|
150
|
+
? user.private_profile_data.saml_agency
|
|
151
|
+
: null,
|
|
152
|
+
samlProvider: user.private_profile_data
|
|
153
|
+
? user.private_profile_data.saml_provider
|
|
154
|
+
: null,
|
|
155
|
+
},
|
|
156
|
+
access: models.AcActivity.PRIVATE,
|
|
157
|
+
}, (error) => {
|
|
158
|
+
if (error) {
|
|
159
|
+
log.error("Error creating activity for user login", { error });
|
|
160
|
+
}
|
|
161
|
+
done();
|
|
162
|
+
});
|
|
163
|
+
})
|
|
164
|
+
.catch((error) => {
|
|
165
|
+
log.error("Error saving user for login registration", { error });
|
|
166
|
+
done();
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
this.registerUserLogin = (user, userId, loginProvider, req, done) => {
|
|
170
|
+
if (user && user.private_profile_data) {
|
|
171
|
+
this.completeRegisterUserLogin(user, loginProvider, req, done);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
models.User.findOne({
|
|
175
|
+
where: { id: userId },
|
|
176
|
+
attributes: ["id", "private_profile_data", "last_login_at"],
|
|
177
|
+
})
|
|
178
|
+
.then((user) => {
|
|
179
|
+
if (user) {
|
|
180
|
+
this.completeRegisterUserLogin(user, loginProvider, req, done);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
log.error("Did not find user for login registration", { userId });
|
|
184
|
+
done();
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
.catch((error) => {
|
|
188
|
+
log.error("Error saving user for login registration", { error });
|
|
189
|
+
done();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
this.app = express();
|
|
194
|
+
this.port = port || (process.env.PORT ? parseInt(process.env.PORT) : 4242);
|
|
195
|
+
this.wsClients = new Map();
|
|
196
|
+
this.initializeRedis();
|
|
197
|
+
this.addRedisToRequest();
|
|
198
|
+
this.addDirnameToRequest();
|
|
199
|
+
this.forceHttps();
|
|
200
|
+
this.initializeMiddlewares();
|
|
201
|
+
this.setupNewWebAppVersionHandling();
|
|
202
|
+
this.handleShortenedRedirects();
|
|
203
|
+
this.initializeRateLimiting();
|
|
204
|
+
this.setupDomainAndCommunity();
|
|
205
|
+
this.setupSitemapRoute();
|
|
206
|
+
this.initializePassportStrategies();
|
|
207
|
+
this.addInviteAsAnonMiddleWare();
|
|
208
|
+
this.setupStaticFileServing();
|
|
209
|
+
this.checkAuthForSsoInit();
|
|
210
|
+
this.initializeRoutes();
|
|
211
|
+
this.initializeEsControllers();
|
|
212
|
+
}
|
|
213
|
+
async initialize() {
|
|
214
|
+
await this.initializeRedis();
|
|
215
|
+
this.addRedisToRequest();
|
|
216
|
+
this.addDirnameToRequest();
|
|
217
|
+
this.forceHttps();
|
|
218
|
+
this.initializeMiddlewares();
|
|
219
|
+
this.setupNewWebAppVersionHandling();
|
|
220
|
+
this.handleShortenedRedirects();
|
|
221
|
+
this.initializeRateLimiting();
|
|
222
|
+
this.setupDomainAndCommunity();
|
|
223
|
+
this.setupSitemapRoute();
|
|
224
|
+
this.initializePassportStrategies();
|
|
225
|
+
this.addInviteAsAnonMiddleWare();
|
|
226
|
+
this.setupStaticFileServing();
|
|
227
|
+
this.checkAuthForSsoInit();
|
|
228
|
+
this.initializeRoutes();
|
|
229
|
+
this.initializeEsControllers();
|
|
230
|
+
}
|
|
231
|
+
setupNewWebAppVersionHandling() {
|
|
232
|
+
this.app.use((req, res, next) => {
|
|
233
|
+
req.useNewVersion = this.determineVersion(req);
|
|
234
|
+
if (req.session) {
|
|
235
|
+
req.session.useNewVersion = req.useNewVersion;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
console.error("Session not found in request");
|
|
239
|
+
}
|
|
240
|
+
next();
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
async initializeRedis() {
|
|
244
|
+
if (process.env.REDIS_URL) {
|
|
245
|
+
let redisUrl = process.env.REDIS_URL;
|
|
246
|
+
if (redisUrl.startsWith("redis://h:")) {
|
|
247
|
+
redisUrl = redisUrl.replace("redis://h:", "redis://:");
|
|
248
|
+
}
|
|
249
|
+
this.redisClient = createClient({
|
|
250
|
+
legacyMode: false,
|
|
251
|
+
url: redisUrl,
|
|
252
|
+
pingInterval: 10000,
|
|
253
|
+
socket: {
|
|
254
|
+
tls: redisUrl.startsWith("rediss://"),
|
|
255
|
+
rejectUnauthorized: false,
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.redisClient = createClient({ legacyMode: false });
|
|
261
|
+
}
|
|
262
|
+
this.redisClient.on("error", (err) => {
|
|
263
|
+
console.error("App Redis client error", err);
|
|
264
|
+
});
|
|
265
|
+
this.redisClient.on("connect", () => {
|
|
266
|
+
console.log("App Redis client is connected");
|
|
267
|
+
});
|
|
268
|
+
this.redisClient.on("reconnecting", () => {
|
|
269
|
+
console.log("App Redis client is reconnecting");
|
|
270
|
+
});
|
|
271
|
+
this.redisClient.on("ready", () => {
|
|
272
|
+
console.log("App Redis client is ready");
|
|
273
|
+
});
|
|
274
|
+
try {
|
|
275
|
+
await this.redisClient.connect();
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
console.error("App Failed to connect Redis client", err);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
addRedisToRequest() {
|
|
282
|
+
this.app.use((req, res, next) => {
|
|
283
|
+
if (this.redisClient && typeof this.redisClient.get === "function") {
|
|
284
|
+
req.redisClient = this.redisClient;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
log.error("Redis client get method not found or client not initialized");
|
|
288
|
+
}
|
|
289
|
+
next();
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
addDirnameToRequest() {
|
|
293
|
+
this.app.use((req, res, next) => {
|
|
294
|
+
req.dirName = __dirname;
|
|
295
|
+
next();
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
addInviteAsAnonMiddleWare() {
|
|
299
|
+
this.app.use(async (req, res, next) => {
|
|
300
|
+
if (req.query.anonInvite && req.query.token) {
|
|
301
|
+
const token = req.query.token;
|
|
302
|
+
try {
|
|
303
|
+
//TODO: Fix this "as any" in all places
|
|
304
|
+
const invite = await models.Invite.findOne({
|
|
305
|
+
where: {
|
|
306
|
+
token,
|
|
307
|
+
joined_at: null,
|
|
308
|
+
type: models.Invite
|
|
309
|
+
.INVITE_TO_COMMUNITY_AND_GROUP_AS_ANON,
|
|
310
|
+
deleted: false,
|
|
311
|
+
[Op.or]: [
|
|
312
|
+
{ expires_at: null },
|
|
313
|
+
{ expires_at: { [Op.gt]: new Date() } },
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
if (invite) {
|
|
318
|
+
const anonEmail = req.sessionID + "_v3anonymous@citizens.is";
|
|
319
|
+
let user;
|
|
320
|
+
if (req.user) {
|
|
321
|
+
user = req.user;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
user = await models.User.findOne({
|
|
325
|
+
where: { email: anonEmail },
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (!user) {
|
|
329
|
+
user = await models.User.create({
|
|
330
|
+
email: anonEmail,
|
|
331
|
+
name: "Invited User",
|
|
332
|
+
notifications_settings: models.AcNotification
|
|
333
|
+
.anonymousNotificationSettings,
|
|
334
|
+
status: "active",
|
|
335
|
+
//TODO: Having this blocks security for the cloned groups, find a better solution
|
|
336
|
+
//profile_data: { isAnonymousUser: true },
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
// Associate user with community
|
|
340
|
+
if (invite.community_id) {
|
|
341
|
+
const community = await models.Community.findByPk(invite.community_id);
|
|
342
|
+
if (community) {
|
|
343
|
+
await community.addCommunityUsers(user);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Associate user with group
|
|
347
|
+
if (invite.group_id) {
|
|
348
|
+
const group = await models.Group.findByPk(invite.group_id);
|
|
349
|
+
if (group) {
|
|
350
|
+
await group.addGroupUsers(user);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// Mark invite as used
|
|
354
|
+
invite.joined_at = new Date();
|
|
355
|
+
await invite.save();
|
|
356
|
+
console.log("Invite joined at", invite.joined_at);
|
|
357
|
+
await new Promise((resolve, reject) => {
|
|
358
|
+
req.logIn(user, (error) => (error ? reject(error) : resolve()));
|
|
359
|
+
});
|
|
360
|
+
console.log("User logged in for anon invite");
|
|
361
|
+
return next();
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
console.error("Invite not found");
|
|
365
|
+
return next();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (err) {
|
|
369
|
+
log.error("Error in anonInvite middleware", { err });
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
next();
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
forceHttps() {
|
|
376
|
+
if (this.app.get("env") !== "development" &&
|
|
377
|
+
!process.env.DISABLE_FORCE_HTTPS) {
|
|
378
|
+
this.app.use((req, res, next) => {
|
|
379
|
+
if (!/https/.test(req.protocol)) {
|
|
380
|
+
res.redirect("https://" + req.headers.host + req.url);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
return next();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
handleShortenedRedirects() {
|
|
389
|
+
this.app.use((req, res, next) => {
|
|
390
|
+
if (req.path.startsWith("/s/")) {
|
|
391
|
+
res.redirect(`${req.protocol}://${req.headers.host}${req.url.replace("/s/", "/survey/")}`);
|
|
392
|
+
}
|
|
393
|
+
else if (req.path.startsWith("/g/")) {
|
|
394
|
+
res.redirect(`${req.protocol}://${req.headers.host}${req.url.replace("/g/", "/group/")}`);
|
|
395
|
+
}
|
|
396
|
+
else if (req.path.startsWith("/c/")) {
|
|
397
|
+
res.redirect(`${req.protocol}://${req.headers.host}${req.url.replace("/c/", "/community/")}`);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
return next();
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
handleServiceWorker(req, res) {
|
|
405
|
+
res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0");
|
|
406
|
+
res.setHeader("Last-Modified", new Date().toUTCString());
|
|
407
|
+
const filePath = req.path.includes("/sw.js")
|
|
408
|
+
? path.join(__dirname, "../webAppsDist/client/dist/sw.js")
|
|
409
|
+
: path.join(__dirname, "../webAppsDist/old/client/build/bundled/service-worker.js");
|
|
410
|
+
res.sendFile(filePath);
|
|
411
|
+
}
|
|
412
|
+
setupDomainAndCommunity() {
|
|
413
|
+
this.app.use((req, res, next) => {
|
|
414
|
+
models.Domain.setYpDomain(req, res, () => {
|
|
415
|
+
log.info("Domain", {
|
|
416
|
+
id: req.ypDomain ? req.ypDomain.id : "-1",
|
|
417
|
+
n: req.ypDomain ? req.ypDomain.domain_name : "?",
|
|
418
|
+
});
|
|
419
|
+
models.Community.setYpCommunity(req, res, () => {
|
|
420
|
+
log.info("Community", {
|
|
421
|
+
id: req.ypCommunity ? req.ypCommunity.id : null,
|
|
422
|
+
n: req.ypCommunity ? req.ypCommunity.hostname : null,
|
|
423
|
+
});
|
|
424
|
+
next();
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
async initializeRateLimiting() {
|
|
430
|
+
const botRateLimiter = rateLimit({
|
|
431
|
+
windowMs: process.env.RATE_LIMITER_WINDOW_MS
|
|
432
|
+
? parseInt(process.env.RATE_LIMITER_WINDOW_MS, 10)
|
|
433
|
+
: 15 * 60 * 1000, // 15 minutes
|
|
434
|
+
max: process.env.RATE_LIMITER_MAX
|
|
435
|
+
? parseInt(process.env.RATE_LIMITER_MAX, 10)
|
|
436
|
+
: 30,
|
|
437
|
+
});
|
|
438
|
+
this.app.use((req, res, next) => {
|
|
439
|
+
let ua = req.headers["user-agent"] || "";
|
|
440
|
+
if (req.headers["content-type"] !== "application/json" &&
|
|
441
|
+
req.originalUrl &&
|
|
442
|
+
!req.originalUrl.endsWith("/sitemap.xml")) {
|
|
443
|
+
const isBotBad = isBadBot(ua.toLowerCase());
|
|
444
|
+
if (!req.headers["x-api-key"] &&
|
|
445
|
+
!botsWithJavascript(ua) &&
|
|
446
|
+
(isbot(ua) || isBadBot(ua))) {
|
|
447
|
+
if (isBotBad) {
|
|
448
|
+
botRateLimiter(req, res, () => {
|
|
449
|
+
nonSPArouter(req, res, next);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
nonSPArouter(req, res, next);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
next();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
next();
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
setupSitemapRoute() {
|
|
466
|
+
this.app.get("/sitemap.xml", async (req, res) => {
|
|
467
|
+
try {
|
|
468
|
+
const url = req.get("host") + req.originalUrl;
|
|
469
|
+
const redisKey = "cache:sitemapv14:" + url;
|
|
470
|
+
const sitemap = await req.redisClient.get(redisKey);
|
|
471
|
+
if (sitemap) {
|
|
472
|
+
res.header("Content-Type", "application/xml");
|
|
473
|
+
res.send(sitemap);
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
generateSitemap(req, res);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
log.error("Error getting sitemap from redis", { error });
|
|
481
|
+
generateSitemap(req, res);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
checkAuthForSsoInit() {
|
|
486
|
+
this.app.use((req, res, next) => {
|
|
487
|
+
if (req.url.indexOf("/auth") > -1 ||
|
|
488
|
+
req.url.indexOf("/login") > -1 ||
|
|
489
|
+
req.url.indexOf("saml_assertion") > -1) {
|
|
490
|
+
sso.init(req.ypDomain?.loginHosts, req.ypDomain?.loginProviders, {
|
|
491
|
+
authorize: this.bearerCallback,
|
|
492
|
+
login: models.User.localCallback,
|
|
493
|
+
});
|
|
494
|
+
req.sso = sso;
|
|
495
|
+
}
|
|
496
|
+
next();
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
initializeMiddlewares() {
|
|
500
|
+
this.app.use(morgan("combined"));
|
|
501
|
+
this.app.use(useragent.express());
|
|
502
|
+
this.app.use(requestIp.mw());
|
|
503
|
+
this.app.use(bodyParser.json({ limit: "100mb", strict: false }));
|
|
504
|
+
this.app.use(bodyParser.urlencoded({ limit: "100mb", extended: true }));
|
|
505
|
+
this.app.use(cors());
|
|
506
|
+
this.app.use(compression());
|
|
507
|
+
this.app.set("views", __dirname + "/views");
|
|
508
|
+
this.app.set("view engine", "pug");
|
|
509
|
+
const store = new RedisStore({ client: this.redisClient, ttl: 86400 });
|
|
510
|
+
const sessionConfig = {
|
|
511
|
+
store: store,
|
|
512
|
+
name: "yrpri.sid",
|
|
513
|
+
secret: process.env.SESSION_SECRET || "not so secret... use env var.",
|
|
514
|
+
resave: false,
|
|
515
|
+
proxy: process.env.USING_NGINX_PROXY ? true : undefined,
|
|
516
|
+
cookie: { autoSubDomain: true },
|
|
517
|
+
saveUninitialized: false,
|
|
518
|
+
};
|
|
519
|
+
if (this.app.get("env") === "production") {
|
|
520
|
+
this.app.set("trust proxy", 3); // Trust three proxies
|
|
521
|
+
//@ts-ignore
|
|
522
|
+
sessionConfig.cookie.secure = true; // serve secure cookies
|
|
523
|
+
}
|
|
524
|
+
//@ts-ignore
|
|
525
|
+
this.app.use(session(sessionConfig));
|
|
526
|
+
}
|
|
527
|
+
async initializeEsControllers() {
|
|
528
|
+
console.log("Initializing ES controllers");
|
|
529
|
+
const { AllOurIdeasController } = await import("./controllers/allOurIdeas.js");
|
|
530
|
+
console.log("Initializing ES controllers 2 " + this.wsClients);
|
|
531
|
+
const aoiController = new AllOurIdeasController(this.wsClients);
|
|
532
|
+
console.log(`Controller path: ${aoiController.path} ${aoiController.router}`);
|
|
533
|
+
this.app.use(aoiController.path, aoiController.router);
|
|
534
|
+
const { PolicySynthAgentsController } = await import("./agents/controllers/policySynthAgents.js");
|
|
535
|
+
const policySynthAgentsController = new PolicySynthAgentsController(this.wsClients);
|
|
536
|
+
this.app.use(policySynthAgentsController.path, policySynthAgentsController.router);
|
|
537
|
+
const { AssistantController } = await import("./agents/controllers/assistantsController.js");
|
|
538
|
+
const assistantController = new AssistantController(this.wsClients);
|
|
539
|
+
this.app.use(assistantController.path, assistantController.router);
|
|
540
|
+
// Setup those here so they wont override the ES controllers
|
|
541
|
+
this.setupErrorHandler();
|
|
542
|
+
}
|
|
543
|
+
setupStaticFileServing() {
|
|
544
|
+
const baseDir = path.join(__dirname, "../webAppsDist");
|
|
545
|
+
this.app.use((req, res, next) => {
|
|
546
|
+
if (req.path.endsWith(".js")) {
|
|
547
|
+
res.setHeader("Cache-Control", "public, max-age=31536000, s-maxage=86400, stale-while-revalidate=86400"); // 1 year cache, 1 day revalidate
|
|
548
|
+
}
|
|
549
|
+
else if (req.path.match(/\.(png|jpg|jpeg|gif)$/)) {
|
|
550
|
+
res.setHeader("Cache-Control", "public, max-age=2592000, s-maxage=86400, stale-while-revalidate=86400"); // 1 month cache, 1 day revalidate
|
|
551
|
+
}
|
|
552
|
+
else if (req.path.endsWith(".json")) {
|
|
553
|
+
res.setHeader("Cache-Control", "public, max-age=43200, s-maxage=60, stale-while-revalidate=60"); // 12 hour cache, 5 minutes revalidate
|
|
554
|
+
}
|
|
555
|
+
next();
|
|
556
|
+
});
|
|
557
|
+
this.app.get("/sw.js", this.handleServiceWorker);
|
|
558
|
+
this.app.get("/service-worker.js", this.handleServiceWorker);
|
|
559
|
+
// Promotion app
|
|
560
|
+
const promotionAppPath = path.join(baseDir, "old/promotion_app/dist");
|
|
561
|
+
this.app.use("/promotion", express.static(promotionAppPath));
|
|
562
|
+
this.app.use("/promotion/domain/*", express.static(promotionAppPath));
|
|
563
|
+
this.app.use("/promotion/organization/*", express.static(promotionAppPath));
|
|
564
|
+
this.app.use("/promotion/community/*", express.static(promotionAppPath));
|
|
565
|
+
this.app.use("/promotion/group/*", express.static(promotionAppPath));
|
|
566
|
+
this.app.use("/promotion/post/*", express.static(promotionAppPath));
|
|
567
|
+
this.app.use("/promotion/locales/en/*", express.static(path.join(promotionAppPath, "locales/en")));
|
|
568
|
+
this.app.use("/promotion/locales/is/*", express.static(path.join(promotionAppPath, "locales/is")));
|
|
569
|
+
// Land use game
|
|
570
|
+
const landUseGamePath = path.join(baseDir, "land_use_game/dist");
|
|
571
|
+
this.app.use("/land_use", express.static(landUseGamePath));
|
|
572
|
+
this.app.use("/land_use/*", express.static(landUseGamePath));
|
|
573
|
+
this.app.use("/land_use/locales/en/*", express.static(path.join(landUseGamePath, "locales/en")));
|
|
574
|
+
this.app.use("/land_use/locales/is/*", express.static(path.join(landUseGamePath, "locales/is")));
|
|
575
|
+
this.app.use("/Assets", express.static(path.join(landUseGamePath, "Assets")));
|
|
576
|
+
this.app.use("/ThirdParty", express.static(path.join(landUseGamePath, "ThirdParty")));
|
|
577
|
+
this.app.use("/Widgets", express.static(path.join(landUseGamePath, "Widgets")));
|
|
578
|
+
this.app.use("/Workers", express.static(path.join(landUseGamePath, "Workers")));
|
|
579
|
+
// Middleware to set paths based on query parameters
|
|
580
|
+
this.app.use((req, res, next) => {
|
|
581
|
+
const baseDir = path.join(__dirname, "../webAppsDist");
|
|
582
|
+
const useNewVersion = req.useNewVersion;
|
|
583
|
+
// Set the paths depending on the version
|
|
584
|
+
req.adminAppPath = useNewVersion
|
|
585
|
+
? path.join(baseDir, "client/dist")
|
|
586
|
+
: path.join(baseDir, "old/translationApp/dist");
|
|
587
|
+
req.clientAppPath = useNewVersion
|
|
588
|
+
? path.join(baseDir, "client/dist")
|
|
589
|
+
: path.join(baseDir, "old/client/build/bundled");
|
|
590
|
+
const staticPath = req.path.startsWith("/admin")
|
|
591
|
+
? req.adminAppPath
|
|
592
|
+
: req.clientAppPath;
|
|
593
|
+
//console.log("Static path", staticPath);
|
|
594
|
+
// Check if the request is for index.html
|
|
595
|
+
if (req.path === "/" || req.path === "/index.html") {
|
|
596
|
+
index(req, res, next); // Use your dynamic handler
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
express.static(staticPath)(req, res, next);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
initializeRoutes() {
|
|
604
|
+
this.app.use("/", index);
|
|
605
|
+
this.app.use("/index.html", index);
|
|
606
|
+
this.app.use("/domain", index);
|
|
607
|
+
this.app.use("/community", index);
|
|
608
|
+
this.app.use("/organization", index);
|
|
609
|
+
this.app.use("/agent_bundle/*", index);
|
|
610
|
+
this.app.use("/group", index);
|
|
611
|
+
this.app.use("/post", index);
|
|
612
|
+
this.app.use("/user", index);
|
|
613
|
+
this.app.use("/admin", index);
|
|
614
|
+
this.app.use("/survey*", index);
|
|
615
|
+
this.app.use("/api/domains", domains);
|
|
616
|
+
this.app.use("/api/organizations", organizations);
|
|
617
|
+
this.app.use("/api/communities", communities);
|
|
618
|
+
this.app.use("/api/groups", groups);
|
|
619
|
+
this.app.use("/api/posts", posts);
|
|
620
|
+
this.app.use("/api/points", points);
|
|
621
|
+
this.app.use("/api/images", images);
|
|
622
|
+
this.app.use("/api/videos", videos);
|
|
623
|
+
this.app.use("/api/audios", audios);
|
|
624
|
+
this.app.use("/api/categories", categories);
|
|
625
|
+
this.app.use("/api/externalIds", externalIds);
|
|
626
|
+
this.app.use("/api/users", users);
|
|
627
|
+
this.app.use("/api/news_feeds", news_feeds);
|
|
628
|
+
this.app.use("/api/activities", activities);
|
|
629
|
+
this.app.use("/api/notifications", notifications);
|
|
630
|
+
this.app.use("/api/bulk_status_updates", bulkStatusUpdates);
|
|
631
|
+
this.app.use("/api/recommendations", recommendations);
|
|
632
|
+
this.app.use("/api/ratings", ratings);
|
|
633
|
+
this.app.use("/ideas", legacyPosts);
|
|
634
|
+
this.app.use("/users", legacyUsers);
|
|
635
|
+
this.app.use("/pages", legacyPages);
|
|
636
|
+
// Additional routes for authentication and other functionalities
|
|
637
|
+
this.app.post("/authenticate_from_island_is", (req, res) => {
|
|
638
|
+
console.log("SAML SAML 1", { domainId: req.ypDomain.id });
|
|
639
|
+
req.sso.authenticate(`saml-strategy-${req.ypDomain.id}`, {}, req, res, (error) => {
|
|
640
|
+
console.log("SAML SAML 2", {
|
|
641
|
+
domainId: req.ypDomain.id,
|
|
642
|
+
err: error,
|
|
643
|
+
});
|
|
644
|
+
if (error) {
|
|
645
|
+
console.error("Error from SAML login", { err: error });
|
|
646
|
+
error.url = req.url;
|
|
647
|
+
res.sendStatus(401);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
if (req.user.DestinationSSN === "6012101260") {
|
|
651
|
+
console.log("SAML SAML 3", { domainId: req.ypDomain.id });
|
|
652
|
+
res.render("samlLoginComplete", {});
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
console.error("Error from SAML login", {
|
|
656
|
+
err: "Failed DestinationSSN check",
|
|
657
|
+
});
|
|
658
|
+
res.sendStatus(401);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
this.app.post("/saml_assertion", (req, res) => {
|
|
664
|
+
console.log("SAML SAML 1 General", { domainId: req.ypDomain.id });
|
|
665
|
+
req.sso.authenticate(`saml-strategy-${req.ypDomain.id}`, {}, req, res, (error, user) => {
|
|
666
|
+
console.log("SAML SAML 2 General", {
|
|
667
|
+
domainId: req.ypDomain.id,
|
|
668
|
+
err: error,
|
|
669
|
+
});
|
|
670
|
+
if (error) {
|
|
671
|
+
console.error("Error from SAML General login", { err: error });
|
|
672
|
+
if (error === "customError") {
|
|
673
|
+
res.render("samlCustomError", {
|
|
674
|
+
customErrorHTML: req.ypDomain.configuration.customSAMLErrorHTML,
|
|
675
|
+
closeWindowText: "Close window",
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
error.url = req.url;
|
|
680
|
+
console.error("Error from SAML General login", { err: error });
|
|
681
|
+
res.sendStatus(500);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
console.log("SAML SAML 3 General", { domainId: req.ypDomain.id });
|
|
686
|
+
res.render("samlLoginComplete", {});
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
this.app.get("/manifest.json", (req, res) => {
|
|
691
|
+
generateManifest(req, res);
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
initializePassportStrategies() {
|
|
695
|
+
this.app.use(passport.initialize());
|
|
696
|
+
this.app.use(passport.session());
|
|
697
|
+
passport.serializeUser((req, profile, done) => {
|
|
698
|
+
log.info("----> User Serialized", { loginProvider: profile.provider });
|
|
699
|
+
if (profile.provider === "facebook") {
|
|
700
|
+
models.User.serializeFacebookUser(profile, req.ypDomain, (error, user) => {
|
|
701
|
+
if (error) {
|
|
702
|
+
log.error("Error in User Serialized from Facebook", {
|
|
703
|
+
err: error,
|
|
704
|
+
});
|
|
705
|
+
done(error);
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
log.info("User Serialized", {
|
|
709
|
+
context: "loginFromFacebook",
|
|
710
|
+
userId: user.id,
|
|
711
|
+
});
|
|
712
|
+
// Assuming registerUserLogin is defined elsewhere in your application
|
|
713
|
+
this.registerUserLogin(user, user.id, "facebook", req, () => {
|
|
714
|
+
done(null, { userId: user.id, loginProvider: "facebook" });
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
else if (profile.provider === "saml") {
|
|
720
|
+
models.User.serializeSamlUser(profile, req, (error, user) => {
|
|
721
|
+
if (error) {
|
|
722
|
+
log.error("Error in User Serialized from SAML", { err: error });
|
|
723
|
+
done(error);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
log.info("User Serialized", {
|
|
727
|
+
context: "loginFromSaml",
|
|
728
|
+
userId: user.id,
|
|
729
|
+
});
|
|
730
|
+
this.registerUserLogin(user, user.id, "saml", req, () => {
|
|
731
|
+
done(null, { userId: user.id, loginProvider: "saml" });
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
else if (profile.provider === "oidc") {
|
|
737
|
+
models.User.serializeOidcUser(profile, req, (error, user) => {
|
|
738
|
+
if (error) {
|
|
739
|
+
log.error("Error in User Serialized from OIDC", { err: error });
|
|
740
|
+
done(error);
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
log.info("User Serialized", {
|
|
744
|
+
context: "loginFromOidc",
|
|
745
|
+
userId: user.id,
|
|
746
|
+
});
|
|
747
|
+
this.registerUserLogin(user, user.id, "oidc", req, () => {
|
|
748
|
+
done(null, { userId: user.id, loginProvider: "saml" });
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
log.info("User Serialized", {
|
|
755
|
+
context: "serializeUser",
|
|
756
|
+
userEmail: profile.email,
|
|
757
|
+
userId: profile.id,
|
|
758
|
+
});
|
|
759
|
+
this.registerUserLogin(null, parseInt(profile.id), "email", req, () => {
|
|
760
|
+
done(null, {
|
|
761
|
+
userId: parseInt(profile.id),
|
|
762
|
+
loginProvider: "email",
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
passport.deserializeUser((sessionUser, done) => {
|
|
768
|
+
models.User.findOne({
|
|
769
|
+
where: { id: sessionUser.userId },
|
|
770
|
+
attributes: [
|
|
771
|
+
"id",
|
|
772
|
+
"name",
|
|
773
|
+
"email",
|
|
774
|
+
"default_locale",
|
|
775
|
+
"facebook_id",
|
|
776
|
+
"twitter_id",
|
|
777
|
+
"google_id",
|
|
778
|
+
"github_id",
|
|
779
|
+
"ssn",
|
|
780
|
+
"profile_data",
|
|
781
|
+
"private_profile_data",
|
|
782
|
+
],
|
|
783
|
+
include: [
|
|
784
|
+
{
|
|
785
|
+
model: models.Image,
|
|
786
|
+
as: "UserProfileImages",
|
|
787
|
+
required: false,
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
model: models.Image,
|
|
791
|
+
as: "UserHeaderImages",
|
|
792
|
+
required: false,
|
|
793
|
+
},
|
|
794
|
+
],
|
|
795
|
+
})
|
|
796
|
+
.then((user) => {
|
|
797
|
+
if (user) {
|
|
798
|
+
user.loginProvider = sessionUser.loginProvider;
|
|
799
|
+
if (user.private_profile_data?.saml_agency &&
|
|
800
|
+
sessionUser.loginProvider === "saml") {
|
|
801
|
+
user.isSamlEmployee = true;
|
|
802
|
+
log.info("SAML isSamlEmployee is true");
|
|
803
|
+
}
|
|
804
|
+
done(null, user);
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
log.error("User Deserialized Not found", {
|
|
808
|
+
context: "deserializeUser",
|
|
809
|
+
});
|
|
810
|
+
if (airbrake) {
|
|
811
|
+
airbrake
|
|
812
|
+
.notify("User Deserialized Not found")
|
|
813
|
+
.then((airbrakeErr) => {
|
|
814
|
+
if (airbrakeErr.error) {
|
|
815
|
+
log.error("AirBrake Error", {
|
|
816
|
+
context: "airbrake",
|
|
817
|
+
err: airbrakeErr.error,
|
|
818
|
+
errorStatus: 500,
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
done(null, false);
|
|
824
|
+
}
|
|
825
|
+
})
|
|
826
|
+
.catch((error) => {
|
|
827
|
+
log.error("User Deserialize Error", {
|
|
828
|
+
context: "deserializeUser",
|
|
829
|
+
err: error,
|
|
830
|
+
errorStatus: 500,
|
|
831
|
+
});
|
|
832
|
+
if (airbrake) {
|
|
833
|
+
airbrake.notify(error).then((airbrakeErr) => {
|
|
834
|
+
if (airbrakeErr.error) {
|
|
835
|
+
log.error("AirBrake Error", {
|
|
836
|
+
context: "airbrake",
|
|
837
|
+
err: airbrakeErr.error,
|
|
838
|
+
errorStatus: 500,
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
done(null, false);
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
setupErrorHandler() {
|
|
848
|
+
this.app.use((err, req, res, next) => {
|
|
849
|
+
if (err instanceof auth.UnauthorizedError) {
|
|
850
|
+
log.info("Anon debug UnauthorizedError", { user: req.user });
|
|
851
|
+
log.error("User Unauthorized", {
|
|
852
|
+
context: "unauthorizedError",
|
|
853
|
+
user: toJson(req.user),
|
|
854
|
+
err: "Unauthorized",
|
|
855
|
+
errorStatus: 401,
|
|
856
|
+
});
|
|
857
|
+
res.sendStatus(401);
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
next(err);
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
this.app.use((req, res, next) => {
|
|
864
|
+
const err = new Error("Not Found");
|
|
865
|
+
err.status = 404;
|
|
866
|
+
log.warn("Not Found", {
|
|
867
|
+
context: "notFound",
|
|
868
|
+
user: toJson(req.user),
|
|
869
|
+
err: "Not Found",
|
|
870
|
+
errorStatus: 404,
|
|
871
|
+
});
|
|
872
|
+
next(err);
|
|
873
|
+
});
|
|
874
|
+
this.app.use((err, req, res, next) => {
|
|
875
|
+
let status = err.status || 500;
|
|
876
|
+
if (err.message && err.message.includes("Expected url like")) {
|
|
877
|
+
status = 404;
|
|
878
|
+
}
|
|
879
|
+
let body = null;
|
|
880
|
+
try {
|
|
881
|
+
if (req.body) {
|
|
882
|
+
body = JSON.stringify(req.body);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
catch (bodyError) {
|
|
886
|
+
log.error("General Error: Body JSON parsing error", {
|
|
887
|
+
err: bodyError,
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
log.error("General Error", {
|
|
891
|
+
context: "generalError",
|
|
892
|
+
user: req.user ? toJson(req.user) : null,
|
|
893
|
+
err: err,
|
|
894
|
+
protocol: req.protocol,
|
|
895
|
+
host: req.get("host"),
|
|
896
|
+
originalUrl: req.originalUrl,
|
|
897
|
+
body,
|
|
898
|
+
errStack: err.stack,
|
|
899
|
+
errorStatus: status,
|
|
900
|
+
});
|
|
901
|
+
err.url = req.url;
|
|
902
|
+
err.params = req.params;
|
|
903
|
+
if (status !== 404 && status !== 401) {
|
|
904
|
+
// Optionally notify an error tracking service like Airbrake
|
|
905
|
+
if (airbrake) {
|
|
906
|
+
airbrake.notify(err).then((airbrakeErr) => {
|
|
907
|
+
if (airbrakeErr.error) {
|
|
908
|
+
log.error("AirBrake Error", {
|
|
909
|
+
context: "airbrake",
|
|
910
|
+
user: toJson(req.user),
|
|
911
|
+
err: airbrakeErr.error,
|
|
912
|
+
errorStatus: 500,
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
res.sendStatus(status);
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
async listen() {
|
|
922
|
+
const server = await this.setupHttpsServer();
|
|
923
|
+
this.webSocketsManager = new WebSocketsManager(this.wsClients, this.redisClient, server);
|
|
924
|
+
await this.webSocketsManager.listen();
|
|
925
|
+
}
|
|
926
|
+
setupHttpsServer() {
|
|
927
|
+
let server;
|
|
928
|
+
const portNumber = process.env.PORT ? parseInt(process.env.PORT) : 4242;
|
|
929
|
+
if (process.env.YOUR_PRIORITIES_LISTEN_HOST) {
|
|
930
|
+
server = this.app.listen(portNumber, process.env.YOUR_PRIORITIES_LISTEN_HOST, () => {
|
|
931
|
+
log.info(`Your Priorities Platform API Server listening on port ${process.env.YOUR_PRIORITIES_LISTEN_HOST}:${this.app.get("port")} on ${process.env.NODE_ENV}`);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
server = this.app.listen(portNumber, function () {
|
|
936
|
+
log.info("Your Priorities Platform API Server listening on port " +
|
|
937
|
+
server.address().port +
|
|
938
|
+
` on ${process.env.NODE_ENV}`);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
return server;
|
|
942
|
+
}
|
|
943
|
+
}
|