houdini/lib/insert/insert_supporter_notes.rb
2021-01-17 17:08:52 -06:00

22 lines
725 B
Ruby

# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module InsertSupporterNotes
#note_supporter_users : array of hashes
# each hash:
# supporter: Supporter new note should belong to
# user: User creating the note
# note: parameters to pass into the note
def self.create(*note_supporter_users)
inserted = nil
ActiveRecord::Base.transaction do
inserted = note_supporter_users.map do |nsu|
nsu[:supporter].supporter_notes.create(nsu[:note].merge({user: nsu[:user]}))
end
InsertActivities.for_supporter_notes(inserted)
end
inserted
end
end