2023-06-01 00:03:23 -04:00
|
|
|
namespace vassago.Models;
|
|
|
|
|
2023-05-23 19:03:58 -04:00
|
|
|
using System;
|
2023-06-01 00:03:23 -04:00
|
|
|
using System.Collections.Generic;
|
2023-06-05 14:55:48 -04:00
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
using System.Reflection;
|
2023-06-01 00:03:23 -04:00
|
|
|
using System.Threading.Tasks;
|
2024-04-05 23:59:39 -04:00
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
2023-12-03 14:33:58 -05:00
|
|
|
using static vassago.Models.Enumerations;
|
2023-05-23 19:03:58 -04:00
|
|
|
|
2023-06-01 00:03:23 -04:00
|
|
|
public class Channel
|
2023-05-23 19:03:58 -04:00
|
|
|
{
|
2023-06-05 14:55:48 -04:00
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
2023-06-01 00:03:23 -04:00
|
|
|
public Guid Id { get; set; }
|
2023-07-04 12:58:21 -04:00
|
|
|
public string ExternalId { get; set; }
|
2023-06-01 00:03:23 -04:00
|
|
|
public string DisplayName { get; set; }
|
2023-06-05 14:55:48 -04:00
|
|
|
public List<Channel> SubChannels { get; set; }
|
2023-06-01 00:03:23 -04:00
|
|
|
public Channel ParentChannel { get; set; }
|
2023-06-05 14:55:48 -04:00
|
|
|
public string Protocol { get; set; }
|
2023-06-15 23:29:07 -04:00
|
|
|
public List<Message> Messages { get; set; }
|
2023-06-19 12:56:40 -04:00
|
|
|
public List<Account> Users { get; set; }
|
2024-01-05 21:39:31 -05:00
|
|
|
public ChannelType ChannelType {get; set; }
|
2023-06-01 00:03:23 -04:00
|
|
|
|
2024-04-05 23:59:39 -04:00
|
|
|
//Permissions
|
|
|
|
public ulong? MaxAttachmentBytes { get; set; }
|
|
|
|
public uint? MaxTextChars { get; set; }
|
|
|
|
public bool? LinksAllowed { get; set; }
|
|
|
|
public bool? ReactionsPossible { get; set; }
|
|
|
|
public Enumerations.LewdnessFilterLevel? LewdnessFilterLevel { get; set; }
|
|
|
|
public Enumerations.MeannessFilterLevel? MeannessFilterLevel { get; set; }
|
|
|
|
|
2023-06-05 14:55:48 -04:00
|
|
|
[NonSerialized]
|
|
|
|
public Func<string, string, Task> SendFile;
|
|
|
|
|
|
|
|
[NonSerialized]
|
|
|
|
public Func<string, Task> SendMessage;
|
2023-06-19 11:03:06 -04:00
|
|
|
|
|
|
|
|
2023-07-04 13:31:19 -04:00
|
|
|
public DefinitePermissionSettings EffectivePermissions
|
2023-06-19 11:03:06 -04:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2024-04-05 23:59:39 -04:00
|
|
|
var path = new Stack<Channel>(); //omg i actually get to use a data structure from university
|
|
|
|
var walker = this;
|
|
|
|
path.Push(this);
|
|
|
|
while(walker.ParentChannel != null)
|
|
|
|
{
|
|
|
|
walker = walker.ParentChannel;
|
|
|
|
path.Push(walker);
|
|
|
|
}
|
|
|
|
DefinitePermissionSettings toReturn = new DefinitePermissionSettings();
|
2024-05-10 17:07:50 -04:00
|
|
|
|
|
|
|
while(path.Count > 0)
|
2024-04-05 23:59:39 -04:00
|
|
|
{
|
|
|
|
walker = path.Pop();
|
2024-05-10 17:07:50 -04:00
|
|
|
toReturn.LewdnessFilterLevel = walker.LewdnessFilterLevel ?? toReturn.LewdnessFilterLevel;
|
|
|
|
toReturn.MeannessFilterLevel = walker.MeannessFilterLevel ?? toReturn.MeannessFilterLevel;
|
|
|
|
toReturn.LinksAllowed = walker.LinksAllowed ?? toReturn.LinksAllowed;
|
|
|
|
toReturn.MaxAttachmentBytes = walker.MaxAttachmentBytes ?? toReturn.MaxAttachmentBytes;
|
|
|
|
toReturn.MaxTextChars = walker.MaxTextChars ?? toReturn.MaxTextChars;
|
|
|
|
toReturn.ReactionsPossible = walker.ReactionsPossible ?? toReturn.ReactionsPossible;
|
2024-04-05 23:59:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return toReturn;
|
2023-06-19 11:03:06 -04:00
|
|
|
}
|
|
|
|
}
|
2023-12-03 14:33:58 -05:00
|
|
|
public string LineageSummary
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if(this.ParentChannel != null)
|
|
|
|
{
|
|
|
|
return this.ParentChannel.LineageSummary + '/' + this.DisplayName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.Protocol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-05 23:59:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public class DefinitePermissionSettings
|
|
|
|
{
|
|
|
|
public ulong MaxAttachmentBytes { get; set; }
|
|
|
|
public uint MaxTextChars { get; set; }
|
|
|
|
public bool LinksAllowed { get; set; }
|
|
|
|
public bool ReactionsPossible { get; set; }
|
|
|
|
public Enumerations.LewdnessFilterLevel LewdnessFilterLevel { get; set; }
|
|
|
|
public Enumerations.MeannessFilterLevel MeannessFilterLevel { get; set; }
|
2023-06-05 14:55:48 -04:00
|
|
|
}
|