chore(backend): Import user avatars but not sets (for now)
This commit is contained in:
parent
6451222b2b
commit
e36fbad721
3 changed files with 14 additions and 5 deletions
|
@ -76,7 +76,6 @@ const html = mustache.render(
|
|||
*/
|
||||
const batches = splitArray(users, 45)
|
||||
|
||||
let i = 0
|
||||
const total = batches.length
|
||||
batches.forEach((batch, i) => {
|
||||
/*
|
||||
|
|
|
@ -1289,7 +1289,6 @@ const migrateUser = (v2) => {
|
|||
* This is a special route not available for API users
|
||||
*/
|
||||
UserModel.prototype.import = async function (user) {
|
||||
let created = 0
|
||||
if (user.status === 'active') {
|
||||
const data = migrateUser(user)
|
||||
if (user.consent.profile) data.consent++
|
||||
|
@ -1303,7 +1302,7 @@ UserModel.prototype.import = async function (user) {
|
|||
/*
|
||||
* Skip images for now
|
||||
*/
|
||||
if (false && data.img) {
|
||||
if (data.img) {
|
||||
/*
|
||||
* Figure out what image to grab from the FreeSewing v2 backend server
|
||||
*/
|
||||
|
@ -1333,7 +1332,6 @@ UserModel.prototype.import = async function (user) {
|
|||
}
|
||||
try {
|
||||
await this.createRecord(data)
|
||||
created++
|
||||
} catch (err) {
|
||||
log.warn(err, 'Could not create user record')
|
||||
console.log(user)
|
||||
|
|
|
@ -88,8 +88,20 @@ export async function importImage(props, isTest = false) {
|
|||
// Bypass slow ass upload when testing import
|
||||
if (!config.import) return `default-avatar`
|
||||
|
||||
// Only upload user images for now
|
||||
if (props.id.slice(0, 5) !== 'user-') return `default-avatar`
|
||||
|
||||
const form = getFormData(props)
|
||||
await axios.post(config.api, form, { headers })
|
||||
/*
|
||||
* The image may already exist, so swallow the error
|
||||
*/
|
||||
try {
|
||||
await axios.post(config.api, form, { headers })
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
console.log('Imported img', props.id)
|
||||
|
||||
return props.id
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue