mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[PM-16812] Shortcut duplicate group patch requests (#5354)
* Copy PatchGroupCommand to vNext and refactor * Detect duplicate add requests and return early * Update read repository method to use HA replica * Add new write repository method
This commit is contained in:
39
util/Migrator/DbScripts/2025-02-13_00_GroupUser_AddUsers.sql
Normal file
39
util/Migrator/DbScripts/2025-02-13_00_GroupUser_AddUsers.sql
Normal file
@ -0,0 +1,39 @@
|
||||
CREATE OR ALTER PROCEDURE [dbo].[GroupUser_AddUsers]
|
||||
@GroupId UNIQUEIDENTIFIER,
|
||||
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @OrgId UNIQUEIDENTIFIER = (
|
||||
SELECT TOP 1
|
||||
[OrganizationId]
|
||||
FROM
|
||||
[dbo].[Group]
|
||||
WHERE
|
||||
[Id] = @GroupId
|
||||
)
|
||||
|
||||
-- Insert
|
||||
INSERT INTO
|
||||
[dbo].[GroupUser] (GroupId, OrganizationUserId)
|
||||
SELECT DISTINCT
|
||||
@GroupId,
|
||||
[Source].[Id]
|
||||
FROM
|
||||
@OrganizationUserIds AS [Source]
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON [Source].[Id] = OU.[Id] AND OU.[OrganizationId] = @OrgId
|
||||
WHERE
|
||||
NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
[dbo].[GroupUser]
|
||||
WHERE
|
||||
[GroupId] = @GroupId
|
||||
AND [OrganizationUserId] = [Source].[Id]
|
||||
)
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @OrgId
|
||||
END
|
Reference in New Issue
Block a user