@open-xchange/soap-client 0.0.5 → 0.0.6

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/bin/provision.js CHANGED
@@ -6,8 +6,7 @@ import * as secondaryAccountService from '../services/secondaryAccount.js'
6
6
  import * as userService from '../services/common/user.js'
7
7
  import * as contextService from '../services/common/context.js'
8
8
 
9
- dotenv.config({ path: '.env' })
10
- dotenv.config({ path: '.env.defaults' })
9
+ dotenv.config({ path: ['.env', '.env.defaults'], quiet: true })
11
10
 
12
11
  const contextAdmin = {
13
12
  admin: {
@@ -59,12 +58,15 @@ async function getOrCreateContext (data) {
59
58
 
60
59
  async function getOrCreateUser (context, userData) {
61
60
  try {
62
- const existingUser = await userService.list(context, userData.display_name)
63
- if (existingUser?.length > 0) {
64
- console.log('User already exists, using existing one')
65
- return existingUser[0]
61
+ const existingUsers = (await Promise.all([
62
+ userService.list(context, userData.name),
63
+ userService.list(context, userData.display_name)
64
+ ])).flat().filter(Boolean)
65
+ if (existingUsers?.length > 0) {
66
+ console.log('User already exists', userData.name)
67
+ return existingUsers[0]
66
68
  }
67
- console.log('Creating new user')
69
+ console.log('Creating new user', userData.name)
68
70
  userData = {
69
71
  imapServer: process.env.IMAP_SERVER || 'main-dovecot',
70
72
  smtpServer: process.env.SMTP_SERVER || 'main-postfix',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/soap-client",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "SOAP client for OX App Suite",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "commander": "^14.0.0",
24
24
  "dotenv": "^17.2.1",
25
- "p-retry": "^6.2.1",
25
+ "p-retry": "^7.0.0",
26
26
  "soap": "^1.3.0"
27
27
  },
28
28
  "devDependencies": {
@@ -119,3 +119,12 @@ export async function list (context, searchPattern, includeGuests = false) {
119
119
  auth: context.admin
120
120
  })
121
121
  }
122
+
123
+ export async function listAll (context, includeGuests = false, excludeUsers = []) {
124
+ return await (await OXUserService).listAsync({
125
+ ctx: { id: context.id },
126
+ include_guests: includeGuests,
127
+ exclude_users: excludeUsers,
128
+ auth: context.admin
129
+ })
130
+ }