@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,449 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
let express = require("express");
|
|
3
|
-
let router = express.Router();
|
|
4
|
-
let log = require("../utils/logger.cjs");
|
|
5
|
-
let toJson = require("../utils/to_json.cjs");
|
|
6
|
-
let path = require("path");
|
|
7
|
-
let fs = require("fs");
|
|
8
|
-
const { getSharingParameters, getFullUrl, getSplitUrl, } = require("../utils/sharing_parameters.cjs");
|
|
9
|
-
const models = require("../models/index.cjs");
|
|
10
|
-
let replaceForBetterReykjavik = function (data) {
|
|
11
|
-
return data.replace(/XmanifestPathX/g, "manifest_br");
|
|
12
|
-
};
|
|
13
|
-
let replaceForBetterReykjavikFallback = function (data) {
|
|
14
|
-
data = data.replace(/XappNameX/g, "Betri Reykjavík");
|
|
15
|
-
data = data.replace(/XdescriptionX/g, "Betri Reykjavík er samráðsverkefni Reykjavíkurborgar, Íbúa ses og Reykvíkinga.");
|
|
16
|
-
return data;
|
|
17
|
-
};
|
|
18
|
-
let replaceForBetterIceland = function (data) {
|
|
19
|
-
return data.replace(/XmanifestPathX/g, "manifest_bi");
|
|
20
|
-
};
|
|
21
|
-
let replaceForBetterIcelandFallback = function (data) {
|
|
22
|
-
data = data.replace(/XappNameX/g, "Betra Ísland");
|
|
23
|
-
data = data.replace(/XdescriptionX/g, "Betra Ísland er samráðsvefur fyrir alla Íslendinga");
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
let replaceForYrpri = function (data) {
|
|
27
|
-
return data.replace(/XmanifestPathX/g, "manifest_yp");
|
|
28
|
-
};
|
|
29
|
-
let replaceForYrpriFallback = function (data) {
|
|
30
|
-
data = data.replace(/XappNameX/g, "Your Priorities");
|
|
31
|
-
data = data.replace(/XdescriptionX/g, "Citizen participation application");
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
let replaceForEngageBritain = function (data) {
|
|
35
|
-
return data.replace(/XmanifestPathX/g, "manifest_eb");
|
|
36
|
-
};
|
|
37
|
-
let replaceForEngageBritainFallback = function (data) {
|
|
38
|
-
data = data.replace(/XappNameX/g, "Engage Britain");
|
|
39
|
-
data = data.replace(/XdescriptionX/g, "Engage Britain is a fully independent charity that brings people together to tackle our country’s biggest challenges.");
|
|
40
|
-
return data;
|
|
41
|
-
};
|
|
42
|
-
let replaceForMyCityChallenge = function (data) {
|
|
43
|
-
return data.replace(/XmanifestPathX/g, "manifest_my_city_challenge");
|
|
44
|
-
};
|
|
45
|
-
let replaceForMyCityChallengeFallback = function (data) {
|
|
46
|
-
data = data.replace(/XappNameX/g, "My City Challenge");
|
|
47
|
-
data = data.replace(/XdescriptionX/g, "My City Challenge");
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
50
|
-
let replaceForTarsalgo = function (data) {
|
|
51
|
-
return data.replace(/XmanifestPathX/g, "manifest_tarsalgo");
|
|
52
|
-
};
|
|
53
|
-
let replaceForTarsalgoFallback = function (data) {
|
|
54
|
-
data = data.replace(/XappNameX/g, "társalgó");
|
|
55
|
-
data = data.replace(/XdescriptionX/g, "tarsalgo.net");
|
|
56
|
-
return data;
|
|
57
|
-
};
|
|
58
|
-
let replaceForOpenMontana = function (data) {
|
|
59
|
-
return data.replace(/XmanifestPathX/g, "manifest_open_montana");
|
|
60
|
-
};
|
|
61
|
-
let replaceForOpenMontanaFallback = function (data) {
|
|
62
|
-
data = data.replace(/XappNameX/g, "Open Montana");
|
|
63
|
-
data = data.replace(/XdescriptionX/g, "For transparent, participatory, and collaborative governance.");
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
let replaceForParlScot = function (data) {
|
|
67
|
-
return data.replace(/XmanifestPathX/g, "manifest_parlscott");
|
|
68
|
-
};
|
|
69
|
-
let replaceForParlScotFallback = function (data) {
|
|
70
|
-
data = data.replace(/XappNameX/g, "Engage - Scottish Parliament");
|
|
71
|
-
data = data.replace(/XdescriptionX/g, "Engage with the Scottish Parliament");
|
|
72
|
-
return data;
|
|
73
|
-
};
|
|
74
|
-
let replaceForJungesWien = function (data) {
|
|
75
|
-
return data.replace(/XmanifestPathX/g, "manifest_junges_wien");
|
|
76
|
-
};
|
|
77
|
-
let replaceForJungesWienFallback = function (data) {
|
|
78
|
-
data = data.replace(/XappNameX/g, "Junges Wien");
|
|
79
|
-
data = data.replace(/XdescriptionX/g, "Die Junges Wien - Plattform dient der Stadt Wien zur Ideen-Einreichung und zur Projektabstimmung für die erste partizipative Wiener Kinder- und Jugendmillion. #jungeswien");
|
|
80
|
-
return data;
|
|
81
|
-
};
|
|
82
|
-
let replaceForSmarterNJ = function (data) {
|
|
83
|
-
return data.replace(/XmanifestPathX/g, "manifest_smarternj");
|
|
84
|
-
};
|
|
85
|
-
let replaceForSmarterNJFallback = function (data) {
|
|
86
|
-
data = data.replace(/XappNameX/g, "SmarterNJ");
|
|
87
|
-
data = data.replace(/XdescriptionX/g, "SmarterNJ is an open government initiative that uses new and innovative technology to meaningfully engage New Jerseyans. Your participation in SmarterNJ will allow us to create policies, programs and services that are more effective, more efficient, and more impactful for all New Jerseyans.");
|
|
88
|
-
return data;
|
|
89
|
-
};
|
|
90
|
-
let replaceForCommunityFund = function (data) {
|
|
91
|
-
return data.replace(/XmanifestPathX/g, "manifest_community_fund");
|
|
92
|
-
};
|
|
93
|
-
let replaceForCommunityFundFallback = function (data) {
|
|
94
|
-
data = data.replace(/XappNameX/g, "The National Lottery Community Fund");
|
|
95
|
-
data = data.replace(/XdescriptionX/g, "Now is the time for a conversation about how The National Lottery Community Fund can best support UK communities to prosper and thrive.");
|
|
96
|
-
return data;
|
|
97
|
-
};
|
|
98
|
-
let replaceFromEnv = function (data) {
|
|
99
|
-
return data.replace(/XmanifestPathX/g, process.env.YP_INDEX_MANIFEST_PATH
|
|
100
|
-
? process.env.YP_INDEX_MANIFEST_PATH
|
|
101
|
-
: "manifest_yp");
|
|
102
|
-
};
|
|
103
|
-
let replaceFromEnvFallback = function (data) {
|
|
104
|
-
data = data.replace(/XappNameX/g, process.env.YP_INDEX_APP_NAME
|
|
105
|
-
? process.env.YP_INDEX_APP_NAME
|
|
106
|
-
: "Your Priorities");
|
|
107
|
-
data = data.replace(/XdescriptionX/g, process.env.YP_INDEX_DESCRIPTION
|
|
108
|
-
? process.env.YP_INDEX_DESCRIPTION
|
|
109
|
-
: "Citizen participation application");
|
|
110
|
-
return data;
|
|
111
|
-
};
|
|
112
|
-
const plausibleCode = `
|
|
113
|
-
<script defer data-domain="DATADOMAIN" src="https://plausible.io/js/plausible.js"></script>
|
|
114
|
-
<script>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
|
|
115
|
-
`;
|
|
116
|
-
const getGA4Code = (tag) => {
|
|
117
|
-
return `
|
|
118
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=${tag}"></script>
|
|
119
|
-
<script>
|
|
120
|
-
window.dataLayer = window.dataLayer || [];
|
|
121
|
-
function gtag(){dataLayer.push(arguments);}
|
|
122
|
-
gtag('js', new Date());
|
|
123
|
-
gtag('config', '${tag}', { 'anonymize_ip': true });
|
|
124
|
-
</script>
|
|
125
|
-
`;
|
|
126
|
-
};
|
|
127
|
-
const getPlausibleCode = (dataDomain) => {
|
|
128
|
-
return plausibleCode.replace("DATADOMAIN", dataDomain);
|
|
129
|
-
};
|
|
130
|
-
const ziggeoHeaders = (ziggeoApplicationToken) => {
|
|
131
|
-
return `
|
|
132
|
-
<link rel="stylesheet" href="https://assets.ziggeo.com/v2-stable/ziggeo.css" />
|
|
133
|
-
<script src="https://assets.ziggeo.com/v2-stable/ziggeo.js"></script>
|
|
134
|
-
<script>
|
|
135
|
-
var ziggeoApp = new ZiggeoApi.V2.Application({
|
|
136
|
-
token:"${ziggeoApplicationToken}",
|
|
137
|
-
webrtc_streaming_if_necessary: true,
|
|
138
|
-
"video_profile": "r10c5c4a98bf3c636af176586ca911a0",
|
|
139
|
-
recordingwidth: "1280",
|
|
140
|
-
recordingheight: "720",
|
|
141
|
-
webrtc_on_mobile: true,
|
|
142
|
-
debug: true
|
|
143
|
-
});
|
|
144
|
-
</script>
|
|
145
|
-
`;
|
|
146
|
-
};
|
|
147
|
-
const getCollection = async (req) => {
|
|
148
|
-
return await new Promise(async (resolve, reject) => {
|
|
149
|
-
try {
|
|
150
|
-
let collection;
|
|
151
|
-
const { splitUrl, splitPath, id } = getSplitUrl(req);
|
|
152
|
-
if (!isNaN(id)) {
|
|
153
|
-
if (splitUrl[splitPath] === "domain") {
|
|
154
|
-
collection = req.ypDomain;
|
|
155
|
-
}
|
|
156
|
-
else if (splitUrl[splitPath] === "community") {
|
|
157
|
-
if (req.ypCommunity &&
|
|
158
|
-
req.ypCommunity.id &&
|
|
159
|
-
req.ypCommunity.name &&
|
|
160
|
-
req.ypCommunity.description) {
|
|
161
|
-
collection = req.ypCommunity;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
collection = await models.Community.findOne({
|
|
165
|
-
where: {
|
|
166
|
-
id: id,
|
|
167
|
-
},
|
|
168
|
-
attributes: ["id", "name", "description", "language"],
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else if (splitUrl[splitPath] === "group") {
|
|
173
|
-
collection = await models.Group.findOne({
|
|
174
|
-
where: {
|
|
175
|
-
id: id,
|
|
176
|
-
},
|
|
177
|
-
attributes: ["id", "name", "objectives", "language"],
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
else if (splitUrl[splitPath] === "post") {
|
|
181
|
-
collection = await models.Post.findOne({
|
|
182
|
-
where: {
|
|
183
|
-
id: id,
|
|
184
|
-
},
|
|
185
|
-
attributes: ["id", "name", "description", "language"],
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
resolve({ collection: req.ypDomain });
|
|
190
|
-
}
|
|
191
|
-
resolve({ collection });
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
resolve({ collection: req.ypDomain });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
reject(error);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
const replaceSharingData = async (req, indexFileData) => {
|
|
203
|
-
return await new Promise(async (resolve, reject) => {
|
|
204
|
-
try {
|
|
205
|
-
const { collection } = await getCollection(req);
|
|
206
|
-
const sharingParameters = await getSharingParameters(req, collection, getFullUrl(req), "");
|
|
207
|
-
indexFileData = indexFileData.replace(/XappNameX/g, sharingParameters.title);
|
|
208
|
-
indexFileData = indexFileData.replace(/XdescriptionX/g, sharingParameters.description);
|
|
209
|
-
indexFileData = indexFileData.replace(/Xogp:urlX/g, sharingParameters.url);
|
|
210
|
-
indexFileData = indexFileData.replace(/Xogp:imageX/g, "");
|
|
211
|
-
indexFileData = indexFileData.replace(/Xog:localeX/g, sharingParameters.locale);
|
|
212
|
-
resolve(indexFileData);
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
reject(error);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
let replaceWithHardCodedFallback = (req, indexFileData) => {
|
|
220
|
-
if (req.hostname) {
|
|
221
|
-
if (req.hostname.indexOf("betrireykjavik.is") > -1) {
|
|
222
|
-
indexFileData = replaceForBetterReykjavikFallback(indexFileData);
|
|
223
|
-
}
|
|
224
|
-
else if (req.hostname.indexOf("betraisland.is") > -1) {
|
|
225
|
-
indexFileData = replaceForBetterIcelandFallback(indexFileData);
|
|
226
|
-
}
|
|
227
|
-
else if (req.hostname.indexOf("smarter.nj.gov") > -1) {
|
|
228
|
-
indexFileData = replaceForSmarterNJFallback(indexFileData);
|
|
229
|
-
}
|
|
230
|
-
else if (req.hostname.indexOf("puttingcommunitiesfirst.org.uk") > -1) {
|
|
231
|
-
indexFileData = replaceForCommunityFundFallback(indexFileData);
|
|
232
|
-
}
|
|
233
|
-
else if (req.hostname.indexOf("parliament.scot") > -1) {
|
|
234
|
-
indexFileData = replaceForParlScotFallback(indexFileData);
|
|
235
|
-
}
|
|
236
|
-
else if (req.hostname.indexOf("ypus.org") > -1) {
|
|
237
|
-
indexFileData = replaceForYrpriFallback(indexFileData);
|
|
238
|
-
}
|
|
239
|
-
else if (req.hostname.indexOf("mycitychallenge.org") > -1) {
|
|
240
|
-
indexFileData = replaceForMyCityChallengeFallback(indexFileData);
|
|
241
|
-
}
|
|
242
|
-
else if (req.hostname.indexOf("engagebritain.org") > -1) {
|
|
243
|
-
indexFileData = replaceForEngageBritainFallback(indexFileData);
|
|
244
|
-
}
|
|
245
|
-
else if (req.hostname.indexOf("tarsalgo.net") > -1) {
|
|
246
|
-
indexFileData = replaceForTarsalgoFallback(indexFileData);
|
|
247
|
-
}
|
|
248
|
-
else if (req.hostname.indexOf("junges.wien") > -1) {
|
|
249
|
-
indexFileData = replaceForJungesWienFallback(indexFileData);
|
|
250
|
-
}
|
|
251
|
-
else if (req.hostname.indexOf("openmontana.org") > -1) {
|
|
252
|
-
indexFileData = replaceForOpenMontanaFallback(indexFileData);
|
|
253
|
-
}
|
|
254
|
-
else if (req.hostname.indexOf("yrpri.org") > -1) {
|
|
255
|
-
indexFileData = replaceForYrpriFallback(indexFileData);
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
indexFileData = replaceFromEnvFallback(indexFileData);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
indexFileData = replaceFromEnvFallback(indexFileData);
|
|
263
|
-
}
|
|
264
|
-
return indexFileData;
|
|
265
|
-
};
|
|
266
|
-
let indexCache = {
|
|
267
|
-
newVersion: {
|
|
268
|
-
data: null,
|
|
269
|
-
lastModified: null
|
|
270
|
-
},
|
|
271
|
-
oldVersion: {
|
|
272
|
-
data: null,
|
|
273
|
-
lastModified: null
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
async function replaceSiteData(indexFileData, req, useNewVersion) {
|
|
277
|
-
if (process.env.ZIGGEO_ENABLED &&
|
|
278
|
-
req.ypDomain.configuration.ziggeoApplicationToken) {
|
|
279
|
-
indexFileData = indexFileData.replace('<html lang="en">', `<html lang="en">${ziggeoHeaders(req.ypDomain.configuration.ziggeoApplicationToken)}`);
|
|
280
|
-
}
|
|
281
|
-
if (req.ypDomain.configuration &&
|
|
282
|
-
req.ypDomain.configuration.preloadCssUrl) {
|
|
283
|
-
indexFileData = indexFileData.replace('<html lang="en">', `<html lang="en"><link rel="stylesheet" href="${req.ypDomain.configuration.preloadCssUrl}">`);
|
|
284
|
-
}
|
|
285
|
-
//TODO: Remove when old client app version is deprecated fully
|
|
286
|
-
const plausibleReplaceKeyOld = `XplcX`;
|
|
287
|
-
const ga4TagKeyOld = `Xga4X`;
|
|
288
|
-
const plausibleReplaceKeyNew = `<meta name="XplcX" content="XplcX">`;
|
|
289
|
-
const ga4TagKeyNew = `<meta name="Xga4X" content="Xga4X">`;
|
|
290
|
-
const plausibleReplaceKey = useNewVersion ? plausibleReplaceKeyNew : plausibleReplaceKeyOld;
|
|
291
|
-
if (req.ypDomain &&
|
|
292
|
-
req.ypDomain.configuration &&
|
|
293
|
-
req.ypDomain.configuration.plausibleDataDomains &&
|
|
294
|
-
req.ypDomain.configuration.plausibleDataDomains.length > 5) {
|
|
295
|
-
indexFileData = indexFileData.replace(plausibleReplaceKey, getPlausibleCode(req.ypDomain.configuration.plausibleDataDomains));
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
indexFileData = indexFileData.replace(plausibleReplaceKey, "");
|
|
299
|
-
}
|
|
300
|
-
const ga4TagKey = useNewVersion ? ga4TagKeyNew : ga4TagKeyOld;
|
|
301
|
-
if (req.ypDomain &&
|
|
302
|
-
req.ypDomain.configuration &&
|
|
303
|
-
req.ypDomain.configuration.ga4Tag &&
|
|
304
|
-
req.ypDomain.configuration.ga4Tag.length > 4) {
|
|
305
|
-
indexFileData = indexFileData.replace(ga4TagKey, getGA4Code(req.ypDomain.configuration.ga4Tag));
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
indexFileData = indexFileData.replace(ga4TagKey, "");
|
|
309
|
-
}
|
|
310
|
-
if (req.hostname) {
|
|
311
|
-
if (req.hostname.indexOf("betrireykjavik.is") > -1) {
|
|
312
|
-
indexFileData = replaceForBetterReykjavik(indexFileData);
|
|
313
|
-
}
|
|
314
|
-
else if (req.hostname.indexOf("betraisland.is") > -1) {
|
|
315
|
-
indexFileData = replaceForBetterIceland(indexFileData);
|
|
316
|
-
}
|
|
317
|
-
else if (req.hostname.indexOf("smarter.nj.gov") > -1) {
|
|
318
|
-
indexFileData = replaceForSmarterNJ(indexFileData);
|
|
319
|
-
}
|
|
320
|
-
else if (req.hostname.indexOf("puttingcommunitiesfirst.org.uk") > -1) {
|
|
321
|
-
indexFileData = replaceForCommunityFund(indexFileData);
|
|
322
|
-
}
|
|
323
|
-
else if (req.hostname.indexOf("parliament.scot") > -1) {
|
|
324
|
-
indexFileData = replaceForParlScot(indexFileData);
|
|
325
|
-
}
|
|
326
|
-
else if (req.hostname.indexOf("ypus.org") > -1) {
|
|
327
|
-
indexFileData = replaceForYrpri(indexFileData);
|
|
328
|
-
}
|
|
329
|
-
else if (req.hostname.indexOf("mycitychallenge.org") > -1) {
|
|
330
|
-
indexFileData = replaceForMyCityChallenge(indexFileData);
|
|
331
|
-
}
|
|
332
|
-
else if (req.hostname.indexOf("engagebritain.org") > -1) {
|
|
333
|
-
indexFileData = replaceForEngageBritain(indexFileData);
|
|
334
|
-
}
|
|
335
|
-
else if (req.hostname.indexOf("tarsalgo.net") > -1) {
|
|
336
|
-
indexFileData = replaceForTarsalgo(indexFileData);
|
|
337
|
-
}
|
|
338
|
-
else if (req.hostname.indexOf("junges.wien") > -1) {
|
|
339
|
-
indexFileData = replaceForJungesWien(indexFileData);
|
|
340
|
-
}
|
|
341
|
-
else if (req.hostname.indexOf("openmontana.org") > -1) {
|
|
342
|
-
indexFileData = replaceForOpenMontana(indexFileData);
|
|
343
|
-
}
|
|
344
|
-
else if (req.hostname.indexOf("yrpri.org") > -1) {
|
|
345
|
-
indexFileData = replaceForYrpri(indexFileData);
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
indexFileData = replaceFromEnv(indexFileData);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
log.warn("No req.hostname");
|
|
353
|
-
indexFileData = replaceFromEnv(indexFileData);
|
|
354
|
-
}
|
|
355
|
-
try {
|
|
356
|
-
indexFileData = await replaceSharingData(req, indexFileData);
|
|
357
|
-
}
|
|
358
|
-
catch (error) {
|
|
359
|
-
log.error(`Error in index.html creation: ${error}`);
|
|
360
|
-
try {
|
|
361
|
-
indexFileData = replaceWithHardCodedFallback(req, indexFileData);
|
|
362
|
-
}
|
|
363
|
-
catch (error) {
|
|
364
|
-
log.error(`Error in index.html creation: ${error}`);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return indexFileData;
|
|
368
|
-
}
|
|
369
|
-
async function cacheIndexFile(filePath, versionKey) {
|
|
370
|
-
try {
|
|
371
|
-
const stats = await fs.promises.stat(filePath);
|
|
372
|
-
const data = await fs.promises.readFile(filePath, "utf8");
|
|
373
|
-
indexCache[versionKey].lastModified = stats.mtime.toUTCString();
|
|
374
|
-
indexCache[versionKey].data = data;
|
|
375
|
-
}
|
|
376
|
-
catch (err) {
|
|
377
|
-
console.error("Error caching index file:", err);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
let sendIndex = async (req, res) => {
|
|
381
|
-
log.info("Index Viewed", { userId: req.user ? req.user.id : null });
|
|
382
|
-
if (typeof req.useNewVersion === 'undefined') {
|
|
383
|
-
log.error("req.useNewVersion is undefined. This should never happen. Check setupNewWebAppVersionHandling middleware.", {
|
|
384
|
-
path: req.path,
|
|
385
|
-
method: req.method,
|
|
386
|
-
headers: req.headers,
|
|
387
|
-
session: req.session
|
|
388
|
-
});
|
|
389
|
-
// Default to old version in this unexpected case
|
|
390
|
-
req.useNewVersion = false;
|
|
391
|
-
}
|
|
392
|
-
let useNewVersion = req.useNewVersion;
|
|
393
|
-
let versionKey = useNewVersion ? 'newVersion' : 'oldVersion';
|
|
394
|
-
let indexFilePath = path.resolve(req.dirName, useNewVersion ? "../webAppsDist/client/dist/index.html" : "../webAppsDist/old/client/build/bundled/index.html");
|
|
395
|
-
// Ensure the version file is cached
|
|
396
|
-
if (!indexCache[versionKey].data || !indexCache[versionKey].lastModified) {
|
|
397
|
-
await cacheIndexFile(indexFilePath, versionKey);
|
|
398
|
-
}
|
|
399
|
-
log.info(`Index file path: ${indexFilePath}`);
|
|
400
|
-
try {
|
|
401
|
-
let indexFileData = indexCache[versionKey].data;
|
|
402
|
-
indexFileData = await replaceSiteData(indexFileData, req, useNewVersion);
|
|
403
|
-
res.setHeader("Cache-Control", "no-cache, must-revalidate");
|
|
404
|
-
res.setHeader("Last-Modified", indexCache[versionKey].lastModified);
|
|
405
|
-
res.send(indexFileData);
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
log.error(`Error in index.html processing: ${error}`);
|
|
409
|
-
res.status(500).send("Server error");
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
async function initializeIndexCache() {
|
|
413
|
-
try {
|
|
414
|
-
await Promise.all([
|
|
415
|
-
cacheIndexFile(path.resolve(__dirname, "../../webAppsDist/client/dist/index.html"), 'newVersion'),
|
|
416
|
-
cacheIndexFile(path.resolve(__dirname, "../../webAppsDist/old/client/build/bundled/index.html"), 'oldVersion')
|
|
417
|
-
]);
|
|
418
|
-
log.debug("Index cache initialized successfully");
|
|
419
|
-
}
|
|
420
|
-
catch (error) {
|
|
421
|
-
log.error("Failed to initialize index cache", { error });
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
initializeIndexCache();
|
|
425
|
-
router.get("/", function (req, res) {
|
|
426
|
-
sendIndex(req, res);
|
|
427
|
-
});
|
|
428
|
-
router.get("/domain{/*splat}", function (req, res) {
|
|
429
|
-
sendIndex(req, res);
|
|
430
|
-
});
|
|
431
|
-
router.get("/organization{/*splat}", function (req, res) {
|
|
432
|
-
sendIndex(req, res);
|
|
433
|
-
});
|
|
434
|
-
router.get("/community{/*splat}", function (req, res) {
|
|
435
|
-
sendIndex(req, res);
|
|
436
|
-
});
|
|
437
|
-
router.get("/agent_bundle{/*splat}", function (req, res) {
|
|
438
|
-
sendIndex(req, res);
|
|
439
|
-
});
|
|
440
|
-
router.get("/group{/*splat}", function (req, res) {
|
|
441
|
-
sendIndex(req, res);
|
|
442
|
-
});
|
|
443
|
-
router.get("/post{/*splat}", function (req, res) {
|
|
444
|
-
sendIndex(req, res);
|
|
445
|
-
});
|
|
446
|
-
router.get("/user{/*splat}", function (req, res) {
|
|
447
|
-
sendIndex(req, res);
|
|
448
|
-
});
|
|
449
|
-
module.exports = router;
|
|
@@ -1,35 +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 url = require('url');
|
|
9
|
-
var hostPartOfUrl = function (req) {
|
|
10
|
-
return url.format({
|
|
11
|
-
protocol: req.protocol,
|
|
12
|
-
host: req.get('host')
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
router.get('/:id', function (req, res) {
|
|
16
|
-
var cleanLegacyId = req.params.id.split("-")[0];
|
|
17
|
-
models.Page.findOne({
|
|
18
|
-
where: {
|
|
19
|
-
legacy_page_id: cleanLegacyId,
|
|
20
|
-
legacy_new_domain_id: req.ypDomain.id
|
|
21
|
-
}
|
|
22
|
-
}).then(function (page) {
|
|
23
|
-
if (page) {
|
|
24
|
-
var returnUrl = hostPartOfUrl(req) + "/page/" + page.id;
|
|
25
|
-
res.redirect(301, returnUrl);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
res.sendStatus(404);
|
|
29
|
-
}
|
|
30
|
-
}).catch(function (error) {
|
|
31
|
-
log.error({ err: error, context: 'legacy_page_id' });
|
|
32
|
-
res.sendStatus(404);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
module.exports = router;
|
|
@@ -1,56 +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 url = require('url');
|
|
9
|
-
var hostPartOfUrl = function (req) {
|
|
10
|
-
return url.format({
|
|
11
|
-
protocol: req.protocol,
|
|
12
|
-
host: req.get('host')
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
router.get('/:id', function (req, res) {
|
|
16
|
-
var cleanLegacyId = req.params.id.split("-")[0];
|
|
17
|
-
models.Post.findOne({
|
|
18
|
-
where: { legacy_post_id: cleanLegacyId },
|
|
19
|
-
include: [
|
|
20
|
-
{
|
|
21
|
-
model: models.Group,
|
|
22
|
-
required: true,
|
|
23
|
-
attributes: ['id'],
|
|
24
|
-
include: [
|
|
25
|
-
{
|
|
26
|
-
model: models.Community,
|
|
27
|
-
required: true,
|
|
28
|
-
attributes: ['id'],
|
|
29
|
-
include: [
|
|
30
|
-
{
|
|
31
|
-
model: models.Domain,
|
|
32
|
-
attributes: ['id'],
|
|
33
|
-
where: {
|
|
34
|
-
id: req.ypDomain.id
|
|
35
|
-
},
|
|
36
|
-
required: true
|
|
37
|
-
}
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}).then(function (post) {
|
|
44
|
-
if (post) {
|
|
45
|
-
var returnUrl = hostPartOfUrl(req) + "/post/" + post.id;
|
|
46
|
-
res.redirect(301, returnUrl);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
res.sendStatus(404);
|
|
50
|
-
}
|
|
51
|
-
}).catch(function (error) {
|
|
52
|
-
log.error({ err: error, context: 'legacy_post_id' });
|
|
53
|
-
res.sendStatus(404);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
module.exports = router;
|
|
@@ -1,36 +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 url = require('url');
|
|
9
|
-
var hostPartOfUrl = function (req) {
|
|
10
|
-
return url.format({
|
|
11
|
-
protocol: req.protocol,
|
|
12
|
-
host: req.get('host')
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
router.get('/:id', function (req, res) {
|
|
16
|
-
var cleanLegacyId = req.params.id.split("-")[0];
|
|
17
|
-
models.User.findOne({
|
|
18
|
-
where: {
|
|
19
|
-
legacy_user_id: cleanLegacyId,
|
|
20
|
-
legacy_new_domain_id: req.ypDomain.id
|
|
21
|
-
},
|
|
22
|
-
attributes: ['id', 'name', 'created_at']
|
|
23
|
-
}).then(function (user) {
|
|
24
|
-
if (user) {
|
|
25
|
-
var returnUrl = hostPartOfUrl(req) + "/user/" + user.id;
|
|
26
|
-
res.redirect(301, returnUrl);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
res.sendStatus(404);
|
|
30
|
-
}
|
|
31
|
-
}).catch(function (error) {
|
|
32
|
-
log.error({ err: error, context: 'legacy_user_id' });
|
|
33
|
-
res.sendStatus(404);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
module.exports = router;
|