Commit 2e1decd0 authored by James Lopez's avatar James Lopez

restricted actual member mapping to admins

parent 1eb802cd
...@@ -18,6 +18,16 @@ module Gitlab ...@@ -18,6 +18,16 @@ module Gitlab
@map = generate_map @map = generate_map
end end
def default_project_member
@default_project_member ||=
begin
return @project.project_members.first.user.id unless @project.project_members.empty?
default_member = ProjectMember.new(default_project_member_hash)
default_member.save!
default_member.user.id
end
end
private private
def generate_map def generate_map
...@@ -39,16 +49,6 @@ module Gitlab ...@@ -39,16 +49,6 @@ module Gitlab
member.except('id').merge(source_id: @project.id) member.except('id').merge(source_id: @project.id)
end end
def default_project_member
@default_project_member ||=
begin
return @project.project_members.first.user.id unless @project.project_members.empty?
default_member = ProjectMember.new(default_project_member_hash)
default_member.save!
default_member.user.id
end
end
def default_project_member_hash def default_project_member_hash
{ user: @user, access_level: ProjectMember::MASTER, source_id: @project.id } { user: @user, access_level: ProjectMember::MASTER, source_id: @project.id }
end end
......
...@@ -94,8 +94,10 @@ module Gitlab ...@@ -94,8 +94,10 @@ module Gitlab
end end
def relation_from_factory(relation, relation_hash) def relation_from_factory(relation, relation_hash)
Gitlab::ImportExport::RelationFactory.create( Gitlab::ImportExport::RelationFactory.create(relation_sym: relation.to_sym,
relation_sym: relation.to_sym, relation_hash: relation_hash.merge('project_id' => project.id), members_mapper: members_mapper) relation_hash: relation_hash.merge('project_id' => project.id),
members_mapper: members_mapper,
user_admin: @user.is_admin?)
end end
end end
end end
......
...@@ -6,11 +6,11 @@ module Gitlab ...@@ -6,11 +6,11 @@ module Gitlab
OVERRIDES = { snippets: :project_snippets, ci_commits: 'Ci::Commit', statuses: 'commit_status' }.freeze OVERRIDES = { snippets: :project_snippets, ci_commits: 'Ci::Commit', statuses: 'commit_status' }.freeze
USER_REFERENCES = %w(author_id assignee_id updated_by_id).freeze USER_REFERENCES = %w(author_id assignee_id updated_by_id).freeze
def create(relation_sym:, relation_hash:, members_mapper:) def create(relation_sym:, relation_hash:, members_mapper:, user_admin:)
relation_sym = parse_relation_sym(relation_sym) relation_sym = parse_relation_sym(relation_sym)
klass = parse_relation(relation_hash, relation_sym) klass = parse_relation(relation_hash, relation_sym)
update_missing_author(relation_hash, members_mapper) if relation_sym == :notes update_missing_author(relation_hash, members_mapper, user_admin) if relation_sym == :notes
update_user_references(relation_hash, members_mapper.map) update_user_references(relation_hash, members_mapper.map)
update_project_references(relation_hash, klass) update_project_references(relation_hash, klass)
...@@ -27,12 +27,19 @@ module Gitlab ...@@ -27,12 +27,19 @@ module Gitlab
end end
end end
def update_missing_author(relation_hash, members_map) def update_missing_author(relation_hash, members_map, user_admin)
old_author_id = relation_hash['author_id'] old_author_id = relation_hash['author_id']
# Users with admin access have access to mapping of users
if user_admin
relation_hash['author_id'] = members_map.default_project_member
else
relation_hash['author_id'] = members_map.map[old_author_id] relation_hash['author_id'] = members_map.map[old_author_id]
end
author = relation_hash.delete('author') author = relation_hash.delete('author')
return unless members_map.note_member_list.include?(old_author_id) return unless user_admin && members_map.note_member_list.include?(old_author_id)
relation_hash['note'] = ('*Blank note*') if relation_hash['note'].blank? relation_hash['note'] = ('*Blank note*') if relation_hash['note'].blank?
relation_hash['note'] += (missing_author_note(relation_hash['updated_at'], author['name'])) relation_hash['note'] += (missing_author_note(relation_hash['updated_at'], author['name']))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment