@yrpri/api 9.0.103 → 9.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
package/dist/models/user.cjs
DELETED
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const async = require("async");
|
|
3
|
-
const log = require('../utils/logger.cjs');
|
|
4
|
-
const toJson = require('../utils/to_json.cjs');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
const bcrypt = require('bcrypt');
|
|
7
|
-
module.exports = (sequelize, DataTypes) => {
|
|
8
|
-
const User = sequelize.define("User", {
|
|
9
|
-
name: { type: DataTypes.STRING, allowNull: false },
|
|
10
|
-
email: { type: DataTypes.STRING, allowNull: true },
|
|
11
|
-
status: { type: DataTypes.STRING, allowNull: false },
|
|
12
|
-
ssn: DataTypes.STRING,
|
|
13
|
-
age_group: DataTypes.STRING,
|
|
14
|
-
post_code: DataTypes.STRING,
|
|
15
|
-
my_gender: DataTypes.STRING,
|
|
16
|
-
description: DataTypes.TEXT,
|
|
17
|
-
profile_data: DataTypes.JSONB,
|
|
18
|
-
private_profile_data: DataTypes.JSONB,
|
|
19
|
-
deleted: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
|
|
20
|
-
facebook_id: DataTypes.BIGINT,
|
|
21
|
-
facebook_profile: DataTypes.JSONB,
|
|
22
|
-
twitter_id: DataTypes.BIGINT,
|
|
23
|
-
twitter_profile: DataTypes.JSONB,
|
|
24
|
-
google_id: DataTypes.BIGINT,
|
|
25
|
-
google_profile: DataTypes.JSONB,
|
|
26
|
-
github_id: DataTypes.BIGINT,
|
|
27
|
-
github_profile: DataTypes.JSONB,
|
|
28
|
-
buddy_icon_file_name: DataTypes.STRING,
|
|
29
|
-
twitter_profile_image_url: DataTypes.STRING,
|
|
30
|
-
encrypted_password: DataTypes.STRING,
|
|
31
|
-
default_locale: DataTypes.STRING,
|
|
32
|
-
reset_password_token: DataTypes.STRING,
|
|
33
|
-
reset_password_expires: DataTypes.DATE,
|
|
34
|
-
notifications_settings: { type: DataTypes.JSONB },
|
|
35
|
-
interaction_profile: DataTypes.JSONB,
|
|
36
|
-
counter_login: { type: DataTypes.INTEGER, defaultValue: 0 },
|
|
37
|
-
last_login_at: DataTypes.DATE,
|
|
38
|
-
social_points: DataTypes.INTEGER,
|
|
39
|
-
legacy_user_id: DataTypes.INTEGER,
|
|
40
|
-
legacy_new_domain_id: DataTypes.INTEGER,
|
|
41
|
-
theme_id: { type: DataTypes.INTEGER, defaultValue: null },
|
|
42
|
-
legacy_passwords_disabled: { type: DataTypes.BOOLEAN, defaultValue: false },
|
|
43
|
-
privacy_settings: DataTypes.JSONB,
|
|
44
|
-
ignore_list: DataTypes.JSONB
|
|
45
|
-
}, {
|
|
46
|
-
underscored: true,
|
|
47
|
-
timestamps: true,
|
|
48
|
-
createdAt: 'created_at',
|
|
49
|
-
updatedAt: 'updated_at',
|
|
50
|
-
tableName: 'users',
|
|
51
|
-
defaultScope: {
|
|
52
|
-
where: {
|
|
53
|
-
deleted: false,
|
|
54
|
-
status: 'active'
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
indexes: [
|
|
58
|
-
{
|
|
59
|
-
unique: true,
|
|
60
|
-
fields: ['email']
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'users_idx_deleted_status',
|
|
64
|
-
fields: ['deleted', 'status']
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
fields: ['interaction_profile'],
|
|
68
|
-
using: 'gin',
|
|
69
|
-
operator: 'jsonb_path_ops'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
fields: ['ssn']
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
fields: ['facebook_id']
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
fields: ['notifications_settings'],
|
|
79
|
-
using: 'gin',
|
|
80
|
-
operator: 'jsonb_path_ops'
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
fields: ['id', 'deleted']
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
fields: ['id', 'deleted', 'status']
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
User.associate = (models) => {
|
|
91
|
-
User.hasMany(models.Post);
|
|
92
|
-
User.hasMany(models.Point);
|
|
93
|
-
User.hasMany(models.Endorsement);
|
|
94
|
-
User.hasMany(models.PointQuality);
|
|
95
|
-
User.hasMany(models.UserLegacyPassword);
|
|
96
|
-
User.belongsToMany(models.Group, { as: 'GroupUsers', through: 'GroupUser' });
|
|
97
|
-
User.belongsToMany(models.Community, { as: 'CommunityUsers', through: 'CommunityUser' });
|
|
98
|
-
User.belongsToMany(models.Domain, { as: 'DomainUsers', through: 'DomainUser' });
|
|
99
|
-
User.belongsToMany(models.Image, { as: 'UserProfileImages', through: 'UserProfileImage' });
|
|
100
|
-
User.belongsToMany(models.Image, { as: 'UserHeaderImages', through: 'UserHeaderImage' });
|
|
101
|
-
User.belongsToMany(models.Domain, { as: 'DomainAdmins', through: 'DomainAdmin' });
|
|
102
|
-
User.belongsToMany(models.Community, { as: 'CommunityAdmins', through: 'CommunityAdmin' });
|
|
103
|
-
User.belongsToMany(models.Community, { as: 'CommunityPromoters', through: 'CommunityPromoter' });
|
|
104
|
-
User.belongsToMany(models.Group, { as: 'GroupAdmins', through: 'GroupAdmin' });
|
|
105
|
-
User.belongsToMany(models.Group, { as: 'GroupPromoters', through: 'GroupPromoter' });
|
|
106
|
-
User.belongsToMany(models.Organization, { as: 'OrganizationAdmins', through: 'OrganizationAdmin' });
|
|
107
|
-
User.belongsToMany(models.Organization, { as: 'OrganizationUsers', through: 'OrganizationUser' });
|
|
108
|
-
User.belongsToMany(models.Video, { as: 'UserProfileVideos', through: 'UserProfileVideo' });
|
|
109
|
-
User.hasMany(models.Campaign);
|
|
110
|
-
};
|
|
111
|
-
User.defaultAttributesWithSocialMedia = ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'github_id', 'twitter_id', 'default_locale', 'legacy_passwords_disabled'];
|
|
112
|
-
User.defaultAttributesWithSocialMediaPublic = ['id', 'description', 'name', 'facebook_id', 'google_id', 'github_id', 'twitter_id', 'legacy_passwords_disabled'];
|
|
113
|
-
User.defaultAttributesWithSocialMediaPublicAndEmail = ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'github_id', 'twitter_id', 'legacy_passwords_disabled'];
|
|
114
|
-
User.serializeSamlUser = (profile, req, callback) => {
|
|
115
|
-
log.info("Serialize SAML user", { context: 'serializeSamlUser', profile: profile });
|
|
116
|
-
if (profile.UserSSN) {
|
|
117
|
-
sequelize.models.User.serializeIslandIsSamlUser(profile, callback);
|
|
118
|
-
}
|
|
119
|
-
else if (profile["urn:mynj:userCode"] || profile.issuer === 'https://my.state.nj.us/idp/shibboleth') {
|
|
120
|
-
sequelize.models.User.serializeMyNJSamlUser(profile, req, callback);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
callback("Can't find SAML serialize handler");
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
User.serializeMyNJSamlUser = (profile, req, callback) => {
|
|
127
|
-
log.info("User Serialized In Serialize MyNJ SAML User", { context: 'serializeSamlUser', profile: profile });
|
|
128
|
-
let email = null;
|
|
129
|
-
let user;
|
|
130
|
-
async.series([
|
|
131
|
-
(seriesCallback) => {
|
|
132
|
-
if (!profile["urn:mynj:userCode"] ||
|
|
133
|
-
(req.ypDomain.configuration &&
|
|
134
|
-
req.ypDomain.configuration.forceSecureSamlEmployeeLogin &&
|
|
135
|
-
!profile["urn:mynj:pubEmpAgency"])) {
|
|
136
|
-
log.info("User not allowed access through MyNJ", { context: 'serializeSamlUser', profile: profile });
|
|
137
|
-
seriesCallback("customError");
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
seriesCallback();
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
(seriesCallback) => {
|
|
144
|
-
sequelize.models.User.findOne({
|
|
145
|
-
where: {
|
|
146
|
-
ssn: profile["urn:mynj:userCode"]
|
|
147
|
-
},
|
|
148
|
-
attributes: ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'profile_data', 'github_id', 'twitter_id', 'ssn', 'legacy_passwords_disabled']
|
|
149
|
-
}).then((userIn) => {
|
|
150
|
-
if (userIn) {
|
|
151
|
-
user = userIn;
|
|
152
|
-
log.info("User Serialized Found MyNJ SAML User", { context: 'serializeSamlUser', userSsn: user.ssn });
|
|
153
|
-
seriesCallback();
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
seriesCallback();
|
|
157
|
-
}
|
|
158
|
-
}).catch((error) => {
|
|
159
|
-
seriesCallback(error);
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
(seriesCallback) => {
|
|
163
|
-
if (!user) {
|
|
164
|
-
email = profile["urn:mynj:pubEmpEmail"];
|
|
165
|
-
if (email) {
|
|
166
|
-
email = email.toLowerCase();
|
|
167
|
-
sequelize.models.User.findOne({
|
|
168
|
-
where: {
|
|
169
|
-
email: email
|
|
170
|
-
},
|
|
171
|
-
attributes: ['id', 'email']
|
|
172
|
-
}).then((userByEmail) => {
|
|
173
|
-
if (userByEmail) {
|
|
174
|
-
email = 'my-nj-' + Math.floor(Math.random() * 999) + '.' + email;
|
|
175
|
-
}
|
|
176
|
-
seriesCallback();
|
|
177
|
-
}).catch((error) => {
|
|
178
|
-
seriesCallback(error);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
seriesCallback();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
seriesCallback();
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
(seriesCallback) => {
|
|
190
|
-
if (!user) {
|
|
191
|
-
sequelize.models.User.create({
|
|
192
|
-
ssn: profile["urn:mynj:userCode"],
|
|
193
|
-
name: profile.FirstName + ' ' + profile.LastName,
|
|
194
|
-
email: email,
|
|
195
|
-
profile_data: {
|
|
196
|
-
saml_show_confirm_email_completed: email ? false : true,
|
|
197
|
-
},
|
|
198
|
-
private_profile_data: {
|
|
199
|
-
saml_agency: profile["urn:mynj:pubEmpAgency"],
|
|
200
|
-
saml_provider: 'MyNJ'
|
|
201
|
-
},
|
|
202
|
-
notifications_settings: sequelize.models.AcNotification.defaultNotificationSettings,
|
|
203
|
-
status: 'active'
|
|
204
|
-
}).then((userIn) => {
|
|
205
|
-
if (userIn) {
|
|
206
|
-
user = userIn;
|
|
207
|
-
log.info("User Serialized Created MyNJ SAML User", { context: 'serializeSamlUser', userSsn: user.ssn });
|
|
208
|
-
seriesCallback();
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
seriesCallback("Could not create user from SAML");
|
|
212
|
-
}
|
|
213
|
-
}).catch((error) => {
|
|
214
|
-
seriesCallback(error);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
seriesCallback();
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
], (error) => {
|
|
222
|
-
if (error) {
|
|
223
|
-
callback(error);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
callback(null, user);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
User.serializeIslandIsSamlUser = (profile, callback) => {
|
|
231
|
-
log.info("User Serialized In Serialize IslandIs SAML User", { context: 'serializeSamlUser', profile: profile });
|
|
232
|
-
let user;
|
|
233
|
-
async.series([
|
|
234
|
-
(seriesCallback) => {
|
|
235
|
-
sequelize.models.User.findOne({
|
|
236
|
-
where: {
|
|
237
|
-
ssn: profile.UserSSN
|
|
238
|
-
},
|
|
239
|
-
attributes: ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'profile_data', 'github_id', 'twitter_id', 'ssn', 'legacy_passwords_disabled']
|
|
240
|
-
}).then((userIn) => {
|
|
241
|
-
if (userIn) {
|
|
242
|
-
user = userIn;
|
|
243
|
-
log.info("User Serialized Found IslandIs SAML User", { context: 'serializeSamlUser', userSsn: user.ssn });
|
|
244
|
-
seriesCallback();
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
seriesCallback();
|
|
248
|
-
}
|
|
249
|
-
}).catch((error) => {
|
|
250
|
-
seriesCallback(error);
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
(seriesCallback) => {
|
|
254
|
-
if (!user) {
|
|
255
|
-
sequelize.models.User.create({
|
|
256
|
-
ssn: profile.UserSSN,
|
|
257
|
-
name: profile.Name,
|
|
258
|
-
private_profile_data: { saml_provider: 'island.is' },
|
|
259
|
-
notifications_settings: sequelize.models.AcNotification.defaultNotificationSettings,
|
|
260
|
-
status: 'active'
|
|
261
|
-
}).then((userIn) => {
|
|
262
|
-
if (userIn) {
|
|
263
|
-
user = userIn;
|
|
264
|
-
log.info("User Serialized Created IslandIs SAML User", { context: 'serializeSamlUser', userSsn: user.ssn });
|
|
265
|
-
seriesCallback();
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
seriesCallback("Could not create user from SAML");
|
|
269
|
-
}
|
|
270
|
-
}).catch((error) => {
|
|
271
|
-
seriesCallback(error);
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
seriesCallback();
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
], (error) => {
|
|
279
|
-
if (error) {
|
|
280
|
-
callback(error);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
callback(null, user);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
User.serializeOidcUser = (profile, req, callback) => {
|
|
288
|
-
log.info("User Serialized In Serialize OIDC User", { context: 'serializeOidcUser', profile: profile });
|
|
289
|
-
let user;
|
|
290
|
-
async.series([
|
|
291
|
-
(seriesCallback) => {
|
|
292
|
-
sequelize.models.User.findOne({
|
|
293
|
-
where: {
|
|
294
|
-
ssn: profile.nationalRegisterId
|
|
295
|
-
},
|
|
296
|
-
attributes: ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'profile_data', 'github_id', 'twitter_id', 'ssn', 'legacy_passwords_disabled']
|
|
297
|
-
}).then((userIn) => {
|
|
298
|
-
if (userIn) {
|
|
299
|
-
user = userIn;
|
|
300
|
-
log.info("User Serialized Found OIDC User", { context: 'serializeOidcUser', userSsn: user.ssn });
|
|
301
|
-
seriesCallback();
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
seriesCallback();
|
|
305
|
-
}
|
|
306
|
-
}).catch((error) => {
|
|
307
|
-
seriesCallback(error);
|
|
308
|
-
});
|
|
309
|
-
},
|
|
310
|
-
(seriesCallback) => {
|
|
311
|
-
if (!user) {
|
|
312
|
-
sequelize.models.User.create({
|
|
313
|
-
ssn: profile.nationalRegisterId,
|
|
314
|
-
name: profile.name,
|
|
315
|
-
private_profile_data: { oidc_provider: "oidc" },
|
|
316
|
-
notifications_settings: sequelize.models.AcNotification.defaultNotificationSettings,
|
|
317
|
-
status: 'active'
|
|
318
|
-
}).then((userIn) => {
|
|
319
|
-
if (userIn) {
|
|
320
|
-
user = userIn;
|
|
321
|
-
log.info("User Serialized Created OIDC User", { context: 'serializeOidcUser', userSsn: user.ssn });
|
|
322
|
-
seriesCallback();
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
seriesCallback("Could not create user from OIDC");
|
|
326
|
-
}
|
|
327
|
-
}).catch((error) => {
|
|
328
|
-
seriesCallback(error);
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
seriesCallback();
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
], (error) => {
|
|
336
|
-
if (error) {
|
|
337
|
-
callback(error);
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
callback(null, user);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
User.serializeFacebookUser = (profile, domain, callback) => {
|
|
345
|
-
let user;
|
|
346
|
-
async.series([
|
|
347
|
-
(seriesCallback) => {
|
|
348
|
-
sequelize.models.User.findOne({
|
|
349
|
-
where: {
|
|
350
|
-
facebook_id: profile.identifier
|
|
351
|
-
},
|
|
352
|
-
attributes: ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'github_id', 'twitter_id', 'legacy_passwords_disabled']
|
|
353
|
-
}).then((userIn) => {
|
|
354
|
-
if (userIn) {
|
|
355
|
-
user = userIn;
|
|
356
|
-
seriesCallback();
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
seriesCallback();
|
|
360
|
-
}
|
|
361
|
-
}).catch((error) => {
|
|
362
|
-
seriesCallback(error);
|
|
363
|
-
});
|
|
364
|
-
},
|
|
365
|
-
(seriesCallback) => {
|
|
366
|
-
if (!user && profile.email) {
|
|
367
|
-
sequelize.models.User.findOne({
|
|
368
|
-
where: {
|
|
369
|
-
email: profile.email
|
|
370
|
-
},
|
|
371
|
-
attributes: ['id', 'email', 'description', 'name', 'facebook_id', 'google_id', 'github_id', 'twitter_id', 'legacy_passwords_disabled']
|
|
372
|
-
}).then((userIn) => {
|
|
373
|
-
if (userIn) {
|
|
374
|
-
userIn.facebook_id = profile.identifier;
|
|
375
|
-
userIn.save().then((results) => {
|
|
376
|
-
user = userIn;
|
|
377
|
-
seriesCallback();
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
seriesCallback();
|
|
382
|
-
}
|
|
383
|
-
}).catch((error) => {
|
|
384
|
-
seriesCallback(error);
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
seriesCallback();
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
(seriesCallback) => {
|
|
392
|
-
if (!user) {
|
|
393
|
-
sequelize.models.User.create({
|
|
394
|
-
email: profile.email,
|
|
395
|
-
facebook_id: profile.identifier,
|
|
396
|
-
name: profile.nameDisplay,
|
|
397
|
-
notifications_settings: sequelize.models.AcNotification.defaultNotificationSettings,
|
|
398
|
-
status: 'active'
|
|
399
|
-
}).then((userIn) => {
|
|
400
|
-
if (userIn) {
|
|
401
|
-
user = userIn;
|
|
402
|
-
seriesCallback();
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
seriesCallback("Could not create user");
|
|
406
|
-
}
|
|
407
|
-
}).catch((error) => {
|
|
408
|
-
seriesCallback(error);
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
seriesCallback();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
], (error) => {
|
|
416
|
-
if (error) {
|
|
417
|
-
callback(error);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
callback(null, user);
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
};
|
|
424
|
-
User.localCallback = (req, email, password, done) => {
|
|
425
|
-
sequelize.models.User.findOne({
|
|
426
|
-
where: { email: email },
|
|
427
|
-
attributes: ['id', 'encrypted_password', 'legacy_passwords_disabled']
|
|
428
|
-
}).then((user) => {
|
|
429
|
-
if (user) {
|
|
430
|
-
user.validatePassword(password, done);
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
log.warn("User LocalStrategy Incorrect username", { context: 'localStrategy', user: toJson(user), err: 'Incorrect username', errorStatus: 401 });
|
|
434
|
-
return done(null, false, { message: 'Incorrect username.' });
|
|
435
|
-
}
|
|
436
|
-
return null;
|
|
437
|
-
}).catch((error) => {
|
|
438
|
-
log.error("User LocalStrategy Error", { context: 'localStrategy', err: error, errorStatus: 500 });
|
|
439
|
-
done(error);
|
|
440
|
-
});
|
|
441
|
-
};
|
|
442
|
-
User.getUserWithAll = (userId, callback) => {
|
|
443
|
-
let user, endorsements, pointQualities;
|
|
444
|
-
async.parallel([
|
|
445
|
-
(seriesCallback) => {
|
|
446
|
-
sequelize.models.User.findOne({
|
|
447
|
-
where: { id: userId },
|
|
448
|
-
attributes: _.concat(sequelize.models.User.defaultAttributesWithSocialMediaPublic, ['notifications_settings', 'profile_data', 'email', 'default_locale']),
|
|
449
|
-
order: [
|
|
450
|
-
[{ model: sequelize.models.Image, as: 'UserProfileImages' }, 'created_at', 'asc'],
|
|
451
|
-
[{ model: sequelize.models.Image, as: 'UserHeaderImages' }, 'created_at', 'asc']
|
|
452
|
-
],
|
|
453
|
-
include: [
|
|
454
|
-
{
|
|
455
|
-
model: sequelize.models.Image, as: 'UserProfileImages',
|
|
456
|
-
attributes: ['id', 'created_at', 'formats'],
|
|
457
|
-
required: false
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
model: sequelize.models.Image, as: 'UserHeaderImages',
|
|
461
|
-
attributes: ['id', 'created_at', 'formats'],
|
|
462
|
-
required: false
|
|
463
|
-
}
|
|
464
|
-
]
|
|
465
|
-
}).then((userIn) => {
|
|
466
|
-
user = userIn;
|
|
467
|
-
seriesCallback();
|
|
468
|
-
}).catch((error) => {
|
|
469
|
-
seriesCallback(error);
|
|
470
|
-
});
|
|
471
|
-
},
|
|
472
|
-
(seriesCallback) => {
|
|
473
|
-
sequelize.models.Endorsement.findAll({
|
|
474
|
-
where: { user_id: userId },
|
|
475
|
-
attributes: ['id', 'value', 'post_id']
|
|
476
|
-
}).then((endorsementsIn) => {
|
|
477
|
-
endorsements = endorsementsIn;
|
|
478
|
-
seriesCallback();
|
|
479
|
-
}).catch((error) => {
|
|
480
|
-
seriesCallback(error);
|
|
481
|
-
});
|
|
482
|
-
},
|
|
483
|
-
(seriesCallback) => {
|
|
484
|
-
sequelize.models.PointQuality.findAll({
|
|
485
|
-
where: { user_id: userId },
|
|
486
|
-
attributes: ['id', 'value', 'point_id']
|
|
487
|
-
}).then((pointQualitiesIn) => {
|
|
488
|
-
pointQualities = pointQualitiesIn;
|
|
489
|
-
seriesCallback();
|
|
490
|
-
}).catch((error) => {
|
|
491
|
-
seriesCallback(error);
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
], (error) => {
|
|
495
|
-
if (user) {
|
|
496
|
-
user.dataValues.Endorsements = endorsements;
|
|
497
|
-
user.dataValues.PointQualities = pointQualities;
|
|
498
|
-
}
|
|
499
|
-
callback(error, user);
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
User.prototype.simple = function () {
|
|
503
|
-
return { id: this.id, name: this.name, email: this.email };
|
|
504
|
-
};
|
|
505
|
-
User.prototype.setLocale = function (i18n, domain, community, done) {
|
|
506
|
-
if (this.default_locale && this.default_locale !== "") {
|
|
507
|
-
i18n.changeLanguage(this.default_locale, (err, t) => {
|
|
508
|
-
done();
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
else if (community && community.default_locale && community.default_locale !== "") {
|
|
512
|
-
i18n.changeLanguage(community.default_locale, (err, t) => {
|
|
513
|
-
done();
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
i18n.changeLanguage(domain.default_locale, (err, t) => {
|
|
518
|
-
done();
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
User.prototype.setupProfileImage = function (body, done) {
|
|
523
|
-
if (body.uploadedProfileImageId) {
|
|
524
|
-
sequelize.models.Image.findOne({
|
|
525
|
-
where: { id: body.uploadedProfileImageId }
|
|
526
|
-
}).then((image) => {
|
|
527
|
-
if (image)
|
|
528
|
-
this.addUserProfileImage(image);
|
|
529
|
-
done();
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
else
|
|
533
|
-
done();
|
|
534
|
-
};
|
|
535
|
-
User.prototype.setupHeaderImage = function (body, done) {
|
|
536
|
-
if (body.uploadedHeaderImageId) {
|
|
537
|
-
sequelize.models.Image.findOne({
|
|
538
|
-
where: { id: body.uploadedHeaderImageId }
|
|
539
|
-
}).then((image) => {
|
|
540
|
-
if (image)
|
|
541
|
-
this.addUserHeaderImage(image);
|
|
542
|
-
done();
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
else
|
|
546
|
-
done();
|
|
547
|
-
};
|
|
548
|
-
User.prototype.setupImages = function (body, done) {
|
|
549
|
-
async.parallel([
|
|
550
|
-
(callback) => {
|
|
551
|
-
this.setupProfileImage(body, (err) => {
|
|
552
|
-
if (err)
|
|
553
|
-
return callback(err);
|
|
554
|
-
callback();
|
|
555
|
-
});
|
|
556
|
-
},
|
|
557
|
-
(callback) => {
|
|
558
|
-
this.setupHeaderImage(body, (err) => {
|
|
559
|
-
if (err)
|
|
560
|
-
return callback(err);
|
|
561
|
-
callback();
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
], (err) => {
|
|
565
|
-
done(err);
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
User.prototype.createPasswordHash = function (password) {
|
|
569
|
-
const salt = bcrypt.genSaltSync(10);
|
|
570
|
-
this.encrypted_password = bcrypt.hashSync(password, salt);
|
|
571
|
-
};
|
|
572
|
-
User.prototype.validatePassword = function (password, done) {
|
|
573
|
-
let verified = this.encrypted_password ? bcrypt.compareSync(password, this.encrypted_password) : null;
|
|
574
|
-
if (verified) {
|
|
575
|
-
console.log(`User ${this.id} has verified password`);
|
|
576
|
-
done(null, this);
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
if (this.legacy_passwords_disabled) {
|
|
580
|
-
done(null, false, { message: 'Incorrect password.' });
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
log.warn("Looking for legacy passwords");
|
|
584
|
-
sequelize.models.User.findOne({
|
|
585
|
-
where: { id: this.id },
|
|
586
|
-
include: [sequelize.models.UserLegacyPassword]
|
|
587
|
-
}).then((user) => {
|
|
588
|
-
user.UserLegacyPasswords.map((legacyPassword) => {
|
|
589
|
-
if (bcrypt.compareSync(password, legacyPassword.encrypted_password)) {
|
|
590
|
-
verified = true;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
if (verified) {
|
|
594
|
-
done(null, this);
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
done(null, false, { message: 'Incorrect password.' });
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
};
|
|
603
|
-
return User;
|
|
604
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
module.exports = (sequelize, DataTypes) => {
|
|
3
|
-
const UserLegacyPassword = sequelize.define("UserLegacyPassword", {
|
|
4
|
-
encrypted_password: { type: DataTypes.STRING, allowNull: false }
|
|
5
|
-
}, {
|
|
6
|
-
underscored: true,
|
|
7
|
-
tableName: 'user_legacy_passwords'
|
|
8
|
-
});
|
|
9
|
-
UserLegacyPassword.associate = (models) => {
|
|
10
|
-
UserLegacyPassword.belongsTo(models.User, { foreignKey: 'user_id' });
|
|
11
|
-
};
|
|
12
|
-
return UserLegacyPassword;
|
|
13
|
-
};
|