@xuda.io/account_module 1.2.1639 → 1.2.1641
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 +90 -89
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1907,6 +1907,94 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
|
|
|
1907
1907
|
}
|
|
1908
1908
|
};
|
|
1909
1909
|
|
|
1910
|
+
const set_account_profile_picture = async function (uid, account_uid, metadata, job_id, headers) {
|
|
1911
|
+
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
1912
|
+
const account_profile_info = await get_active_account_profile_info(uid);
|
|
1913
|
+
await update_account_profile_picture_status(account_uid, 1);
|
|
1914
|
+
try {
|
|
1915
|
+
let profile_picture;
|
|
1916
|
+
|
|
1917
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
1918
|
+
let account_info = account_obj.account_info;
|
|
1919
|
+
|
|
1920
|
+
if (account_code < 0) {
|
|
1921
|
+
throw new Error(`account ${account_uid} not found`);
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
|
|
1925
|
+
|
|
1926
|
+
await update_account_profile_picture_status(account_uid, 2);
|
|
1927
|
+
if (!account_info.profile_picture) {
|
|
1928
|
+
const file_ret = await ai_module.get_profile_picture(uid, account_info.account_type, name, { email: account_info.email, metadata, account_info }, account_profile_info, job_id, headers);
|
|
1929
|
+
|
|
1930
|
+
let { code: account_code, data: account_obj2 } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
1931
|
+
account_obj = account_obj2;
|
|
1932
|
+
account_info = account_obj.account_info;
|
|
1933
|
+
|
|
1934
|
+
account_info.profile_picture_obj = file_ret.data;
|
|
1935
|
+
|
|
1936
|
+
account_info.profile_picture = account_info.profile_picture_obj.file_url;
|
|
1937
|
+
account_info.profile_picture_source = file_ret.profile_picture_source;
|
|
1938
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
1939
|
+
profile_picture = account_info.profile_picture;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
if (!account_info.profile_avatar) {
|
|
1943
|
+
let business_size;
|
|
1944
|
+
|
|
1945
|
+
switch (account_obj.membership_plan) {
|
|
1946
|
+
case 'free': {
|
|
1947
|
+
business_size = 'unknown';
|
|
1948
|
+
break;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
case 'pro': {
|
|
1952
|
+
business_size = 'small';
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
case 'team': {
|
|
1957
|
+
business_size = 'medium';
|
|
1958
|
+
break;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
case 'agency': {
|
|
1962
|
+
business_size = 'large';
|
|
1963
|
+
break;
|
|
1964
|
+
}
|
|
1965
|
+
case 'enterprise_t1':
|
|
1966
|
+
case 'enterprise_t2':
|
|
1967
|
+
case 'enterprise_t3': {
|
|
1968
|
+
business_size = 'enterprise';
|
|
1969
|
+
break;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
default:
|
|
1973
|
+
business_size = 'unknown';
|
|
1974
|
+
break;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
const { bio, country, mainCategory, subCategory } = account_info;
|
|
1978
|
+
|
|
1979
|
+
const file_ret = await ai_module.get_profile_avatar(account_info.profile_picture, uid, '', account_profile_info, account_info.account_type, 'account', account_uid, { bio, country, mainCategory, subCategory }, business_size, name, account_info.email, job_id, headers);
|
|
1980
|
+
if (file_ret.code < 0) {
|
|
1981
|
+
throw new Error(file_ret.data);
|
|
1982
|
+
}
|
|
1983
|
+
let { code: account_code, data: account_obj3 } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
1984
|
+
account_obj = account_obj3;
|
|
1985
|
+
account_info = account_obj.account_info;
|
|
1986
|
+
|
|
1987
|
+
account_info.profile_avatar_obj = file_ret.data;
|
|
1988
|
+
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
1989
|
+
|
|
1990
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
1991
|
+
await update_account_profile_picture_status(account_uid, 3);
|
|
1992
|
+
}
|
|
1993
|
+
} catch (err) {
|
|
1994
|
+
await update_account_profile_picture_status(account_uid, 1, err.message);
|
|
1995
|
+
}
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1910
1998
|
setTimeout(async () => {
|
|
1911
1999
|
const app_id = 'prj712ffdf5aa8adce6cedef988f9c12392'; //'prj3937cb6f9a31c8c7dea25055bba845b1'; //
|
|
1912
2000
|
const uid = 'd39126e0e2c51ffbd1aad10709fc8335';
|
|
@@ -1956,7 +2044,7 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
1956
2044
|
/////////////////
|
|
1957
2045
|
|
|
1958
2046
|
let is_spam = false;
|
|
1959
|
-
|
|
2047
|
+
|
|
1960
2048
|
let account_type;
|
|
1961
2049
|
let cached_contact;
|
|
1962
2050
|
if (contact_uid) {
|
|
@@ -2046,95 +2134,8 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2046
2134
|
}
|
|
2047
2135
|
};
|
|
2048
2136
|
|
|
2049
|
-
const set_account_profile_picture = async function (uid, account_uid, metadata, job_id, headers) {
|
|
2050
|
-
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
2051
|
-
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2052
|
-
await update_account_profile_picture_status(account_uid, 1);
|
|
2053
|
-
try {
|
|
2054
|
-
let profile_picture;
|
|
2055
|
-
|
|
2056
|
-
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2057
|
-
let account_info = account_obj.account_info;
|
|
2058
|
-
|
|
2059
|
-
if (account_code < 0) {
|
|
2060
|
-
throw new Error(`account ${account_uid} not found`);
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
|
|
2064
|
-
|
|
2065
|
-
await update_account_profile_picture_status(account_uid, 2);
|
|
2066
|
-
if (!account_info.profile_picture) {
|
|
2067
|
-
const file_ret = await ai_module.get_profile_picture(uid, account_info.account_type, name, { email: account_info.email, metadata, account_info }, account_profile_info, job_id, headers);
|
|
2068
|
-
|
|
2069
|
-
let { code: account_code, data: account_obj2 } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2070
|
-
account_obj = account_obj2;
|
|
2071
|
-
account_info = account_obj.account_info;
|
|
2072
|
-
|
|
2073
|
-
account_info.profile_picture_obj = file_ret.data;
|
|
2074
|
-
|
|
2075
|
-
account_info.profile_picture = account_info.profile_picture_obj.file_url;
|
|
2076
|
-
account_info.profile_picture_source = file_ret.profile_picture_source;
|
|
2077
|
-
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2078
|
-
profile_picture = account_info.profile_picture;
|
|
2079
|
-
}
|
|
2080
|
-
|
|
2081
|
-
if (!account_info.profile_avatar) {
|
|
2082
|
-
let business_size;
|
|
2083
|
-
|
|
2084
|
-
switch (account_obj.membership_plan) {
|
|
2085
|
-
case 'free': {
|
|
2086
|
-
business_size = 'unknown';
|
|
2087
|
-
break;
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
case 'pro': {
|
|
2091
|
-
business_size = 'small';
|
|
2092
|
-
break;
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
case 'team': {
|
|
2096
|
-
business_size = 'medium';
|
|
2097
|
-
break;
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
case 'agency': {
|
|
2101
|
-
business_size = 'large';
|
|
2102
|
-
break;
|
|
2103
|
-
}
|
|
2104
|
-
case 'enterprise_t1':
|
|
2105
|
-
case 'enterprise_t2':
|
|
2106
|
-
case 'enterprise_t3': {
|
|
2107
|
-
business_size = 'enterprise';
|
|
2108
|
-
break;
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
default:
|
|
2112
|
-
business_size = 'unknown';
|
|
2113
|
-
break;
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
const { bio, country, mainCategory, subCategory } = account_info;
|
|
2117
|
-
|
|
2118
|
-
const file_ret = await ai_module.get_profile_avatar(account_info.profile_picture, uid, '', account_profile_info, account_info.account_type, 'account', account_uid, { bio, country, mainCategory, subCategory }, business_size, name, account_info.email, job_id, headers);
|
|
2119
|
-
if (file_ret.code < 0) {
|
|
2120
|
-
throw new Error(file_ret.data);
|
|
2121
|
-
}
|
|
2122
|
-
let { code: account_code, data: account_obj3 } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2123
|
-
account_obj = account_obj3;
|
|
2124
|
-
account_info = account_obj.account_info;
|
|
2125
|
-
|
|
2126
|
-
account_info.profile_avatar_obj = file_ret.data;
|
|
2127
|
-
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
2128
|
-
|
|
2129
|
-
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2130
|
-
await update_account_profile_picture_status(account_uid, 3);
|
|
2131
|
-
}
|
|
2132
|
-
} catch (err) {
|
|
2133
|
-
await update_account_profile_picture_status(account_uid, 1, err.message);
|
|
2134
|
-
}
|
|
2135
|
-
};
|
|
2136
|
-
|
|
2137
2137
|
const set_contact_profile_picture = async function (uid, contact_id, metadata, job_id, headers) {
|
|
2138
|
+
debugger;
|
|
2138
2139
|
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
2139
2140
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2140
2141
|
|