mirror of
https://github.com/bitwarden/server.git
synced 2025-07-13 13:47:30 -05:00
[PM-14380] Add GET /tasks/organization endpoint (#5149)
* [PM-14380] Add GetManyByOrganizationIdStatusAsync to SecurityTaskRepository * [PM-14380] Introduce IGetTasksForOrganizationQuery * [PM-14380] Add /tasks/organization endpoint * [PM-14380] Add unit tests * [PM-14380] Formatting * [PM-14380] Bump migration script date * [PM-14380] Bump migration script date
This commit is contained in:
@ -25,4 +25,31 @@ public class SecurityTaskRepository : Repository<Core.Vault.Entities.SecurityTas
|
||||
var data = await query.Run(dbContext).ToListAsync();
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ICollection<Core.Vault.Entities.SecurityTask>> GetManyByOrganizationIdStatusAsync(Guid organizationId,
|
||||
SecurityTaskStatus? status = null)
|
||||
{
|
||||
using var scope = ServiceScopeFactory.CreateScope();
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var query = from st in dbContext.SecurityTasks
|
||||
join o in dbContext.Organizations
|
||||
on st.OrganizationId equals o.Id
|
||||
where
|
||||
o.Enabled &&
|
||||
st.OrganizationId == organizationId &&
|
||||
(status == null || st.Status == status)
|
||||
select new Core.Vault.Entities.SecurityTask
|
||||
{
|
||||
Id = st.Id,
|
||||
OrganizationId = st.OrganizationId,
|
||||
CipherId = st.CipherId,
|
||||
Status = st.Status,
|
||||
Type = st.Type,
|
||||
CreationDate = st.CreationDate,
|
||||
RevisionDate = st.RevisionDate,
|
||||
};
|
||||
|
||||
return await query.OrderByDescending(st => st.CreationDate).ToListAsync();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user