mirror of
https://github.com/bitwarden/server.git
synced 2024-11-24 12:35:25 +01:00
31 lines
765 B
Transact-SQL
31 lines
765 B
Transact-SQL
IF OBJECT_ID('[dbo].[EmergencyAccess_ReadToNotify]') IS NOT NULL
|
|
BEGIN
|
|
DROP PROCEDURE [dbo].[EmergencyAccess_ReadToNotify]
|
|
END
|
|
GO
|
|
|
|
CREATE PROCEDURE [dbo].[EmergencyAccess_ReadToNotify]
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
SELECT
|
|
EA.*,
|
|
Grantee.Name as GranteeName,
|
|
Grantee.Email as GranteeEmail,
|
|
Grantor.Email as GrantorEmail
|
|
FROM
|
|
[dbo].[EmergencyAccess] EA
|
|
LEFT JOIN
|
|
[dbo].[User] Grantor ON Grantor.[Id] = EA.[GrantorId]
|
|
LEFT JOIN
|
|
[dbo].[User] Grantee On Grantee.[Id] = EA.[GranteeId]
|
|
WHERE
|
|
EA.[Status] = 3
|
|
AND
|
|
DATEADD(DAY, EA.[WaitTimeDays] - 1, EA.[RecoveryInitiatedDate]) <= GETUTCDATE()
|
|
AND
|
|
DATEADD(DAY, 1, EA.[LastNotificationDate]) <= GETUTCDATE()
|
|
END
|
|
GO
|