wiki/server/models/users.js
/**
   * Add / Update User Avatar Data
   */
Add / Update User Avatar Data
Add / Update User Avatar Data
static async updateUserAvatarData (userId, data) {
    try {
      WIKI.logger.debug(`Updating user ${userId} avatar data...`)
      if (data.length > 1024 * 1024) {
        throw new Error('Avatar image filesize is too large. 1MB max.')
      }
      const existing = await WIKI.models.knex('userAvatars').select('id').where('id', userId).first()
      if (existing) {
        await WIKI.models.knex('userAvatars').where({
          id: userId
        }).update({
          data
        })
      } else {
        await WIKI.models.knex('userAvatars').insert({
          id: userId,
          data
        })
      }
    } catch (err) {
      WIKI.logger.warn(`Failed to process binary thumbnail data for user ${userId}: ${err.message}`)
    }
  }
static async updateUserAvatarData ( userId , data ) { try { WIKI . logger . debug ( ` ${ userId } ` ) if ( data . length > 1024 * 1024 ) { throw new Error ( 'Avatar image filesize is too large. 1MB max.' ) } const existing = await WIKI . models . knex ( 'userAvatars' ) . select ( 'id' ) . where ( 'id' , userId ) . first ( ) if ( existing ) { await WIKI . models . knex ( 'userAvatars' ) . where ( { id : userId } ) . update ( { data } ) } else { await WIKI . models . knex ( 'userAvatars' ) . insert ( { id : userId , data } ) } } catch ( err ) { WIKI . logger . warn ( ` ${ userId } ${ err . message } ` ) } }
Add / Update User Avatar Data
Add / Update User Avatar Data