@xuda.io/account_module 1.2.2252 → 1.2.2254

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.
Files changed (3) hide show
  1. package/index.mjs +49 -10
  2. package/index_ms.mjs +4 -0
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -29,6 +29,11 @@ const account_info_properties = [
29
29
  'active_account_profile_id',
30
30
  'profile_avatar',
31
31
  'profile_avatar_obj',
32
+ 'is_xuda_network_ambassador',
33
+ 'network_profile_url',
34
+ 'network_lang',
35
+ 'network_country_code',
36
+ 'network_city_slug',
32
37
  ];
33
38
 
34
39
  global._conf = (
@@ -162,6 +167,29 @@ export const update_account_info = async function (req, job_id, headers) {
162
167
  if (key === 'country' && !validate_input(val, 55, false, false)) {
163
168
  error[key] = 'Invalid country';
164
169
  }
170
+ if (key === 'is_xuda_network_ambassador' && typeof val !== 'boolean') {
171
+ error[key] = 'Invalid ambassador flag';
172
+ }
173
+ if (key === 'network_profile_url') {
174
+ let url_ok = false;
175
+ try {
176
+ url_ok = new URL(val).protocol === 'https:';
177
+ } catch (_) {
178
+ /* invalid */
179
+ }
180
+ if (!url_ok) {
181
+ error[key] = 'Invalid network profile url';
182
+ }
183
+ }
184
+ if (key === 'network_lang' && !/^[a-z]{2}$/.test(val)) {
185
+ error[key] = 'Invalid network lang';
186
+ }
187
+ if (key === 'network_country_code' && !/^[a-z]{2}$/.test(val)) {
188
+ error[key] = 'Invalid network country code';
189
+ }
190
+ if (key === 'network_city_slug' && !/^[a-z0-9-]{2,64}$/.test(val)) {
191
+ error[key] = 'Invalid network city slug';
192
+ }
165
193
  }
166
194
  }
167
195
 
@@ -703,6 +731,12 @@ export const get_active_account_profile_info = async function (uid, profile_id)
703
731
  }
704
732
  };
705
733
 
734
+ export const get_account_profile_group_member_uids = async function (owner_uid, share_item_id) {
735
+ const selector = { docType: 'team_request', team_req_stat: 3, share_item_id, access_type: 'account_profile', team_req_from_uid: owner_uid };
736
+ const ret = await db_module.find_couch_query('xuda_team', { selector });
737
+ return (ret?.docs || []).map((d) => d.team_req_to_uid).filter(Boolean);
738
+ };
739
+
706
740
  export const get_account_name = async function (req) {
707
741
  const data = await db_module.get_couch_doc('xuda_accounts', req.uid_query || req.uid);
708
742
  if (data.code < 0) {
@@ -1935,15 +1969,19 @@ export const onboarding_completed = async function (req, job_id, headers) {
1935
1969
  account_doc.isBoarded = true;
1936
1970
  const save_ret = await db_module.save_couch_doc('xuda_accounts', account_doc);
1937
1971
 
1938
- notification_msa.submit_notification({
1939
- type: 'account',
1940
- app_id: null,
1941
- uid_arr: [uid],
1942
- topic: 'welcome_aboard',
1943
- params: { name: account_doc.account_info.first_name, email: account_doc.account_info.email, dashboard_url: 'https://xuda.ai/dashboard' },
1944
- ref: null,
1945
- email: null,
1946
- });
1972
+ if (account_doc.account_info?.is_xuda_network_ambassador === true) {
1973
+ console.log('[onboarding_completed] suppressing welcome_aboard for xuda.network ambassador', uid, account_doc.account_info.email);
1974
+ } else {
1975
+ notification_msa.submit_notification({
1976
+ type: 'account',
1977
+ app_id: null,
1978
+ uid_arr: [uid],
1979
+ topic: 'welcome_aboard',
1980
+ params: { name: account_doc.account_info.first_name, email: account_doc.account_info.email, dashboard_url: 'https://xuda.ai/dashboard' },
1981
+ ref: null,
1982
+ email: null,
1983
+ });
1984
+ }
1947
1985
 
1948
1986
  return save_ret;
1949
1987
  } catch (err) {
@@ -3215,7 +3253,8 @@ export const get_account_profiles = async function (req) {
3215
3253
  }
3216
3254
  }
3217
3255
 
3218
- if (filter_type === 'all' && !profile_id && !search && active_tab && profile_docs.docs.length === 1 && profile_docs.docs[0].main) {
3256
+ if (filter_type === 'all' && !profile_id && !search && active_tab && profile_docs.docs[0].main) {
3257
+ //profile_docs.docs.length === 1 &&
3219
3258
  // return empty state if no custom profile defined by user
3220
3259
  return {
3221
3260
  code: 1,
package/index_ms.mjs CHANGED
@@ -69,6 +69,10 @@ export const get_account_name = async function (...args) {
69
69
  return await broker.send_to_queue("get_account_name", ...args);
70
70
  };
71
71
 
72
+ export const get_account_profile_group_member_uids = async function (...args) {
73
+ return await broker.send_to_queue("get_account_profile_group_member_uids", ...args);
74
+ };
75
+
72
76
  export const account_validate_username = async function (...args) {
73
77
  return await broker.send_to_queue("account_validate_username", ...args);
74
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2252",
3
+ "version": "1.2.2254",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {