using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using decePubClient.Models.Types;
using decePubClient.Resources;
namespace decePubClient.Models;
///
/// A new post or reply. It goes through the Mastodon API (plain text, a content warning, a visibility and media) unless
/// it is located (text only, kept within RangeKm of where it was written, never federated) or meant for a group; those
/// go through /clientapi/post/insert.
///
public class ComposeForm
{
public const int MaxContentLength = 5_000;
/// The status a reply answers.
public string InReplyToId { get; set; }
/// The community or circle the post is for.
public string GroupId { get; set; }
[Required(ErrorMessageResourceName = ValidationNames.Required, ErrorMessageResourceType = typeof(ErrorMessages))]
public MessageType MessageType { get; set; } = MessageType.Public;
public bool HasContentWarning { get; set; }
[StringLength(500, ErrorMessageResourceName = ValidationNames.MaxLength, ErrorMessageResourceType = typeof(ErrorMessages))]
public string SpoilerText { get; set; }
[StringLength(MaxContentLength, ErrorMessageResourceName = ValidationNames.MaxLength, ErrorMessageResourceType = typeof(ErrorMessages))]
public string Content { get; set; }
public List Media { get; set; } = [];
/// A located post: shown only to readers within RangeKm of Latitude/Longitude.
public bool IsLocated { get; set; }
[Range(1, 50)]
public double RangeKm { get; set; } = 5;
public double? Latitude { get; set; }
public double? Longitude { get; set; }
[JsonIgnore, Bindable(false)]
public MediaType MediaType { get; set; } = MediaType.Images;
[JsonIgnore, Bindable(false)]
public bool IsScopeOptionsOpen { get; set; }
/// The Mastodon visibility of MessageType.
public string Visibility => MessageType switch
{
MessageType.Direct => "direct",
MessageType.FollowersOnly => "private",
MessageType.Unlisted => "unlisted",
_ => "public"
};
}