Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
dc58f100
Unverified
Commit
dc58f100
authored
2 years ago
by
Khemissi Amir
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
V3 Migrations: Optimized `Migrations::ExternalController::create_room` API. (#4737)
parent
83b08111
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/api/v1/migrations/external_controller.rb
+27
-14
27 additions, 14 deletions
app/controllers/api/v1/migrations/external_controller.rb
with
27 additions
and
14 deletions
app/controllers/api/v1/migrations/external_controller.rb
+
27
−
14
View file @
dc58f100
# frozen_string_literal: true
# frozen_string_literal: true
# rubocop:disable Metrics/PerceivedComplexity
module
Api
module
Api
module
V1
module
V1
module
Migrations
module
Migrations
...
@@ -102,22 +104,31 @@ module Api
...
@@ -102,22 +104,31 @@ module Api
return
render_error
(
status: :bad_request
,
errors:
room
&
.
errors
&
.
to_a
)
unless
room
.
save
return
render_error
(
status: :bad_request
,
errors:
room
&
.
errors
&
.
to_a
)
unless
room
.
save
if
room_hash
[
:room_settings
].
any?
# Finds all the RoomMeetingOptions that need to be updated
# Finds all the RoomMeetingOptions that need to be updated
room_meeting_options_
temp
=
RoomMeetingOption
.
includes
(
:meeting_option
)
room_meeting_options_
joined
=
RoomMeetingOption
.
includes
(
:meeting_option
)
.
where
(
room_id:
room
.
id
,
'meeting_options.name'
:
room_hash
[
:room_settings
].
keys
)
.
where
(
room_id:
room
.
id
,
'meeting_options.name'
:
room_hash
[
:room_settings
].
keys
)
.
pluck
(
:id
,
:'meeting_options.name'
)
.
to_h
okay
=
true
# Re-structure the data so it is in the format: { <room_meeting_option_id>: { value: <room_meeting_option_new_value> } }
room_meeting_options_joined
.
each
do
|
room_meeting_option
|
room_meeting_options
=
room_meeting_options_temp
.
transform_values
{
|
v
|
{
value:
room_hash
[
:room_settings
][
v
.
to_sym
]
}
}
option_name
=
room_meeting_option
.
meeting_option
.
name
RoomMeetingOption
.
update!
(
room_meeting_options
.
keys
,
room_meeting_options
.
values
)
okay
=
false
unless
room_meeting_option
.
update
(
value:
room_hash
[
:room_settings
][
option_name
])
end
return
render_error
status: :bad_request
,
errors:
'Something went wrong when migrating the room settings.'
unless
okay
end
return
render_data
status: :created
unless
room_hash
[
:shared_users_emails
].
any?
return
render_data
status: :created
unless
room_hash
[
:shared_users_emails
].
any?
# Finds all the users that have a SharedAccess to the Room
# Finds all the users that have a SharedAccess to the Room
users_ids
=
User
.
where
(
email:
room_hash
[
:shared_users_emails
]).
pluck
(
:id
)
shared_with_users
=
User
.
where
(
email:
room_hash
[
:shared_users_emails
])
# Re-structure the data so it is in the format: { { room_id:, user_id: } }
shared_accesses
=
users_ids
.
map
{
|
user_id
|
{
room_id:
room
.
id
,
user_id:
}
}
okay
=
true
SharedAccess
.
create!
(
shared_accesses
)
shared_with_users
.
each
do
|
shared_with_user
|
okay
=
false
unless
SharedAccess
.
new
(
room_id:
room
.
id
,
user_id:
shared_with_user
.
id
).
save
end
return
render_error
status: :bad_request
,
errors:
'Something went wrong when sharing the room.'
unless
okay
render_data
status: :created
render_data
status: :created
end
end
...
@@ -172,8 +183,9 @@ module Api
...
@@ -172,8 +183,9 @@ module Api
end
end
def
room_params
def
room_params
decrypted_params
.
require
(
:room
).
permit
(
:name
,
:friendly_id
,
:meeting_id
,
:last_session
,
:owner_email
,
room_settings:
{},
decrypted_params
.
require
(
:room
).
permit
(
:name
,
:friendly_id
,
:meeting_id
,
:last_session
,
:owner_email
,
shared_users_emails:
[])
shared_users_emails:
[],
room_settings:
%w[record muteOnStart guestPolicy glAnyoneCanStart glAnyoneJoinAsModerator]
)
end
end
def
settings_params
def
settings_params
...
@@ -208,3 +220,4 @@ module Api
...
@@ -208,3 +220,4 @@ module Api
end
end
end
end
end
end
# rubocop:enable Metrics/PerceivedComplexity
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment