@yrpri/api 9.0.139 → 9.0.140
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 +45 -44
- 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 +5 -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 +11 -11
- package/scripts/bulkStatusUpdates/performUpdateForStatus.js +15 -15
- package/scripts/change/changeVideoAspectTo.js +3 -3
- package/scripts/change/setUseNewVersion.cjs +4 -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 +7 -7
- package/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +8 -8
- package/scripts/cleanups/deleteYearOldNotifications.cjs +5 -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 +9 -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 +14 -14
- package/scripts/setDomainAdmin.cjs +6 -6
- package/scripts/setDomainLocales.js +2 -2
- package/scripts/setEarlQuestionIdOnGroup.cjs +4 -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 +10 -10
- package/services/engine/moderation/fraud/CreateFraudAuditReport.cjs +2 -1
- package/services/engine/moderation/fraud/FraudBase.cjs +2 -2
- package/services/engine/moderation/fraud/FraudDeleteBase.cjs +4 -4
- package/services/engine/moderation/fraud/FraudGetBase.cjs +1 -1
- package/services/engine/moderation/fraud/FraudGetEndorsements.cjs +1 -1
- package/services/engine/moderation/fraud/FraudGetPointQualities.cjs +1 -1
- package/services/engine/moderation/fraud/FraudGetPoints.cjs +1 -1
- package/services/engine/moderation/fraud/FraudGetPosts.cjs +1 -1
- package/services/engine/moderation/fraud/FraudGetRatings.cjs +1 -1
- package/services/engine/moderation/fraud/FraudScannerNotifier.cjs +9 -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/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 +2 -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 +2 -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 +1 -1
- package/utils/cjsCodeReview.js +7 -6
- package/utils/community_mapping_tools.cjs +2 -2
- package/utils/copy_utils.cjs +31 -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/recount_utils.cjs +5 -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,4 +1,5 @@
|
|
|
1
1
|
import { OpenAI } from "openai";
|
|
2
|
+
import log from "../../../utils/loggerTs.js";
|
|
2
3
|
export class AiHelper {
|
|
3
4
|
constructor(wsClientSocket = undefined) {
|
|
4
5
|
this.modelName = "gpt-4o";
|
|
@@ -26,7 +27,7 @@ Only output: PASSES or FAILS`;
|
|
|
26
27
|
content: this.moderationUserPrompt(question, answerToModerate),
|
|
27
28
|
},
|
|
28
29
|
];
|
|
29
|
-
|
|
30
|
+
log.info(JSON.stringify(messages, null, 2));
|
|
30
31
|
const response = await this.openaiClient.chat.completions.create({
|
|
31
32
|
model: this.modelName,
|
|
32
33
|
messages,
|
|
@@ -38,7 +39,7 @@ Only output: PASSES or FAILS`;
|
|
|
38
39
|
response.choices[0] &&
|
|
39
40
|
response.choices[0].message &&
|
|
40
41
|
response.choices[0].message.content) {
|
|
41
|
-
|
|
42
|
+
log.info("Moderation response:", response.choices[0].message.content);
|
|
42
43
|
return ["PASSES", "PASS"].includes(response.choices[0].message.content.toUpperCase())
|
|
43
44
|
? true
|
|
44
45
|
: false;
|
|
@@ -83,7 +84,7 @@ Only output: PASSES or FAILS`;
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
catch (error) {
|
|
86
|
-
|
|
87
|
+
log.error(error);
|
|
87
88
|
this.sendToClient("bot", "There has been an error, please retry", "error");
|
|
88
89
|
reject();
|
|
89
90
|
}
|
|
@@ -98,11 +99,11 @@ Only output: PASSES or FAILS`;
|
|
|
98
99
|
const moderationResponse = await this.openaiClient.moderations.create({
|
|
99
100
|
input: question,
|
|
100
101
|
});
|
|
101
|
-
|
|
102
|
+
log.info("Moderation response:", moderationResponse);
|
|
102
103
|
const flagged = moderationResponse.results[0].flagged;
|
|
103
|
-
|
|
104
|
+
log.info("Flagged:", flagged);
|
|
104
105
|
if (flagged) {
|
|
105
|
-
|
|
106
|
+
log.error("Flagged:", question);
|
|
106
107
|
return null;
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
@@ -135,7 +136,7 @@ Only output: PASSES or FAILS`;
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
catch (error) {
|
|
138
|
-
|
|
139
|
+
log.error("Error in getAnswerIdeas:", error);
|
|
139
140
|
this.sendToClient("bot", "There has been an error, please retry", "error");
|
|
140
141
|
return null;
|
|
141
142
|
}
|
|
@@ -175,7 +176,7 @@ Only output: PASSES or FAILS`;
|
|
|
175
176
|
});
|
|
176
177
|
const flagged = moderationResponse.results[0].flagged;
|
|
177
178
|
if (flagged) {
|
|
178
|
-
|
|
179
|
+
log.error("Flagged:", answersText);
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
181
182
|
else {
|
|
@@ -197,7 +198,7 @@ Only output: PASSES or FAILS`;
|
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
catch (error) {
|
|
200
|
-
|
|
201
|
+
log.error("Error in getAiAnalysis:", error);
|
|
201
202
|
this.sendToClient("bot", "There has been an error, please retry", "error");
|
|
202
203
|
}
|
|
203
204
|
}
|
|
@@ -7,14 +7,14 @@ const fs = require('fs');
|
|
|
7
7
|
//const request = require('request');
|
|
8
8
|
const request = {
|
|
9
9
|
post: (data, done) => {
|
|
10
|
-
|
|
10
|
+
log.info(JSON.stringify(data, null, 4));
|
|
11
11
|
done();
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
const clean = (text) => {
|
|
15
|
-
//
|
|
15
|
+
//log.info("Before: "+ text);
|
|
16
16
|
var newText = text.replace('"', "'").replace('\n', '').replace('\r', '').replace(/(\r\n|\n|\r)/gm, "").replace(/"/gm, "'").replace(/,/, ';').trim();
|
|
17
|
-
//
|
|
17
|
+
//log.info("After:" + newText);
|
|
18
18
|
return newText.replace(/´/g, '');
|
|
19
19
|
};
|
|
20
20
|
const getEncryptedId = (id, key, iv) => {
|
|
@@ -31,7 +31,7 @@ const importAllDomains = (done) => {
|
|
|
31
31
|
async.eachOfLimit(domains, updateAsyncLimit, (domain, index, callback) => {
|
|
32
32
|
importDomain(domain, callback);
|
|
33
33
|
}, () => {
|
|
34
|
-
|
|
34
|
+
log.info("Finished updating domains");
|
|
35
35
|
done();
|
|
36
36
|
});
|
|
37
37
|
}).catch(function (error) {
|
|
@@ -57,7 +57,7 @@ const importAllCommunities = (done) => {
|
|
|
57
57
|
async.eachOfLimit(communities, updateAsyncLimit, (community, index, callback) => {
|
|
58
58
|
importCommunity(community, callback);
|
|
59
59
|
}, () => {
|
|
60
|
-
|
|
60
|
+
log.info("Finished updating communities");
|
|
61
61
|
done();
|
|
62
62
|
});
|
|
63
63
|
}).catch(function (error) {
|
|
@@ -90,7 +90,7 @@ const importAllGroups = (done) => {
|
|
|
90
90
|
async.eachOfLimit(groups, updateAsyncLimit, (group, index, callback) => {
|
|
91
91
|
importGroup(group, callback);
|
|
92
92
|
}, () => {
|
|
93
|
-
|
|
93
|
+
log.info("Finished updating communities");
|
|
94
94
|
done();
|
|
95
95
|
});
|
|
96
96
|
}).catch(function (error) {
|
|
@@ -177,7 +177,7 @@ const importAllPosts = (done) => {
|
|
|
177
177
|
async.eachOfLimit(posts, updateAsyncLimit, (post, index, callback) => {
|
|
178
178
|
importPost(post, callback);
|
|
179
179
|
}, () => {
|
|
180
|
-
|
|
180
|
+
log.info("Finished updating posts");
|
|
181
181
|
done();
|
|
182
182
|
});
|
|
183
183
|
}).catch(function (error) {
|
|
@@ -244,7 +244,7 @@ const importAllPoints = (done) => {
|
|
|
244
244
|
async.eachOfLimit(points, updateAsyncLimit, (point, index, callback) => {
|
|
245
245
|
importPoint(point, callback);
|
|
246
246
|
}, () => {
|
|
247
|
-
|
|
247
|
+
log.info("Finished updating posts");
|
|
248
248
|
done();
|
|
249
249
|
});
|
|
250
250
|
}).catch(function (error) {
|
|
@@ -279,9 +279,9 @@ const importAll = (done) => {
|
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
], (error) => {
|
|
282
|
-
|
|
282
|
+
log.info("Finished importing all");
|
|
283
283
|
if (error)
|
|
284
|
-
|
|
284
|
+
log.error(error);
|
|
285
285
|
done();
|
|
286
286
|
});
|
|
287
287
|
};
|
|
@@ -290,19 +290,19 @@ if (process.env["AC_ANALYTICS_KEY"] && process.env["AC_ANALYTICS_BASE_URL"]) {
|
|
|
290
290
|
if (process.argv[2] && process.argv[2] === "onlyUpdatePosts") {
|
|
291
291
|
updateAsyncLimit = 5;
|
|
292
292
|
importAllPosts(() => {
|
|
293
|
-
|
|
293
|
+
log.info("Done updating posts");
|
|
294
294
|
process.exit();
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
297
|
else {
|
|
298
298
|
importAll(() => {
|
|
299
|
-
|
|
299
|
+
log.info("Done importing all");
|
|
300
300
|
process.exit();
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
else {
|
|
305
|
-
|
|
305
|
+
log.error("NO AC_ANALYTICS_KEY");
|
|
306
306
|
process.exit();
|
|
307
307
|
}
|
|
308
308
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const models = require("../../../../models/index.cjs");
|
|
3
|
-
const log = require("
|
|
3
|
+
const log = require("../../../../utils/logger.cjs");
|
|
4
4
|
const request = require("request");
|
|
5
5
|
const moment = require("moment");
|
|
6
6
|
// This SQL is needed to allow the site API
|
|
@@ -255,7 +255,7 @@ async function getPlausibleStats(statsParams) {
|
|
|
255
255
|
reject(content.statusCode);
|
|
256
256
|
}
|
|
257
257
|
else if (content) {
|
|
258
|
-
|
|
258
|
+
log.info(content.body);
|
|
259
259
|
resolve(content.body);
|
|
260
260
|
}
|
|
261
261
|
else {
|
|
@@ -294,7 +294,7 @@ async function addPlausibleGoal(eventName) {
|
|
|
294
294
|
},
|
|
295
295
|
method: "PUT",
|
|
296
296
|
};
|
|
297
|
-
|
|
297
|
+
log.info(`${JSON.stringify(options)}`);
|
|
298
298
|
request(options, (error, content) => {
|
|
299
299
|
if (content && content.statusCode != 200) {
|
|
300
300
|
log.error(error);
|
|
@@ -302,7 +302,7 @@ async function addPlausibleGoal(eventName) {
|
|
|
302
302
|
reject(content.statusCode);
|
|
303
303
|
}
|
|
304
304
|
else if (content) {
|
|
305
|
-
|
|
305
|
+
log.info(content.body);
|
|
306
306
|
resolve(content.body);
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const models = require("../../../models/index.cjs");
|
|
3
|
-
const log = require('
|
|
3
|
+
const log = require('../../../utils/logger.cjs');
|
|
4
4
|
const moment = require('moment');
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const getPointDomainIncludes = (id) => {
|
|
@@ -7,7 +7,7 @@ const convertToString = (integer, type) => {
|
|
|
7
7
|
return integer.toString();
|
|
8
8
|
}
|
|
9
9
|
else {
|
|
10
|
-
|
|
10
|
+
log.error("Cant find integer to string for: " + type);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const importDomain = (domain, done) => {
|
|
@@ -113,11 +113,11 @@ const importPost = (post, done) => {
|
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
115
|
description += `${answers[i].value}`;
|
|
116
|
-
|
|
116
|
+
log.warn(`Error trimming answer to description: ${answers[i].value}`);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
else {
|
|
120
|
-
|
|
120
|
+
log.error(`No value for answer in adding to description: ${answers[i]}`);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -149,7 +149,7 @@ const importPost = (post, done) => {
|
|
|
149
149
|
else if (_hasCoverMediaType(post, "audio") && post.Audios && post.Audios.length > 0) {
|
|
150
150
|
audioUrl = _getAudioURL(post.Audios);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
log.info("Image URL before: " + imageUrl);
|
|
153
153
|
if (!imageUrl) {
|
|
154
154
|
if (post.Group.GroupLogoImages && post.Group.GroupLogoImages.length > 0) {
|
|
155
155
|
formats = JSON.parse(post.Group.GroupLogoImages[0].formats);
|
|
@@ -160,9 +160,9 @@ const importPost = (post, done) => {
|
|
|
160
160
|
imageUrl = formats[0];
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
log.info("Image URL after: " + imageUrl);
|
|
164
|
+
log.info("Language: " + language);
|
|
165
|
+
log.info(description);
|
|
166
166
|
//TODO: Add endorsements up and down for ratings for 3d maps
|
|
167
167
|
//TODO: Add English translation if there and make train english maps for all items
|
|
168
168
|
properties = _.merge(properties, {
|
|
@@ -250,8 +250,8 @@ const importPoint = (point, done) => {
|
|
|
250
250
|
if (point.PointAudios && point.PointAudios.length > 0) {
|
|
251
251
|
audioUrl = _getAudioURL(point.PointAudios);
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
log.info("Language: " + language);
|
|
254
|
+
log.info(point.id);
|
|
255
255
|
//TODO: Add endorsements up and down for ratings for 3d maps
|
|
256
256
|
//TODO: Add English translation if there and make train english maps for all items
|
|
257
257
|
properties = _.merge(properties, {
|
|
@@ -349,7 +349,7 @@ const _getImageFormatUrl = function (images, formatId) {
|
|
|
349
349
|
};
|
|
350
350
|
const _hasCoverMediaType = function (post, mediaType) {
|
|
351
351
|
if (!post) {
|
|
352
|
-
|
|
352
|
+
log.info("No post for " + mediaType);
|
|
353
353
|
return false;
|
|
354
354
|
}
|
|
355
355
|
else {
|
|
@@ -6,6 +6,7 @@ const Excel = require("exceljs");
|
|
|
6
6
|
const setJobError = require("../../reports/common_utils.cjs").setJobError;
|
|
7
7
|
const uploadToS3 = require("../../reports/common_utils.cjs").uploadToS3;
|
|
8
8
|
const sanitizeFilename = require("sanitize-filename");
|
|
9
|
+
const log = require("../../../../utils/logger.cjs");
|
|
9
10
|
const formatWorksheet = (worksheet) => {
|
|
10
11
|
worksheet.getRow(1).font = { bold: true };
|
|
11
12
|
// worksheet.properties.defaultRowHeight = 20;
|
|
@@ -288,7 +289,7 @@ class FraudAuditReport {
|
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
catch (error) {
|
|
291
|
-
|
|
292
|
+
log.error(error);
|
|
292
293
|
setJobError(this.workPackage.jobId, "errorFraudAuditReportGeneration", error, (dbError) => {
|
|
293
294
|
reject(dbError || error);
|
|
294
295
|
});
|
|
@@ -12,11 +12,11 @@ class FraudBase {
|
|
|
12
12
|
;
|
|
13
13
|
}
|
|
14
14
|
getTopItems() {
|
|
15
|
-
|
|
15
|
+
log.error("Should be implemented in a sub class");
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
async getAllItems() {
|
|
19
|
-
|
|
19
|
+
log.error("Should be implemented in a sub class");
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
getPostIdsFromItems(topItems) {
|
|
@@ -23,11 +23,11 @@ class FraudDeleteBase extends FraudBase {
|
|
|
23
23
|
}
|
|
24
24
|
async getItemsById() {
|
|
25
25
|
// this.job.internal_data.idsToDelete
|
|
26
|
-
|
|
26
|
+
log.error("Should be implemented in a sub class");
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
async destroyChunkItems(chunks) {
|
|
30
|
-
|
|
30
|
+
log.error("Should be implemented in a sub class");
|
|
31
31
|
}
|
|
32
32
|
getAllItemsExceptOne(items) {
|
|
33
33
|
if (items.length === 1 && this.getAllowedSingleDelete()) {
|
|
@@ -179,7 +179,7 @@ class FraudDeleteBase extends FraudBase {
|
|
|
179
179
|
}
|
|
180
180
|
async deleteItems() {
|
|
181
181
|
return await new Promise(async (resolve, reject) => {
|
|
182
|
-
|
|
182
|
+
log.info(`Delete data ${JSON.stringify(this.workPackage)}`);
|
|
183
183
|
try {
|
|
184
184
|
this.job = await models.AcBackgroundJob.findOne({
|
|
185
185
|
where: {
|
|
@@ -202,7 +202,7 @@ class FraudDeleteBase extends FraudBase {
|
|
|
202
202
|
}
|
|
203
203
|
catch (error) {
|
|
204
204
|
await models.AcBackgroundJob.updateErrorAsync(this.workPackage.jobId, error.toString());
|
|
205
|
-
|
|
205
|
+
log.error(error);
|
|
206
206
|
reject(error);
|
|
207
207
|
}
|
|
208
208
|
});
|
|
@@ -114,7 +114,7 @@ class FraudGetBase extends FraudBase {
|
|
|
114
114
|
async processAndGetFraudItems() {
|
|
115
115
|
return await new Promise(async (resolve, reject) => {
|
|
116
116
|
try {
|
|
117
|
-
|
|
117
|
+
log.info(`Get Fraud ${JSON.stringify(this.workPackage)}`);
|
|
118
118
|
this.items = await this.getAllItems();
|
|
119
119
|
this.setupDataToProcess();
|
|
120
120
|
this.setBackgroundColorsFromKey();
|
|
@@ -51,7 +51,7 @@ class FraudScannerNotifier {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
|
|
54
|
+
log.error("No domain name for community");
|
|
55
55
|
return "";
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -70,7 +70,7 @@ class FraudScannerNotifier {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
|
|
73
|
+
log.error(`No job data for ${collectionType}`);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
capitalizeFirstLetter(string) {
|
|
@@ -127,7 +127,7 @@ class FraudScannerNotifier {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
|
|
130
|
+
log.error("No community admins found");
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -176,7 +176,7 @@ class FraudScannerNotifier {
|
|
|
176
176
|
await this.currentCommunity.save();
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
|
-
|
|
179
|
+
log.info("Not resending same numbers");
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -227,15 +227,15 @@ class FraudScannerNotifier {
|
|
|
227
227
|
]
|
|
228
228
|
});
|
|
229
229
|
for (let i = 0; i < communities.length; i++) {
|
|
230
|
-
|
|
230
|
+
log.info("Processing community: " + communities[i].name);
|
|
231
231
|
this.currentCommunity = communities[i];
|
|
232
232
|
try {
|
|
233
233
|
await this.scan();
|
|
234
234
|
await this.notify();
|
|
235
235
|
}
|
|
236
236
|
catch (error) {
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
log.error("Error processing community: " + communities[i].name);
|
|
238
|
+
log.error(error);
|
|
239
239
|
reject(error);
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
@@ -268,11 +268,11 @@ i18n
|
|
|
268
268
|
try {
|
|
269
269
|
const scanner = new FraudScannerNotifier();
|
|
270
270
|
await scanner.scanAndNotify();
|
|
271
|
-
|
|
271
|
+
log.info("Fraud Scanning Complete");
|
|
272
272
|
process.exit();
|
|
273
273
|
}
|
|
274
274
|
catch (error) {
|
|
275
|
-
|
|
275
|
+
log.error(error);
|
|
276
276
|
process.exit();
|
|
277
277
|
}
|
|
278
278
|
})();
|
|
@@ -4,7 +4,7 @@ const models = require("../../../models/index.cjs");
|
|
|
4
4
|
const i18n = require('../../utils/i18n.cjs');
|
|
5
5
|
const async = require('async');
|
|
6
6
|
const moment = require('moment');
|
|
7
|
-
const log = require('
|
|
7
|
+
const log = require('../../../utils/logger.cjs');
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
const domainIncludes = (domainId) => {
|
|
10
10
|
return [
|
|
@@ -3,7 +3,7 @@ const vision = require('@google-cloud/vision');
|
|
|
3
3
|
const models = require("../../../../models/index.cjs");
|
|
4
4
|
var downloadFile = require('download-file');
|
|
5
5
|
const fs = require("fs");
|
|
6
|
-
const log = require('
|
|
6
|
+
const log = require('../../../../utils/logger.cjs');
|
|
7
7
|
class ImageLabelingBase {
|
|
8
8
|
constructor(workPackage) {
|
|
9
9
|
this.workPackage = workPackage;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const queue = require('../../workers/queue.cjs');
|
|
3
3
|
const models = require("../../../models/index.cjs");
|
|
4
4
|
const async = require('async');
|
|
5
|
-
const log = require('
|
|
5
|
+
const log = require('../../../utils/logger.cjs');
|
|
6
6
|
const _ = require('lodash');
|
|
7
7
|
const getAnonymousUser = require('../../utils/get_anonymous_system_user.cjs');
|
|
8
8
|
const domainIncludes = require('./get_moderation_items.cjs').domainIncludes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const models = require("../../../models/index.cjs");
|
|
3
3
|
const async = require("async");
|
|
4
|
-
const log = require("
|
|
4
|
+
const log = require("../../../utils/logger.cjs");
|
|
5
5
|
const TOXICITY_THRESHOLD = 0.5;
|
|
6
6
|
const TOXICITY_EMAIL_THRESHOLD = 0.75;
|
|
7
7
|
const Perspective = require("./perspective_api_client.cjs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var models = require("../../../models/index.cjs");
|
|
3
3
|
var async = require('async');
|
|
4
|
-
var log = require('
|
|
4
|
+
var log = require('../../../utils/logger.cjs');
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var getRecommendationFor = require('../recommendations/events_manager.cjs').getRecommendationFor;
|
|
7
7
|
var getProcessedRange = require('./news_feeds_utils.cjs').getProcessedRange;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var models = require("../../../models/index.cjs");
|
|
3
3
|
var async = require('async');
|
|
4
|
-
var log = require('
|
|
4
|
+
var log = require('../../../utils/logger.cjs');
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var toJson = require('../../utils/to_json.cjs');
|
|
7
7
|
var airbrake = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var DEBUG_EMAILS_TO_TEMP_FIlE = false;
|
|
3
|
-
var log = require("
|
|
3
|
+
var log = require("../../../utils/logger.cjs");
|
|
4
4
|
var async = require("async");
|
|
5
5
|
var path = require("path");
|
|
6
6
|
var nodemailer = require("nodemailer");
|
|
@@ -212,7 +212,7 @@ const processNotification = (notification, user, template, subject, callback) =>
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
|
-
|
|
215
|
+
log.warn("Can't find email for user");
|
|
216
216
|
callback();
|
|
217
217
|
}
|
|
218
218
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const models = require("../../../models/index.cjs");
|
|
3
|
-
const log = require('
|
|
3
|
+
const log = require('../../../utils/logger.cjs');
|
|
4
4
|
const async = require('async');
|
|
5
5
|
const getModelAndUsersByType = require('./notifications_utils.cjs').getModelAndUsersByType;
|
|
6
6
|
const addNotificationsForUsers = require('./notifications_utils.cjs').addNotificationsForUsers;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const models = require("../../../models/index.cjs");
|
|
3
|
-
const log = require("
|
|
3
|
+
const log = require("../../../utils/logger.cjs");
|
|
4
4
|
const async = require("async");
|
|
5
5
|
const getModelAndUsersByType = require("./notifications_utils.cjs").getModelAndUsersByType;
|
|
6
6
|
const addNotificationsForUsers = require("./notifications_utils.cjs").addNotificationsForUsers;
|