blob: 676c71f13166550550a6693eb153291ea2d19b14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# frozen_string_literal: true
module BulkImports
module Common
module Transformers
class AwardEmojiTransformer
def transform(context, data)
user = find_user(context, data&.dig('user', 'public_email')) || context.current_user
data
.except('user')
.merge('user_id' => user.id)
end
private
def find_user(context, email)
return if email.blank?
context.group.users.find_by_any_email(email, confirmed: true) # rubocop: disable CodeReuse/ActiveRecord
end
end
end
end
end
|