Iceshrimp.NET/Iceshrimp.Backend/Core/Database/Tables/OauthToken.cs

75 lines
No EOL
2.1 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Iceshrimp.Backend.Core.Database.Tables;
[Table("oauth_token")]
[Index(nameof(Token))]
[Index(nameof(Code))]
public class OauthToken
{
[Key]
[Column("id")]
[StringLength(32)]
public string Id { get; set; } = null!;
/// <summary>
/// The created date of the OAuth token
/// </summary>
[Column("createdAt")]
public DateTime CreatedAt { get; set; }
[Column("appId")] [StringLength(32)] public string AppId { get; set; } = null!;
[Column("userId")] [StringLength(32)] public string UserId { get; set; } = null!;
/// <summary>
/// The auth code for the OAuth token
/// </summary>
[Column("code")]
[StringLength(64)]
public string Code { get; set; } = null!;
/// <summary>
/// The OAuth token
/// </summary>
[Column("token")]
[StringLength(64)]
public string Token { get; set; } = null!;
/// <summary>
/// Whether or not the token has been activated
/// </summary>
[Column("active")]
public bool Active { get; set; }
/// <summary>
/// The scopes requested by the OAuth token
/// </summary>
[Column("scopes", TypeName = "character varying(64)[]")]
public List<string> Scopes { get; set; } = null!;
/// <summary>
/// The redirect URI of the OAuth token
/// </summary>
[Column("redirectUri")]
[StringLength(512)]
public string RedirectUri { get; set; } = null!;
[ForeignKey(nameof(AppId))]
[InverseProperty(nameof(OauthApp.OauthTokens))]
public virtual OauthApp App { get; set; } = null!;
[ForeignKey(nameof(UserId))]
[InverseProperty(nameof(Tables.User.OauthTokens))]
public virtual User User { get; set; } = null!;
[InverseProperty(nameof(Tables.PushSubscription.OauthToken))]
public virtual PushSubscription? PushSubscription { get; set; }
[Column("supportsHtmlFormatting")] public bool SupportsHtmlFormatting { get; set; }
[Column("autoDetectQuotes")] public bool AutoDetectQuotes { get; set; }
[Column("lastActiveDate")] public DateTime? LastActiveDate { get; set; }
}