1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

PM-10600: Sending to specific client types for relay push notifications

This commit is contained in:
Maciej Zieniuk
2024-10-22 10:29:11 +01:00
parent 3a604af0a4
commit 7020565770
3 changed files with 49 additions and 23 deletions

View File

@ -1,22 +1,23 @@
using System.ComponentModel.DataAnnotations;
#nullable enable
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
namespace Bit.Core.Models.Api;
public class PushSendRequestModel : IValidatableObject
{
public string UserId { get; set; }
public string OrganizationId { get; set; }
public string DeviceId { get; set; }
public string Identifier { get; set; }
[Required]
public PushType? Type { get; set; }
[Required]
public object Payload { get; set; }
public string? UserId { get; set; }
public string? OrganizationId { get; set; }
public string? DeviceId { get; set; }
public string? Identifier { get; set; }
[Required] public PushType Type { get; set; }
[Required] public object Payload { get; set; } = null!;
public bool Global { get; set; }
public ClientType? ClientType { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (string.IsNullOrWhiteSpace(UserId) && string.IsNullOrWhiteSpace(OrganizationId))
if (string.IsNullOrWhiteSpace(UserId) && string.IsNullOrWhiteSpace(OrganizationId) && !Global)
{
yield return new ValidationResult($"{nameof(UserId)} or {nameof(OrganizationId)} is required.");
}