setDefaultUserImage static method

Future<UserProfileModel> setDefaultUserImage(
  1. Session session,
  2. UuidValue authUserId, {
  3. Transaction? transaction,
})

Sets a user's image to the default image for that user.

Implementation

static Future<UserProfileModel> setDefaultUserImage(
  final Session session,
  final UuidValue authUserId, {
  final Transaction? transaction,
}) async {
  return DatabaseUtil.runInTransactionOrSavepoint(
    session.db,
    transaction,
    (final transaction) async {
      final userProfile = await UserProfiles.findUserProfileByUserId(
        session,
        authUserId,
        transaction: transaction,
      );

      final image = await defaultUserImageGenerator(userProfile);

      final imageBytes = await _encodeImage(image);

      return setUserImageFromBytes(
        session,
        authUserId,
        imageBytes,
        transaction: transaction,
      );
    },
  );
}