@yrpri/api 9.0.139 → 9.0.141
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/agents/assistants/agentAssistant.js +4 -3
- package/agents/assistants/baseAssistant.js +72 -71
- package/agents/assistants/baseAssistantWithVoice.js +6 -5
- package/agents/assistants/modes/agentDirectConnection.js +8 -7
- package/agents/assistants/modes/agentSelectionMode.js +2 -1
- package/agents/assistants/modes/baseAssistantMode.js +3 -2
- package/agents/assistants/modes/tools/agentTools.js +11 -10
- package/agents/assistants/modes/tools/loginTools.js +7 -6
- package/agents/assistants/modes/tools/models/agents.js +6 -5
- package/agents/assistants/modes/tools/models/subscriptions.js +7 -6
- package/agents/assistants/modes/tools/navigationTools.js +7 -6
- package/agents/assistants/modes/tools/subscriptionTools.js +12 -11
- package/agents/assistants/modes/tools/workflowConverstationTools.js +7 -6
- package/agents/assistants/voiceAssistant.js +45 -44
- package/agents/controllers/agentProductController.js +8 -7
- package/agents/controllers/agentSubscriptionController.js +13 -12
- package/agents/controllers/assistantsController.js +45 -44
- package/agents/controllers/policySynthAgents.js +33 -32
- package/agents/managers/emailInvitesManager.js +4 -3
- package/agents/managers/newAiModelSetup.js +46 -45
- package/agents/managers/notificationAgentQueueManager.js +55 -54
- package/agents/managers/subscriptionManager.js +24 -23
- package/agents/models/agentProduct.js +2 -1
- package/agents/models/agentProductBoosterPurchase.js +2 -1
- package/agents/models/testData/createEvolyAgentProduct.js +7 -6
- package/agents/models/testData/old/updateAgentWorkflowConfiguration.js +5 -4
- package/agents/models/testData/updateAgentWorkflowConfiguration.js +5 -4
- package/agents/tools/setTemplateWorkflowCommunityId.js +6 -5
- package/app.d.ts +2 -1
- package/app.js +60 -34
- package/authorization.cjs +4 -4
- package/controllers/allOurIdeas.js +45 -44
- package/controllers/groups.cjs +4 -9
- package/controllers/images.cjs +8 -8
- package/controllers/index.cjs +1 -1
- package/controllers/points.cjs +1 -1
- package/controllers/posts.cjs +3 -3
- package/deleteUnwantedDeclerations.cjs +6 -5
- package/models/community.cjs +1 -1
- package/models/domain.cjs +7 -7
- package/models/image.cjs +2 -2
- package/models/index.cjs +8 -4
- package/models/post.cjs +10 -10
- package/models/user.cjs +1 -1
- package/models/video.cjs +4 -4
- package/package.json +5 -5
- package/scripts/addRatingUsersToGroup.js +1 -1
- package/scripts/addUserToOrganization.js +8 -8
- package/scripts/agents/changeModelForWorkflowGroupTemplate.js +13 -12
- package/scripts/agents/generateAgentWorkflowTemplateFromAgentClass.js +5 -4
- package/scripts/analyseRatingsForCommunity.js +2 -2
- package/scripts/analyzeAndFixBrokenPointUsers.js +3 -3
- package/scripts/analyzeEndorsementsByCountry.js +7 -7
- package/scripts/analyzePostsForCommunity.js +1 -1
- package/scripts/bulkStatusUpdates/listUpdates.js +2 -2
- package/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +5 -5
- package/scripts/bulkStatusUpdates/performUpdate.js +9 -9
- package/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +12 -11
- package/scripts/bulkStatusUpdates/performUpdateForStatus.js +15 -15
- package/scripts/change/changeVideoAspectTo.js +3 -3
- package/scripts/change/setUseNewVersion.cjs +5 -4
- package/scripts/changeCommunityGroupcount.js +3 -3
- package/scripts/changeCommunityPostCount.js +3 -3
- package/scripts/changeGroupPostCount.js +3 -3
- package/scripts/changeLanguage.js +4 -4
- package/scripts/changeOfficalStatus.js +3 -3
- package/scripts/cleanups/deleteAnonNotifications.cjs +8 -7
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +8 -8
- package/scripts/cleanups/deleteYearOldNotifications.cjs +6 -5
- package/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +5 -5
- package/scripts/clearAllEndorsementInGroup.js +5 -5
- package/scripts/cloning/clearUsersForCommunitiesFromUrl.js +3 -3
- package/scripts/cloning/cloneFromUrlScript.js +4 -4
- package/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +6 -6
- package/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +3 -3
- package/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +2 -2
- package/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +2 -2
- package/scripts/cloning/copyCommunityToDomainWithEverything.js +2 -2
- package/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +3 -3
- package/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +3 -3
- package/scripts/cloning/copyPostToGroupOld.js +12 -12
- package/scripts/cloning/copyPostVideosFromURL.js +3 -3
- package/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +2 -2
- package/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +7 -7
- package/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +6 -6
- package/scripts/cloning/setAdminsFromURL.js +5 -5
- package/scripts/cloning/setExternalIdsFromURL.js +3 -3
- package/scripts/countCommunity.js +11 -11
- package/scripts/countCommunityUsers.js +4 -4
- package/scripts/countDelayedNotifications.js +3 -3
- package/scripts/countGroup.js +11 -11
- package/scripts/countStuff.js +3 -3
- package/scripts/countUniqueVotersInAGroup.js +3 -3
- package/scripts/createInvitesAndShow.js +2 -2
- package/scripts/database/sync_database.js +2 -2
- package/scripts/database/sync_dev_database.js +3 -3
- package/scripts/debugNotifications.js +5 -5
- package/scripts/deleteAllNewsFeeds.js +2 -2
- package/scripts/deleteCategory.js +1 -1
- package/scripts/deleteOldAppActivities.js +5 -4
- package/scripts/deletePostContactDataForCommunity.js +5 -4
- package/scripts/destroy/destroy_all_but_one_domain.js +59 -59
- package/scripts/displayAuthorForPost.js +1 -1
- package/scripts/domains/createDomain.js +5 -4
- package/scripts/domains/importDomainsFromXls.js +7 -6
- package/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +2 -2
- package/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +9 -9
- package/scripts/exportAllStatusChanges.js +5 -5
- package/scripts/exportEndorsementsForCommunity.js +5 -5
- package/scripts/exportPointQualitiesForCommunity.js +5 -5
- package/scripts/exportPostsAndPointsForCommunity.js +9 -9
- package/scripts/exportPostsDataSetForDomain.js +12 -12
- package/scripts/exportPostsForGroup.js +7 -7
- package/scripts/exportRatingsForPost.js +2 -2
- package/scripts/exportUserEndorsementsWithUserAnalysis.js +6 -6
- package/scripts/exportUsersForCommunity.js +3 -3
- package/scripts/exportUsersForDomain.js +3 -3
- package/scripts/exportUsersForGroup.js +3 -3
- package/scripts/exports/ratingDistribution.js +6 -6
- package/scripts/exports/whoEndorsedWhatByCommunity.js +2 -2
- package/scripts/findUnusedClientImports.js +2 -2
- package/scripts/fixAllPostPointCounts.js +1 -1
- package/scripts/fixAnonNotificationsSettings.js +5 -5
- package/scripts/fixCountKopavogur.js +1 -1
- package/scripts/fixEndorsementsAfterCopyPostToGroup.js +10 -10
- package/scripts/fixExternalUserId.js +2 -2
- package/scripts/fixGroupAccess.js +3 -3
- package/scripts/fixGroupIdeasAndPointsCount.js +2 -2
- package/scripts/fixNotificationSettings.js +4 -4
- package/scripts/fixSurveyRadioBakedInSubCodes.js +6 -6
- package/scripts/fixWrongUserIdForStatusUpdates.js +6 -5
- package/scripts/gallery/exportGalleryData.js +2 -2
- package/scripts/gallery/importGalleryForCommunity.js +14 -14
- package/scripts/gallery/readJsonAndDownloadImagesVersion2.js +6 -6
- package/scripts/gallery/refreshAcApiPostIdsForCommunity.js +5 -5
- package/scripts/genderAnalysis.js +10 -10
- package/scripts/genderAnalysisByStatus.js +4 -4
- package/scripts/importAllLocalesFromLocalFolders.js +7 -7
- package/scripts/importDomain.js +131 -131
- package/scripts/keys/addOidcToDomain.cjs +10 -9
- package/scripts/landUseGame/export3Ddata.js +15 -15
- package/scripts/listLanguagesForGroup.js +6 -6
- package/scripts/loadTestCreateDummyContentForGroup.js +2 -2
- package/scripts/makeRecursiveMapData.js +4 -4
- package/scripts/mapping/community_map_csv.js +5 -5
- package/scripts/moveCommunityToDomain.js +3 -3
- package/scripts/moveGroupToCommunity.js +3 -3
- package/scripts/movePostToGroup.js +5 -5
- package/scripts/movePostsToGroupsRecountGroupFromUrl.js +6 -6
- package/scripts/oldMovePostToGroup.js +9 -9
- package/scripts/processCsvForPdfUrls.js +2 -2
- package/scripts/processCsvForTranslationAndToxicity.js +10 -10
- package/scripts/recount/recount_recursive_communities.js +6 -6
- package/scripts/recountALLCommunityGroupCounts.js +4 -4
- package/scripts/recountAll.js +3 -3
- package/scripts/recountCommunitesFromUrl.js +3 -3
- package/scripts/recountCommunity.js +2 -2
- package/scripts/recountGroup.js +5 -5
- package/scripts/recountGroupNoUserChange.js +5 -5
- package/scripts/resetAllEndorsementsForGroup.js +3 -3
- package/scripts/resetEnTranslationForGroup.js +5 -5
- package/scripts/setAdminOnAll.cjs +15 -14
- package/scripts/setDomainAdmin.cjs +7 -6
- package/scripts/setDomainLocales.js +2 -2
- package/scripts/setEarlQuestionIdOnGroup.cjs +5 -4
- package/scripts/setLanguageOnGroupCommunitesFromUrl.js +3 -3
- package/scripts/setMemberOfAll.js +14 -14
- package/scripts/setNewUserForContentOfCommunity.js +9 -9
- package/scripts/setOfficialStatusOnAllPostsForCommunity.js +1 -1
- package/scripts/setUserOnAll.js +14 -14
- package/scripts/showCategoryForGroup.js +1 -1
- package/scripts/showOldActivityTypes.js +3 -3
- package/scripts/showPostsMissingCategoryForGroup.js +2 -2
- package/scripts/showStatuses.js +4 -4
- package/scripts/showUniqueVotersInCommunity.js +4 -4
- package/scripts/showUserAgentsAndIpsForEmails.js +4 -4
- package/scripts/simpleExportForGroupsForCommunity.js +5 -5
- package/scripts/simpleExportForPointsForCommunity.js +5 -5
- package/scripts/simpleExportForPostsForCommunity.js +5 -5
- package/scripts/testForEndorsments.js +4 -4
- package/scripts/undeleteGroupAndAllContent.js +8 -8
- package/scripts/undeletePost.js +7 -7
- package/scripts/unlinkSsn.js +4 -4
- package/scripts/updateFromAlthingi.js +8 -8
- package/scripts/users/createUserAddDomain.js +6 -5
- package/scripts/users/importUsersForDomainsFromXls.js +4 -3
- package/scripts/users/listDomainUsersWithSsn.js +6 -5
- package/scripts/users/removeUserFromDomain.js +6 -5
- package/scripts/users/updatePasswordFromSsn.js +5 -4
- package/scripts/users/updateUserSsnFromEmail.js +5 -4
- package/services/controllers/activities.cjs +1 -1
- package/services/controllers/news_feeds.cjs +1 -1
- package/services/controllers/notifications.cjs +1 -1
- package/services/controllers/recommendations.cjs +1 -1
- package/services/engine/allOurIdeas/aiHelper.js +10 -9
- package/services/engine/analytics/export_anon_community_activities.js +3 -3
- package/services/engine/analytics/importer.js +10 -10
- package/services/engine/analytics/plausible/manager.cjs +4 -4
- package/services/engine/analytics/statsCalc.cjs +1 -1
- package/services/engine/analytics/utils.cjs +11 -10
- package/services/engine/marketing/campaign.cjs +1 -0
- package/services/engine/moderation/fraud/CreateFraudAuditReport.cjs +2 -1
- package/services/engine/moderation/fraud/FraudBase.cjs +3 -2
- package/services/engine/moderation/fraud/FraudDeleteBase.cjs +5 -4
- package/services/engine/moderation/fraud/FraudGetBase.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetEndorsements.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPointQualities.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPoints.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetPosts.cjs +2 -1
- package/services/engine/moderation/fraud/FraudGetRatings.cjs +2 -1
- package/services/engine/moderation/fraud/FraudScannerNotifier.cjs +10 -9
- package/services/engine/moderation/get_moderation_items.cjs +1 -1
- package/services/engine/moderation/image_labeling/ImageLabelingBase.cjs +1 -1
- package/services/engine/moderation/process_moderation_items.cjs +1 -1
- package/services/engine/moderation/toxicity_analysis.cjs +1 -1
- package/services/engine/news_feeds/generate_dynamically.cjs +1 -1
- package/services/engine/news_feeds/generate_from_notifications.cjs +1 -1
- package/services/engine/notifications/emails_utils.cjs +2 -2
- package/services/engine/notifications/generate_point_notifications.cjs +1 -1
- package/services/engine/notifications/generate_post_notifications.cjs +1 -1
- package/services/engine/notifications/process_delayed_notifications.cjs +38 -38
- package/services/engine/notifications/process_general_notifications.cjs +1 -0
- package/services/engine/old/exporters/categories_dataset.js +11 -11
- package/services/engine/old/exporters/sentiment_dataset.js +12 -12
- package/services/engine/recommendations/events_importer.cjs +5 -5
- package/services/engine/recommendations/events_manager.cjs +1 -1
- package/services/engine/reports/add_points_to_sheet.cjs +3 -2
- package/services/engine/reports/commonUtils.js +3 -2
- package/services/engine/reports/common_utils.cjs +8 -8
- package/services/engine/reports/docx_group_report.cjs +1 -1
- package/services/engine/reports/xlsAllOurIdeasExport.js +16 -15
- package/services/engine/reports/xls_community_users_report.cjs +2 -2
- package/services/engine/reports/xls_group_report.cjs +1 -1
- package/services/llms/baseChatBot.js +12 -11
- package/services/llms/imageGeneration/chatGptImageGenerator.js +3 -2
- package/services/llms/imageGeneration/collectionImageGenerator.js +7 -6
- package/services/llms/imageGeneration/dalleImageGenerator.js +6 -5
- package/services/llms/imageGeneration/fluxImageGenerator.js +5 -4
- package/services/llms/imageGeneration/imageProcessorService.js +2 -1
- package/services/llms/imageGeneration/imagenImageGenerator.js +8 -7
- package/services/llms/imageGeneration/s3Service.js +12 -11
- package/services/llms/llmTranslation.js +30 -29
- package/services/models/ac_activity.cjs +1 -1
- package/services/models/ac_notification.cjs +1 -1
- package/services/models/ac_translation_cache.cjs +11 -11
- package/services/scripts/analytics/setup_all_plausible_goals.cjs +3 -2
- package/services/scripts/fix_old_delayed_notifications.js +3 -3
- package/services/scripts/kue_status.js +11 -11
- package/services/scripts/kue_watch_stuck_jobs.js +6 -6
- package/services/scripts/translation_clear_language.js +21 -21
- package/services/scripts/translation_delete.js +4 -4
- package/services/scripts/translation_replace_text_from_url.js +4 -4
- package/services/scripts/translation_update.js +4 -4
- package/services/scripts/translations_list.js +5 -5
- package/services/utils/airbrake.cjs +2 -1
- package/services/utils/redisConnection.cjs +6 -5
- package/services/utils/translation_helpers.cjs +3 -2
- package/services/utils/updateAllLocalesFromEn.js +20 -19
- package/services/utils/updateLocaleFolders.js +7 -6
- package/services/workers/activity.cjs +1 -1
- package/services/workers/anonymizations.cjs +1 -1
- package/services/workers/bulk_status_update.cjs +2 -2
- package/services/workers/delayed_jobs.cjs +1 -1
- package/services/workers/deletions.cjs +1 -1
- package/services/workers/email.cjs +1 -1
- package/services/workers/fraud_management.cjs +3 -3
- package/services/workers/generativeAi.js +6 -5
- package/services/workers/main.cjs +1 -1
- package/services/workers/marketing.cjs +1 -1
- package/services/workers/moderation.cjs +1 -1
- package/services/workers/notification_delivery.cjs +1 -1
- package/services/workers/notification_news_feed.cjs +1 -1
- package/services/workers/queue.cjs +2 -2
- package/services/workers/recount.cjs +1 -1
- package/services/workers/reports.cjs +1 -1
- package/services/workers/similarities.cjs +4 -2
- package/services/workers/speech_to_text.cjs +1 -1
- package/utils/airbrake.cjs +2 -1
- package/utils/cjsCodeReview.js +7 -6
- package/utils/community_mapping_tools.cjs +3 -2
- package/utils/copy_utils.cjs +32 -31
- package/utils/export_utils.cjs +7 -7
- package/utils/generateDocumentation.js +10 -9
- package/utils/logger.cjs +2 -23
- package/utils/logger.d.cts +1 -1
- package/utils/loggerAirbrakeTransport.cjs +52 -0
- package/utils/loggerAirbrakeTransport.d.cts +15 -0
- package/utils/loggerAirbrakeTransportTs.d.ts +15 -0
- package/utils/loggerAirbrakeTransportTs.js +45 -0
- package/utils/loggerCore.cjs +29 -0
- package/utils/loggerCore.d.cts +2 -0
- package/utils/loggerCoreTs.d.ts +2 -0
- package/utils/loggerCoreTs.js +23 -0
- package/utils/loggerTs.d.ts +1 -2
- package/utils/loggerTs.js +2 -25
- package/utils/manifest_generator.cjs +1 -0
- package/utils/recount_utils.cjs +6 -5
- package/utils/seedModels.js +50 -49
- package/utils/sitemap_generator.cjs +4 -4
- package/utils/ypLanguages.js +2 -2
- package/webSockets.js +8 -7
- package/services/utils/logger.cjs +0 -25
- package/services/utils/logger.d.cts +0 -2
- package/src/agents/assistants/assistant.d.ts +0 -156
- package/src/controllers/audios.d.ts +0 -5
- package/src/controllers/categories.d.ts +0 -5
- package/src/controllers/communities.d.ts +0 -5
- package/src/controllers/domains.d.ts +0 -5
- package/src/controllers/groups.d.ts +0 -5
- package/src/controllers/images.d.ts +0 -5
- package/src/controllers/points.d.ts +0 -5
- package/src/controllers/posts.d.ts +0 -5
- package/src/controllers/ratings.d.ts +0 -5
- package/src/controllers/users.d.ts +0 -5
- package/src/controllers/videos.d.ts +0 -5
- package/src/models/index.d.ts +0 -84
- package/src/services/controllers/activities.d.ts +0 -5
- package/src/services/controllers/notifications.d.ts +0 -5
- package/src/utils/copy_utils.d.ts +0 -4
- package/src/utils/manifest_generator.d.ts +0 -18
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//import models from "../models/index.js";
|
|
2
2
|
import models from "../models/index.cjs";
|
|
3
3
|
import auth from "../authorization.cjs";
|
|
4
|
+
import log from "../utils/loggerTs.js";
|
|
4
5
|
import express from "express";
|
|
5
6
|
import crypto from "crypto";
|
|
6
7
|
const dbModels = models;
|
|
@@ -65,7 +66,7 @@ export class AllOurIdeasController {
|
|
|
65
66
|
});
|
|
66
67
|
const totalGroupCount = await Group.count();
|
|
67
68
|
if (!choiceResponse.ok) {
|
|
68
|
-
|
|
69
|
+
log.error(choiceResponse.statusText);
|
|
69
70
|
throw new Error("Choice creation failed.");
|
|
70
71
|
}
|
|
71
72
|
const stats = (await choiceResponse.json());
|
|
@@ -81,7 +82,7 @@ export class AllOurIdeasController {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
catch (error) {
|
|
84
|
-
|
|
85
|
+
log.error(error);
|
|
85
86
|
res
|
|
86
87
|
.status(500)
|
|
87
88
|
.json({ error: "Failed to fetch total vote and questions count" });
|
|
@@ -101,7 +102,7 @@ export class AllOurIdeasController {
|
|
|
101
102
|
};
|
|
102
103
|
//@ts-ignore
|
|
103
104
|
choiceParams["local_identifier"] = req.user ? req.user.id : req.session.id;
|
|
104
|
-
|
|
105
|
+
log.info(`choiceParams: ${JSON.stringify(choiceParams)}`);
|
|
105
106
|
try {
|
|
106
107
|
const group = (await Group.findOne({
|
|
107
108
|
where: {
|
|
@@ -117,7 +118,7 @@ export class AllOurIdeasController {
|
|
|
117
118
|
body: JSON.stringify(choiceParams),
|
|
118
119
|
});
|
|
119
120
|
if (!choiceResponse.ok) {
|
|
120
|
-
|
|
121
|
+
log.error(choiceResponse.statusText);
|
|
121
122
|
throw new Error("Choice creation failed.");
|
|
122
123
|
}
|
|
123
124
|
const choice = (await choiceResponse.json());
|
|
@@ -128,12 +129,12 @@ export class AllOurIdeasController {
|
|
|
128
129
|
flagged = await this.getModerationFlag(newIdea);
|
|
129
130
|
if (flagged) {
|
|
130
131
|
await this.deactivateChoice(req, choice);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
log.info("----------------------------------");
|
|
133
|
+
log.info(`Flagged BY OPENAI: ${flagged}`);
|
|
134
|
+
log.info("----------------------------------");
|
|
134
135
|
}
|
|
135
136
|
else {
|
|
136
|
-
|
|
137
|
+
log.info(`Not flagged BY OPENAI Moderation API: ${flagged}`);
|
|
137
138
|
if (aoiConfig.earl?.configuration?.moderationPrompt) {
|
|
138
139
|
const aiHelper = new AiHelper();
|
|
139
140
|
const passedModeration = await aiHelper.getModerationResponse(aoiConfig.earl.configuration.moderationPrompt, aoiConfig.earl.question?.name, newIdea);
|
|
@@ -144,7 +145,7 @@ export class AllOurIdeasController {
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
else {
|
|
147
|
-
|
|
148
|
+
log.info(`Adding idea to moderation queue`);
|
|
148
149
|
await this.deactivateChoice(req, choice);
|
|
149
150
|
}
|
|
150
151
|
// Implement email notification logic based on choice's active status
|
|
@@ -162,7 +163,7 @@ export class AllOurIdeasController {
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
catch (error) {
|
|
165
|
-
|
|
166
|
+
log.error(error);
|
|
166
167
|
res.status(500).json({ error: "Addition of new idea failed" });
|
|
167
168
|
}
|
|
168
169
|
}
|
|
@@ -197,7 +198,7 @@ export class AllOurIdeasController {
|
|
|
197
198
|
choice.active = false;
|
|
198
199
|
}
|
|
199
200
|
catch (error) {
|
|
200
|
-
|
|
201
|
+
log.error(error);
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
async getTranslatedText(req, res) {
|
|
@@ -205,7 +206,7 @@ export class AllOurIdeasController {
|
|
|
205
206
|
//@ts-ignore
|
|
206
207
|
models.AcTranslationCache.getTranslation(req, {}, function (error, translation) {
|
|
207
208
|
if (error) {
|
|
208
|
-
|
|
209
|
+
log.error(error);
|
|
209
210
|
res.status(500).send("A getTranslatedText error occurred");
|
|
210
211
|
}
|
|
211
212
|
else {
|
|
@@ -214,13 +215,13 @@ export class AllOurIdeasController {
|
|
|
214
215
|
});
|
|
215
216
|
}
|
|
216
217
|
catch (error) {
|
|
217
|
-
|
|
218
|
+
log.error(error);
|
|
218
219
|
res.status(500).send("A getTranslatedText error occurred");
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
async generateIdeas(req, res) {
|
|
222
223
|
const { currentIdeas, wsClientSocketId, question } = req.body;
|
|
223
|
-
|
|
224
|
+
log.info(`generateIdeas: ${wsClientSocketId}`);
|
|
224
225
|
const swClientSocket = this.wsClients.get(wsClientSocketId);
|
|
225
226
|
if (swClientSocket) {
|
|
226
227
|
const aiHelper = new AiHelper(swClientSocket);
|
|
@@ -243,7 +244,7 @@ export class AllOurIdeasController {
|
|
|
243
244
|
res.send(job);
|
|
244
245
|
})
|
|
245
246
|
.catch((error) => {
|
|
246
|
-
|
|
247
|
+
log.error("Could not get backgroundJob", {
|
|
247
248
|
err: error,
|
|
248
249
|
context: "start_report_creation"
|
|
249
250
|
});
|
|
@@ -253,7 +254,7 @@ export class AllOurIdeasController {
|
|
|
253
254
|
async exportXls(req, res) {
|
|
254
255
|
AcBackgroundJob.createJob({}, {}, (error, jobId) => {
|
|
255
256
|
if (error) {
|
|
256
|
-
|
|
257
|
+
log.error("Could not create backgroundJob", {
|
|
257
258
|
err: error,
|
|
258
259
|
context: "start_report_creation",
|
|
259
260
|
});
|
|
@@ -279,7 +280,7 @@ export class AllOurIdeasController {
|
|
|
279
280
|
}
|
|
280
281
|
async llmAnswerExplain(req, res) {
|
|
281
282
|
const { wsClientId, chatLog, languageName } = req.body;
|
|
282
|
-
|
|
283
|
+
log.info(`explainConversation: ${wsClientId}`);
|
|
283
284
|
const explainer = new ExplainAnswersAssistant(wsClientId, this.wsClients, languageName);
|
|
284
285
|
await explainer.explainConversation(chatLog);
|
|
285
286
|
res.sendStatus(200);
|
|
@@ -311,8 +312,8 @@ export class AllOurIdeasController {
|
|
|
311
312
|
const question = (await questionResponse.json());
|
|
312
313
|
const { picked_prompt_id } = question;
|
|
313
314
|
const question_id = question.id;
|
|
314
|
-
|
|
315
|
-
|
|
315
|
+
log.info(`picked_prompt_id: ${picked_prompt_id}`);
|
|
316
|
+
log.info(`question_id: ${question_id}`);
|
|
316
317
|
const promptResponse = await fetch(`${PAIRWISE_API_HOST}/questions/${question_id}/prompts/${picked_prompt_id}.json`, {
|
|
317
318
|
method: "GET",
|
|
318
319
|
headers: defaultHeader,
|
|
@@ -331,7 +332,7 @@ export class AllOurIdeasController {
|
|
|
331
332
|
}
|
|
332
333
|
}
|
|
333
334
|
catch (error) {
|
|
334
|
-
|
|
335
|
+
log.error(error);
|
|
335
336
|
res.status(500).send("An error occurred");
|
|
336
337
|
}
|
|
337
338
|
}
|
|
@@ -366,7 +367,7 @@ export class AllOurIdeasController {
|
|
|
366
367
|
res.json(result);
|
|
367
368
|
}
|
|
368
369
|
catch (error) {
|
|
369
|
-
|
|
370
|
+
log.error(error);
|
|
370
371
|
res.status(422).send("Vote unsuccessful.");
|
|
371
372
|
}
|
|
372
373
|
}
|
|
@@ -376,7 +377,7 @@ export class AllOurIdeasController {
|
|
|
376
377
|
}
|
|
377
378
|
async createQuestion(req, res) {
|
|
378
379
|
const questionParams = req.body;
|
|
379
|
-
|
|
380
|
+
log.info(`in createQuestion: ${JSON.stringify(questionParams.ideas)}`);
|
|
380
381
|
if (questionParams.ideas.length < 4) {
|
|
381
382
|
res.status(400).json({ error: "Invalid input" });
|
|
382
383
|
return;
|
|
@@ -403,7 +404,7 @@ export class AllOurIdeasController {
|
|
|
403
404
|
res.json({ question_id: question.id });
|
|
404
405
|
}
|
|
405
406
|
catch (error) {
|
|
406
|
-
|
|
407
|
+
log.error(error);
|
|
407
408
|
res
|
|
408
409
|
.status(500)
|
|
409
410
|
.json({ error: "An error occurred during question creation" });
|
|
@@ -423,7 +424,7 @@ export class AllOurIdeasController {
|
|
|
423
424
|
res.status(200).json({ message: "Choice data updated" });
|
|
424
425
|
}
|
|
425
426
|
catch (error) {
|
|
426
|
-
|
|
427
|
+
log.error(error);
|
|
427
428
|
res.status(422).json({ error: "Choice update failed" });
|
|
428
429
|
}
|
|
429
430
|
}
|
|
@@ -441,7 +442,7 @@ export class AllOurIdeasController {
|
|
|
441
442
|
res.status(200).json({ message: "Choice active updated" });
|
|
442
443
|
}
|
|
443
444
|
catch (error) {
|
|
444
|
-
|
|
445
|
+
log.error(error);
|
|
445
446
|
res.status(422).json({ error: "Choice active failed" });
|
|
446
447
|
}
|
|
447
448
|
}
|
|
@@ -459,7 +460,7 @@ export class AllOurIdeasController {
|
|
|
459
460
|
res.status(200).json({ message: "Question name updated" });
|
|
460
461
|
}
|
|
461
462
|
catch (error) {
|
|
462
|
-
|
|
463
|
+
log.error(error);
|
|
463
464
|
res.status(422).json({ error: "Question update name failed" });
|
|
464
465
|
}
|
|
465
466
|
}
|
|
@@ -493,13 +494,13 @@ export class AllOurIdeasController {
|
|
|
493
494
|
res.json(result);
|
|
494
495
|
}
|
|
495
496
|
catch (error) {
|
|
496
|
-
|
|
497
|
+
log.error(error);
|
|
497
498
|
res.status(422).json({ error: "Skip failed" });
|
|
498
499
|
}
|
|
499
500
|
}
|
|
500
501
|
async analysis(req, res) {
|
|
501
502
|
const { groupId, wsClientSocketId, analysisIndex, analysisTypeIndex } = req.params;
|
|
502
|
-
|
|
503
|
+
log.info(`--------------------> ${groupId} ${analysisIndex} ${analysisTypeIndex}`);
|
|
503
504
|
try {
|
|
504
505
|
const group = await Group.findOne({ where: { id: groupId } });
|
|
505
506
|
if (!group) {
|
|
@@ -527,20 +528,20 @@ export class AllOurIdeasController {
|
|
|
527
528
|
}
|
|
528
529
|
const question = (await questionResponse.json());
|
|
529
530
|
// Additional logic adapted from Ruby for fetching and sorting choices
|
|
530
|
-
|
|
531
|
+
log.info(`@question is ${question}. ${group.configuration.allOurIdeas.earl.configuration.analysis_config}`);
|
|
531
532
|
const analysisConfig = group.configuration.allOurIdeas.earl.configuration.analysis_config;
|
|
532
|
-
|
|
533
|
+
log.info(`@analysisConfig is ${analysisConfig}.`);
|
|
533
534
|
const analysisIdeaConfig = analysisConfig.analyses[parseInt(analysisIndex)];
|
|
534
|
-
|
|
535
|
+
log.info(`@analysisIdeaConfig is ${analysisIdeaConfig}.`);
|
|
535
536
|
const ideasIdsRange = analysisIdeaConfig.ideasIdsRange;
|
|
536
|
-
|
|
537
|
+
log.info(`@ideasIdsRange is ${ideasIdsRange}.`);
|
|
537
538
|
const analysisType = analysisIdeaConfig.analysisTypes[parseInt(analysisTypeIndex, 10)];
|
|
538
|
-
|
|
539
|
+
log.info(`Analysis Type: ${analysisType}`);
|
|
539
540
|
const perPage = Math.abs(ideasIdsRange);
|
|
540
|
-
|
|
541
|
+
log.info(`Per page: ${perPage}`);
|
|
541
542
|
const totalActiveChoices = question.choices_count - question.inactive_choices_count;
|
|
542
543
|
const offset = ideasIdsRange < 0 ? Math.max(totalActiveChoices - perPage, 0) : 0;
|
|
543
|
-
|
|
544
|
+
log.info(`Offset: ${offset}`);
|
|
544
545
|
const choicesResponse = await fetch(`${PAIRWISE_API_HOST}/questions/${questionId}/choices.json?all=1&show_all=true&limit=${perPage}&offset=${offset}`, {
|
|
545
546
|
headers: defaultAuthHeader,
|
|
546
547
|
});
|
|
@@ -554,12 +555,12 @@ export class AllOurIdeasController {
|
|
|
554
555
|
content: choice.data,
|
|
555
556
|
choiceId: choice.id,
|
|
556
557
|
};
|
|
557
|
-
|
|
558
|
+
log.warn(error);
|
|
558
559
|
}
|
|
559
560
|
}
|
|
560
|
-
|
|
561
|
+
log.info(`Number of choices fetched: ${choices.length}`);
|
|
561
562
|
const sortedChoices = choices.sort((a, b) => a.id - b.id);
|
|
562
|
-
|
|
563
|
+
log.info(`Sorted choice IDs: ${sortedChoices.map((choice) => choice.id)}`);
|
|
563
564
|
const choiceIds = sortedChoices.map((choice) => `${choice.id}`).join("-");
|
|
564
565
|
const promptHash = crypto
|
|
565
566
|
.createHash("sha256")
|
|
@@ -568,7 +569,7 @@ export class AllOurIdeasController {
|
|
|
568
569
|
.substring(0, 8);
|
|
569
570
|
const usedLanguageName = req.query.languageName || "English";
|
|
570
571
|
const analysisCacheKey = `${questionId}_${analysisTypeIndex}_${choiceIds}_${usedLanguageName}_${promptHash}_ai_analysis_v14`;
|
|
571
|
-
|
|
572
|
+
log.info(`analysisCacheKey is ${analysisCacheKey} prompt ${analysisType.contextPrompt.substring(0, 15)}...`);
|
|
572
573
|
// Implement caching logic here
|
|
573
574
|
let cachedAnalysis = await req.redisClient.get(analysisCacheKey);
|
|
574
575
|
if (!cachedAnalysis) {
|
|
@@ -585,7 +586,7 @@ export class AllOurIdeasController {
|
|
|
585
586
|
});
|
|
586
587
|
}
|
|
587
588
|
catch (error) {
|
|
588
|
-
|
|
589
|
+
log.error(error);
|
|
589
590
|
res
|
|
590
591
|
.status(500)
|
|
591
592
|
.send("An error occurred while processing the analysis request");
|
|
@@ -624,13 +625,13 @@ export class AllOurIdeasController {
|
|
|
624
625
|
content: choice.data,
|
|
625
626
|
choiceId: choice.id,
|
|
626
627
|
};
|
|
627
|
-
|
|
628
|
+
log.error(error);
|
|
628
629
|
}
|
|
629
630
|
}
|
|
630
631
|
res.json(choices);
|
|
631
632
|
}
|
|
632
633
|
catch (error) {
|
|
633
|
-
|
|
634
|
+
log.error(error);
|
|
634
635
|
res.status(500).send("An error occurred");
|
|
635
636
|
}
|
|
636
637
|
}
|
|
@@ -653,7 +654,7 @@ export class AllOurIdeasController {
|
|
|
653
654
|
const session = req.session; // Assuming express-session middleware is used
|
|
654
655
|
const params = req.query;
|
|
655
656
|
const body = req.body; // Assuming body-parser middleware is used for JSON body parsing
|
|
656
|
-
|
|
657
|
+
log.info(`getVoteRequestOptions: ${JSON.stringify(params)} s: ${session}`);
|
|
657
658
|
const options = {
|
|
658
659
|
visitor_identifier: req.user
|
|
659
660
|
? req.user.id
|
|
@@ -680,7 +681,7 @@ export class AllOurIdeasController {
|
|
|
680
681
|
utm_referrer: params.utm_referrer,
|
|
681
682
|
};
|
|
682
683
|
options.tracking = trackingData;
|
|
683
|
-
|
|
684
|
+
log.info(`---------------------- ${JSON.stringify(trackingData)}`);
|
|
684
685
|
switch (requestType) {
|
|
685
686
|
case "vote":
|
|
686
687
|
options.direction = body.direction;
|
package/controllers/groups.cjs
CHANGED
|
@@ -2153,7 +2153,7 @@ const copyThemeAndLogoFromAgentFabricGroup = async (newGroup, agentFabricGroup)
|
|
|
2153
2153
|
}
|
|
2154
2154
|
};
|
|
2155
2155
|
const createGroup = async (req, res) => {
|
|
2156
|
-
|
|
2156
|
+
log.info("Creating group with community id: " + req.params.communityId);
|
|
2157
2157
|
if (!req.user) {
|
|
2158
2158
|
try {
|
|
2159
2159
|
await addAgentFabricUserToSessionIfNeeded(req);
|
|
@@ -2945,7 +2945,6 @@ var getPostsWithAllFromIds = function (postsWithIds, postOrder, done) {
|
|
|
2945
2945
|
},
|
|
2946
2946
|
(parallelCallback) => {
|
|
2947
2947
|
models.Post.getVideosForPosts(collectedIds, (error, videosIn) => {
|
|
2948
|
-
log.info("GOT VIDEOS 1");
|
|
2949
2948
|
if (error) {
|
|
2950
2949
|
parallelCallback(error);
|
|
2951
2950
|
}
|
|
@@ -3062,7 +3061,7 @@ router.get("/:id/posts/:filter/:categoryId{/:status}", auth.can("view group"), f
|
|
|
3062
3061
|
if (req.params.categoryId != "null") {
|
|
3063
3062
|
where["category_id"] = req.params.categoryId;
|
|
3064
3063
|
}
|
|
3065
|
-
log.
|
|
3064
|
+
log.debug("Posts", {
|
|
3066
3065
|
gId: req.params.id,
|
|
3067
3066
|
f: req.params.filter,
|
|
3068
3067
|
cId: req.params.categoryId,
|
|
@@ -3080,7 +3079,6 @@ router.get("/:id/posts/:filter/:categoryId{/:status}", auth.can("view group"), f
|
|
|
3080
3079
|
offset: offset,
|
|
3081
3080
|
})
|
|
3082
3081
|
.then(function (postResults) {
|
|
3083
|
-
log.info("Posts 2");
|
|
3084
3082
|
const posts = postResults.rows;
|
|
3085
3083
|
var totalPostsCount = postResults.count;
|
|
3086
3084
|
var postRows = posts;
|
|
@@ -3122,9 +3120,7 @@ router.get("/:id/posts/:filter/:categoryId{/:status}", auth.can("view group"), f
|
|
|
3122
3120
|
}
|
|
3123
3121
|
totalPostsCount = postResults.rows.length;
|
|
3124
3122
|
}
|
|
3125
|
-
log.info("Posts 3");
|
|
3126
3123
|
getPostsWithAllFromIds(postRows, postOrder, function (error, finalRows) {
|
|
3127
|
-
log.info("Posts 4");
|
|
3128
3124
|
if (error) {
|
|
3129
3125
|
log.error("Error getting group", { err: error });
|
|
3130
3126
|
res.sendStatus(500);
|
|
@@ -3144,7 +3140,6 @@ router.get("/:id/posts/:filter/:categoryId{/:status}", auth.can("view group"), f
|
|
|
3144
3140
|
], ["desc"]);
|
|
3145
3141
|
}
|
|
3146
3142
|
models.Post.setOrganizationUsersForPosts(finalRows, (error) => {
|
|
3147
|
-
log.info("Posts 2");
|
|
3148
3143
|
if (error) {
|
|
3149
3144
|
log.error("Error getting group", {
|
|
3150
3145
|
err: error,
|
|
@@ -3403,7 +3398,7 @@ router.put("/:id/:groupId/mergeWithGroup", auth.can("edit post"), function (req,
|
|
|
3403
3398
|
async.eachSeries(posts, function (post, seriesCallback) {
|
|
3404
3399
|
post.set("group_id", outGroup.id);
|
|
3405
3400
|
post.save().then(function (results) {
|
|
3406
|
-
|
|
3401
|
+
log.info("Have changed group id");
|
|
3407
3402
|
models.AcActivity.findAll({
|
|
3408
3403
|
where: {
|
|
3409
3404
|
post_id: post.id,
|
|
@@ -3415,7 +3410,7 @@ router.put("/:id/:groupId/mergeWithGroup", auth.can("edit post"), function (req,
|
|
|
3415
3410
|
activity.set("community_id", outCommunityId);
|
|
3416
3411
|
activity.set("domain_id", outDomainId);
|
|
3417
3412
|
activity.save().then(function (results) {
|
|
3418
|
-
|
|
3413
|
+
log.info("Have changed group and all: " +
|
|
3419
3414
|
activity.id);
|
|
3420
3415
|
innerSeriesCallback();
|
|
3421
3416
|
});
|
package/controllers/images.cjs
CHANGED
|
@@ -236,8 +236,8 @@ router.post("/", isAuthenticated, async function (req, res) {
|
|
|
236
236
|
// 1) Check if the file name ends with ".gif"
|
|
237
237
|
const isGifFilename = (filename) => {
|
|
238
238
|
const lowerCaseFilename = filename.toLowerCase();
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
log.info("filename===========>", filename);
|
|
240
|
+
log.info("lowerCaseFilename===========>", lowerCaseFilename);
|
|
241
241
|
return lowerCaseFilename.endsWith(".gif");
|
|
242
242
|
};
|
|
243
243
|
// 2) Create the storage with a Key callback that uses 'isGifFilename'
|
|
@@ -247,9 +247,9 @@ router.post("/", isAuthenticated, async function (req, res) {
|
|
|
247
247
|
if (err)
|
|
248
248
|
return cb(err);
|
|
249
249
|
const rawHex = raw.toString("hex");
|
|
250
|
-
|
|
250
|
+
log.info("file.originalname", file.originalname);
|
|
251
251
|
const isGif = isGifFilename(file.originalname);
|
|
252
|
-
|
|
252
|
+
log.info("gif===========>", isGif);
|
|
253
253
|
file.outputFormat = isGif ? "gif" : "png";
|
|
254
254
|
cb(null, `${rawHex}.${isGif ? "gif" : "png"}`);
|
|
255
255
|
});
|
|
@@ -273,7 +273,7 @@ router.post("/", isAuthenticated, async function (req, res) {
|
|
|
273
273
|
];
|
|
274
274
|
// 4) A fileFilter to reject non-image or invalid Sharp formats
|
|
275
275
|
const fileFilter = (req, file, cb) => {
|
|
276
|
-
|
|
276
|
+
log.info("file------------>", file);
|
|
277
277
|
// Check that it's an image and specifically in our allowed list
|
|
278
278
|
if (!allowedMimeTypes.includes(file.mimetype.toLowerCase())) {
|
|
279
279
|
return cb(new Error(`Unsupported file type: ${file.mimetype}. Allowed: ${allowedMimeTypes.join(", ")}`));
|
|
@@ -293,7 +293,7 @@ router.post("/", isAuthenticated, async function (req, res) {
|
|
|
293
293
|
upload.single("file")(req, res, async function (error) {
|
|
294
294
|
if (error) {
|
|
295
295
|
// Multer will throw if file is too large or invalid
|
|
296
|
-
|
|
296
|
+
log.error("File upload error:", error);
|
|
297
297
|
return res.status(400).json({ error: error.message });
|
|
298
298
|
}
|
|
299
299
|
// Continue if there's a valid image file
|
|
@@ -316,13 +316,13 @@ router.post("/", isAuthenticated, async function (req, res) {
|
|
|
316
316
|
return res.send(image);
|
|
317
317
|
}
|
|
318
318
|
catch (err) {
|
|
319
|
-
|
|
319
|
+
log.error("Error saving image record:", err);
|
|
320
320
|
return res.status(500).json({ error: "Failed to save image record" });
|
|
321
321
|
}
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
catch (err) {
|
|
325
|
-
|
|
325
|
+
log.error("Unexpected error:", err);
|
|
326
326
|
// If req.file exists, use its data; otherwise fallback
|
|
327
327
|
const fileName = req.file ? req.file.originalname : "unknown filename";
|
|
328
328
|
return res.status(500).json({
|
package/controllers/index.cjs
CHANGED
|
@@ -374,7 +374,7 @@ async function cacheIndexFile(filePath, versionKey) {
|
|
|
374
374
|
indexCache[versionKey].data = data;
|
|
375
375
|
}
|
|
376
376
|
catch (err) {
|
|
377
|
-
|
|
377
|
+
log.error("Error caching index file:", err);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
let sendIndex = async (req, res) => {
|
package/controllers/points.cjs
CHANGED
|
@@ -1092,7 +1092,7 @@ router.delete("/:id/pointQuality", auth.can("vote on point"), function (req, res
|
|
|
1092
1092
|
});
|
|
1093
1093
|
}
|
|
1094
1094
|
else {
|
|
1095
|
-
|
|
1095
|
+
log.error("Strange state of pointQualities");
|
|
1096
1096
|
res.status(200).send({
|
|
1097
1097
|
pointQuality: pointQuality,
|
|
1098
1098
|
oldPointQualityValue: oldPointQualityValue,
|
package/controllers/posts.cjs
CHANGED
|
@@ -1439,7 +1439,7 @@ router.put("/:id/:groupId/move", auth.can("edit post"), function (req, res) {
|
|
|
1439
1439
|
post = postIn;
|
|
1440
1440
|
post.set("group_id", group.id);
|
|
1441
1441
|
post.save().then(function (results) {
|
|
1442
|
-
|
|
1442
|
+
log.info("Have changed group id");
|
|
1443
1443
|
callback();
|
|
1444
1444
|
});
|
|
1445
1445
|
})
|
|
@@ -1459,7 +1459,7 @@ router.put("/:id/:groupId/move", auth.can("edit post"), function (req, res) {
|
|
|
1459
1459
|
point.set("community_id", communityId);
|
|
1460
1460
|
point.set("domain_id", domainId);
|
|
1461
1461
|
point.save().then(function () {
|
|
1462
|
-
|
|
1462
|
+
log.info("Have changed group and all for point: " + point.id);
|
|
1463
1463
|
innerSeriesCallback();
|
|
1464
1464
|
});
|
|
1465
1465
|
}, function (error) {
|
|
@@ -1479,7 +1479,7 @@ router.put("/:id/:groupId/move", auth.can("edit post"), function (req, res) {
|
|
|
1479
1479
|
activity.set("community_id", communityId);
|
|
1480
1480
|
activity.set("domain_id", domainId);
|
|
1481
1481
|
activity.save().then(function (results) {
|
|
1482
|
-
|
|
1482
|
+
log.info("Have changed group and all: " + activity.id);
|
|
1483
1483
|
innerSeriesCallback();
|
|
1484
1484
|
});
|
|
1485
1485
|
}, function (error) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const log = require('./utils/logger.cjs');
|
|
4
5
|
const tsOutDir = './ts-out';
|
|
5
6
|
const keepDeclarations = new Set([
|
|
6
7
|
"app.d.ts",
|
|
@@ -30,23 +31,23 @@ function deleteDtsFiles(dir) {
|
|
|
30
31
|
// Delete the file if it ends with .d.ts and not in the keep list
|
|
31
32
|
if (file.endsWith('.d.ts') && !keepDeclarations.has(relativePath)) {
|
|
32
33
|
fs.unlinkSync(filePath);
|
|
33
|
-
|
|
34
|
+
log.info(`Deleted: ${filePath}`);
|
|
34
35
|
}
|
|
35
36
|
if (file.endsWith('.d.cts') && !keepDeclarations.has(relativePath)) {
|
|
36
37
|
fs.unlinkSync(filePath);
|
|
37
|
-
|
|
38
|
+
log.info(`Deleted: ${filePath}`);
|
|
38
39
|
}
|
|
39
40
|
if (file.endsWith('.js.map') && !keepDeclarations.has(relativePath)) {
|
|
40
41
|
fs.unlinkSync(filePath);
|
|
41
|
-
|
|
42
|
+
log.info(`Deleted: ${filePath}`);
|
|
42
43
|
}
|
|
43
44
|
if (file.endsWith('.cjs.map') && !keepDeclarations.has(relativePath)) {
|
|
44
45
|
fs.unlinkSync(filePath);
|
|
45
|
-
|
|
46
|
+
log.info(`Deleted: ${filePath}`);
|
|
46
47
|
}
|
|
47
48
|
if (file.endsWith('.cts.map') && !keepDeclarations.has(relativePath)) {
|
|
48
49
|
fs.unlinkSync(filePath);
|
|
49
|
-
|
|
50
|
+
log.info(`Deleted: ${filePath}`);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
});
|
package/models/community.cjs
CHANGED
|
@@ -206,7 +206,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
206
206
|
community.dataValues.CommunityLogoVideos = _.orderBy(videos, ['created_at'], ['desc']);
|
|
207
207
|
done();
|
|
208
208
|
}).catch(error => {
|
|
209
|
-
|
|
209
|
+
log.info("addVideosToCommunity: " + error.stack);
|
|
210
210
|
done(error);
|
|
211
211
|
});
|
|
212
212
|
};
|
package/models/domain.cjs
CHANGED
|
@@ -121,7 +121,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
121
121
|
];
|
|
122
122
|
Domain.getLoginProviders = (req, domainIn, callback) => {
|
|
123
123
|
const providers = [];
|
|
124
|
-
|
|
124
|
+
log.info(`-------------------> getLoginProviders Checking local keys for domain ${domainIn.id}`);
|
|
125
125
|
providers.push({
|
|
126
126
|
name: "local-strategy",
|
|
127
127
|
provider: "local",
|
|
@@ -135,7 +135,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
135
135
|
urlCallback: "http://localhost/callback/users/auth/local-strategy-1/callback",
|
|
136
136
|
});
|
|
137
137
|
async.eachSeries([domainIn], (domain, seriesCallback) => {
|
|
138
|
-
|
|
138
|
+
log.info(`================> Processing domain ${domain.id} ${process.env.STAGING_SETUP ? "staging" : "production"}`);
|
|
139
139
|
let callbackDomainName;
|
|
140
140
|
if (process.env.STAGING_SETUP) {
|
|
141
141
|
if (domain.domain_name === "betrireykjavik.is") {
|
|
@@ -178,7 +178,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
178
178
|
callbackDomainName = "socialcare." + domain.domain_name;
|
|
179
179
|
}
|
|
180
180
|
else if (process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME) {
|
|
181
|
-
|
|
181
|
+
log.info("Using custom login back name", {
|
|
182
182
|
custom: process.env.LOGIN_CALLBACK_CUSTOM_HOSTNAME,
|
|
183
183
|
});
|
|
184
184
|
callbackDomainName =
|
|
@@ -198,7 +198,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
log.info(`Checking facebook keys for domain ${domain.id}`);
|
|
202
202
|
if (domain.secret_api_keys &&
|
|
203
203
|
domain.secret_api_keys.facebook &&
|
|
204
204
|
checkValidKeys(domain.secret_api_keys.facebook)) {
|
|
@@ -218,13 +218,13 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
218
218
|
"/api/users/auth/facebook/callback",
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
//
|
|
221
|
+
log.info(`Checking oidc keys for domain ${domain.id}`);
|
|
222
|
+
//log.info(JSON.stringify(domain.secret_api_keys, null, 2));
|
|
223
223
|
//callbackDomainName = "betrireykjavik.is";
|
|
224
224
|
if (domain.secret_api_keys &&
|
|
225
225
|
domain.secret_api_keys.oidc &&
|
|
226
226
|
checkValidKeys(domain.secret_api_keys.oidc)) {
|
|
227
|
-
|
|
227
|
+
log.info(`---------------------> OIDC keys found for domain ${domain.id}`);
|
|
228
228
|
providers.push({
|
|
229
229
|
name: "oidc-strategy-" + domain.id,
|
|
230
230
|
provider: "oidc",
|
package/models/image.cjs
CHANGED
|
@@ -295,13 +295,13 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
295
295
|
try {
|
|
296
296
|
const mediaManager = new CollectionImageGenerator();
|
|
297
297
|
await mediaManager.deleteMediaFormatsUrls(image.formats ? JSON.parse(image.formats) : []);
|
|
298
|
-
|
|
298
|
+
log.info("Deleted image", { imageId: image.id });
|
|
299
299
|
res
|
|
300
300
|
.status(200)
|
|
301
301
|
.json({ message: "Image removed from collection" });
|
|
302
302
|
}
|
|
303
303
|
catch (error) {
|
|
304
|
-
|
|
304
|
+
log.error("Could not delete image", { error });
|
|
305
305
|
res.sendStatus(500);
|
|
306
306
|
}
|
|
307
307
|
});
|
package/models/index.cjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const logger_cjs_1 = __importDefault(require("../utils/logger.cjs"));
|
|
2
6
|
const fs = require("fs");
|
|
3
7
|
const path = require("path");
|
|
4
8
|
const env = process.env.NODE_ENV || "development";
|
|
@@ -60,7 +64,7 @@ else {
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
catch (error) {
|
|
63
|
-
|
|
67
|
+
logger_cjs_1.default.error("Error configuring Sequelize:", error);
|
|
64
68
|
process.exit(1);
|
|
65
69
|
}
|
|
66
70
|
}
|
|
@@ -72,15 +76,15 @@ async function createCompoundIndexes(indexCommands) {
|
|
|
72
76
|
for (const command of indexCommands) {
|
|
73
77
|
try {
|
|
74
78
|
await sequelize.query(command);
|
|
75
|
-
|
|
79
|
+
logger_cjs_1.default.info(`Successfully created index with command: ${command}`);
|
|
76
80
|
}
|
|
77
81
|
catch (error) {
|
|
78
82
|
if (error.message.includes("already exists")) {
|
|
79
83
|
/* ignore duplicate index */
|
|
80
84
|
}
|
|
81
85
|
else {
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
logger_cjs_1.default.error(`Error creating index with command: ${command}`);
|
|
87
|
+
logger_cjs_1.default.error(error.message);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
}
|