feat: add phone to instance creation

This commit is contained in:
Khaled FERJANI
2025-10-02 18:15:13 +02:00
parent 00c81827ef
commit bf27a44296
2 changed files with 5 additions and 0 deletions
@@ -4,6 +4,7 @@ import globalResolver from "../../../services/global-resolver";
import User from "../../../services/user/entities/user";
import yargs from "yargs";
import { createCozyInstance } from "./utils";
import { getLDAPUserMobile } from "./utils/ldap";
const migrateUsersCommand: yargs.CommandModule<unknown, unknown> = {
command: "migrate-users",
@@ -59,12 +60,14 @@ const migrateUsersCommand: yargs.CommandModule<unknown, unknown> = {
for (const user of usersToMigrate) {
const userId = user.email_canonical.split("@")[0];
const phone = await getLDAPUserMobile(userId);
const userObject = {
_id: user.id,
id: userId,
email: user.email_canonical,
name: `${user.first_name} ${user.last_name}`,
locale: user.preferences?.locale || "fr",
phone
};
if (!dryRun) {
@@ -39,6 +39,7 @@ export async function createCozyInstance(user: {
name: string;
_id: string;
locale: string;
phone: string;
}) {
console.log(`🚀 Creating Cozy instance for ${user.email}...`);
@@ -54,6 +55,7 @@ export async function createCozyInstance(user: {
public_name: user.name,
locale: user.locale,
oidc: user.id,
phone: user.phone
},
{
headers: {