@xuda.io/ai_module 1.1.4772 → 1.1.4774
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/index.mjs +36 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { mdToPdf } from 'md-to-pdf';
|
|
|
16
16
|
import _ from 'lodash';
|
|
17
17
|
|
|
18
18
|
import { NodeVM, VMScript } from 'vm2';
|
|
19
|
+
import admin from 'firebase-admin';
|
|
19
20
|
|
|
20
21
|
puppeteer.use(StealthPlugin());
|
|
21
22
|
import process from 'process';
|
|
@@ -28,6 +29,11 @@ global._conf = (
|
|
|
28
29
|
})
|
|
29
30
|
).default;
|
|
30
31
|
|
|
32
|
+
const _defaultAppConfig = {
|
|
33
|
+
credential: admin.credential.cert(_conf.firebase_serviceAccount),
|
|
34
|
+
};
|
|
35
|
+
admin.initializeApp(_defaultAppConfig);
|
|
36
|
+
|
|
31
37
|
const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
|
|
32
38
|
const runtime_modules_path = path.join(process.env.XUDA_HOME, 'dist', 'runtime', 'js', 'modules');
|
|
33
39
|
|
|
@@ -6943,6 +6949,8 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6943
6949
|
const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
|
|
6944
6950
|
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
|
|
6945
6951
|
|
|
6952
|
+
const { email } = metadata;
|
|
6953
|
+
|
|
6946
6954
|
let prompt,
|
|
6947
6955
|
url,
|
|
6948
6956
|
factual_prompt,
|
|
@@ -6986,6 +6994,32 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6986
6994
|
break;
|
|
6987
6995
|
}
|
|
6988
6996
|
|
|
6997
|
+
const getUserPhotoByEmail = async function (email) {
|
|
6998
|
+
try {
|
|
6999
|
+
const auth = admin.auth();
|
|
7000
|
+
const userRecord = await auth.getUserByEmail(email);
|
|
7001
|
+
|
|
7002
|
+
// photoURL is the profile picture URL (or null if not set)
|
|
7003
|
+
const photoURL = userRecord.photoURL;
|
|
7004
|
+
// console.log(`User found: ${JSON.stringify(userRecord)}`);
|
|
7005
|
+
|
|
7006
|
+
// console.log(`User found: ${userRecord.uid}`);
|
|
7007
|
+
// console.log(`Display name: ${userRecord.displayName || 'None'}`);
|
|
7008
|
+
// console.log(`Email verified: ${userRecord.emailVerified}`);
|
|
7009
|
+
// console.log(`Profile picture URL: ${photoURL || 'No photo set'}`);
|
|
7010
|
+
|
|
7011
|
+
return photoURL;
|
|
7012
|
+
} catch (error) {
|
|
7013
|
+
if (error.code === 'auth/user-not-found') {
|
|
7014
|
+
console.log(`No user found with email: ${email}`);
|
|
7015
|
+
return null;
|
|
7016
|
+
}
|
|
7017
|
+
|
|
7018
|
+
console.error('Error fetching user:', error);
|
|
7019
|
+
// throw error;
|
|
7020
|
+
}
|
|
7021
|
+
};
|
|
7022
|
+
|
|
6989
7023
|
const get_url = async function () {
|
|
6990
7024
|
const ret = await submit_chat_gpt_prompt({
|
|
6991
7025
|
uid,
|
|
@@ -7001,6 +7035,8 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
7001
7035
|
|
|
7002
7036
|
// debugger;
|
|
7003
7037
|
try {
|
|
7038
|
+
url = await getUserPhotoByEmail(email);
|
|
7039
|
+
|
|
7004
7040
|
// first attempt
|
|
7005
7041
|
if (account_type === 'business') {
|
|
7006
7042
|
url = await get_url();
|