From dc4c19ff9eeb32ff882d7e96cc45d14b31e0bbf4 Mon Sep 17 00:00:00 2001
From: Brendan Enrick <2243498+benrick@users.noreply.github.com>
Date: Tue, 22 Nov 2022 11:25:28 -0500
Subject: [PATCH] Project Structure Suggestion (#18)
* Adding Sample ClassLib Projects
* Sample Model Objects
* Add emoji comments
* Fix warnings
---
Smilodon.sln | 16 +-
src/ActivityPub.Domain/Accounts/Account.cs | 169 ++++++++++++++++++
.../Accounts/ProfileField.cs | 28 +++
.../ActivityPub.Domain.csproj | 10 ++
src/ActivityPub.Domain/Emojis/Emoji.cs | 39 ++++
.../Infrastructure.Database.csproj | 10 ++
6 files changed, 271 insertions(+), 1 deletion(-)
create mode 100644 src/ActivityPub.Domain/Accounts/Account.cs
create mode 100644 src/ActivityPub.Domain/Accounts/ProfileField.cs
create mode 100644 src/ActivityPub.Domain/ActivityPub.Domain.csproj
create mode 100644 src/ActivityPub.Domain/Emojis/Emoji.cs
create mode 100644 src/Infrastructure.Database/Infrastructure.Database.csproj
diff --git a/Smilodon.sln b/Smilodon.sln
index f457f9c..5ba0a86 100644
--- a/Smilodon.sln
+++ b/Smilodon.sln
@@ -9,7 +9,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{74FC9674-053
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9EC4E573-048F-40B7-8721-E28857532DF0}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApp.Test", "test\WebApp.Test\WebApp.Test.csproj", "{972B3171-DDE1-4CF8-863E-B45875440A80}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp.Test", "test\WebApp.Test\WebApp.Test.csproj", "{972B3171-DDE1-4CF8-863E-B45875440A80}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure.Database", "src\Infrastructure.Database\Infrastructure.Database.csproj", "{5D89CB6E-02DA-483F-B0CA-03E235EA795B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActivityPub.Domain", "src\ActivityPub.Domain\ActivityPub.Domain.csproj", "{5538990A-29DE-448B-A5F3-30266AA66C17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -25,6 +29,14 @@ Global
{972B3171-DDE1-4CF8-863E-B45875440A80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{972B3171-DDE1-4CF8-863E-B45875440A80}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D89CB6E-02DA-483F-B0CA-03E235EA795B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D89CB6E-02DA-483F-B0CA-03E235EA795B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D89CB6E-02DA-483F-B0CA-03E235EA795B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D89CB6E-02DA-483F-B0CA-03E235EA795B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5538990A-29DE-448B-A5F3-30266AA66C17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5538990A-29DE-448B-A5F3-30266AA66C17}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5538990A-29DE-448B-A5F3-30266AA66C17}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5538990A-29DE-448B-A5F3-30266AA66C17}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -32,6 +44,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{EF2B2EA7-D380-46EA-A2CE-D7C9D22B18FA} = {74FC9674-053B-480C-84AC-F6AAF8B82239}
{972B3171-DDE1-4CF8-863E-B45875440A80} = {9EC4E573-048F-40B7-8721-E28857532DF0}
+ {5D89CB6E-02DA-483F-B0CA-03E235EA795B} = {74FC9674-053B-480C-84AC-F6AAF8B82239}
+ {5538990A-29DE-448B-A5F3-30266AA66C17} = {74FC9674-053B-480C-84AC-F6AAF8B82239}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B464DC23-8514-4B57-BA12-524A7C3994FA}
diff --git a/src/ActivityPub.Domain/Accounts/Account.cs b/src/ActivityPub.Domain/Accounts/Account.cs
new file mode 100644
index 0000000..aeca9f7
--- /dev/null
+++ b/src/ActivityPub.Domain/Accounts/Account.cs
@@ -0,0 +1,169 @@
+using ActivityPub.Domain.Emojis;
+
+namespace ActivityPub.Domain.Accounts;
+
+public class Account
+{
+ public Account(string id, string username, string accountUri,
+ string url, string displayName, string note, string avatar,
+ string avatarStatic, string headerImage, string headerStatic,
+ bool isLocked, ProfileField[] fields, Emoji[] emojis, bool isBot,
+ bool isGroup, bool? isDiscoverable, Account hasMovedTo, bool? isSuspended,
+ bool isLimited, DateTime createdAt, DateTime? lastStatusAt,
+ int statusCount, int followerCount, int followingCount)
+ {
+ Id = id;
+ Username = username;
+ AccountUri = accountUri;
+ Url = url;
+ DisplayName = displayName;
+ Note = note;
+ Avatar = avatar;
+ AvatarStatic = avatarStatic;
+ HeaderImage = headerImage;
+ HeaderStatic = headerStatic;
+ IsLocked = isLocked;
+ Fields = fields;
+ Emojis = emojis;
+ IsBot = isBot;
+ IsGroup = isGroup;
+ IsDiscoverable = isDiscoverable;
+ HasMovedTo = hasMovedTo;
+ IsSuspended = isSuspended;
+ IsLimited = isLimited;
+ CreatedAt = createdAt;
+ LastStatusAt = lastStatusAt;
+ StatusCount = statusCount;
+ FollowerCount = followerCount;
+ FollowingCount = followingCount;
+ }
+
+ ///
+ /// The Account Id.
+ ///
+ public string Id { get; set; }
+
+ ///
+ /// The Username, not including domain.
+ ///
+ public string Username { get; set; }
+
+ ///
+ /// Same as Username for local, or Username@Domain for remote.
+ ///
+ public string AccountUri { get; set; }
+
+ ///
+ /// The location of the user’s profile page.
+ ///
+ public string Url { get; set; }
+
+ ///
+ /// The profile’s display name.
+ ///
+ public string DisplayName { get; set; }
+
+ ///
+ /// The profile’s bio or description (HTML).
+ ///
+ public string Note { get; set; }
+
+ ///
+ /// URL to the Avatar image for the account.
+ /// Shown on profile and next to posts.
+ ///
+ public string Avatar { get; set; }
+
+ ///
+ /// URL to a static version of the Avatar.
+ /// Equal to Avatar if its value is a static image;
+ /// different if Avatar is an animated GIF.
+ ///
+ public string AvatarStatic { get; set; }
+
+ ///
+ /// URL to a banner image shown above the profile.
+ ///
+ public string HeaderImage { get; set; }
+
+ ///
+ /// URL to a static version of the Header.
+ /// Equal to Header if its value is a static image;
+ /// different if Header is an animated GIF.
+ ///
+ public string HeaderStatic { get; set; }
+
+ ///
+ /// Whether the account manually approves follow requests.
+ ///
+ public bool IsLocked { get; set; }
+
+ ///
+ /// Additional metadata attached to a profile as name-value pairs.
+ ///
+ public ProfileField[] Fields { get; set; }
+
+ ///
+ /// Custom Emojis to be used when rendering the profile.
+ ///
+ public Emoji[] Emojis { get; set; }
+
+ ///
+ /// Indicates that the account may perform automated actions,
+ /// may not be monitored, or identifies as a robot.
+ ///
+ public bool IsBot { get; set; }
+
+ ///
+ /// Indicates that the account represents a Group actor.
+ ///
+ public bool IsGroup { get; set; }
+
+ ///
+ /// Whether the account has opted into discovery features
+ /// such as the profile directory.
+ ///
+ public bool? IsDiscoverable { get; set; }
+
+ ///
+ /// Indicates that the profile is currently inactive
+ /// and that its user has moved to a new account.
+ ///
+ public Account HasMovedTo { get; set; }
+
+ ///
+ /// An extra attribute returned only when an account is suspended.
+ ///
+ public bool? IsSuspended { get; set; }
+
+ ///
+ /// An extra attribute returned only when an account is silenced.
+ /// Indicates that the account should be hidden behind a warning screen.
+ ///
+ public bool IsLimited { get; set; }
+
+ ///
+ /// When the account was created.
+ ///
+ public DateTime CreatedAt { get; set; }
+
+ ///
+ /// When the most recent status was posted.
+ ///
+ public DateTime? LastStatusAt { get; set; }
+
+ ///
+ /// How many statuses are attached to this account.
+ ///
+ public int StatusCount { get; set; }
+
+ ///
+ /// The reported followers of this profile.
+ ///
+ public int FollowerCount { get; set; }
+
+ ///
+ /// The reported follows of this profile.
+ ///
+ public int FollowingCount { get; set; }
+}
diff --git a/src/ActivityPub.Domain/Accounts/ProfileField.cs b/src/ActivityPub.Domain/Accounts/ProfileField.cs
new file mode 100644
index 0000000..3d459e9
--- /dev/null
+++ b/src/ActivityPub.Domain/Accounts/ProfileField.cs
@@ -0,0 +1,28 @@
+namespace ActivityPub.Domain.Accounts
+{
+ public class ProfileField
+ {
+ public ProfileField(string name, string value, DateTime? verifiedAt)
+ {
+ Name = name;
+ Value = value;
+ VerifiedAt = verifiedAt;
+ }
+
+ ///
+ /// The key of a given field’s key-value pair.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// The value associated with the name key. Can have HTML.
+ ///
+ public string Value { get; set; }
+
+ ///
+ /// Timestamp of when the server verified a URL value for a rel=“me” link.
+ /// Null means not verified.
+ ///
+ public DateTime? VerifiedAt { get; set; }
+ }
+}
diff --git a/src/ActivityPub.Domain/ActivityPub.Domain.csproj b/src/ActivityPub.Domain/ActivityPub.Domain.csproj
new file mode 100644
index 0000000..4cb84ae
--- /dev/null
+++ b/src/ActivityPub.Domain/ActivityPub.Domain.csproj
@@ -0,0 +1,10 @@
+
+
+
+ net7.0
+ enable
+ enable
+ true
+
+
+
diff --git a/src/ActivityPub.Domain/Emojis/Emoji.cs b/src/ActivityPub.Domain/Emojis/Emoji.cs
new file mode 100644
index 0000000..96d34e6
--- /dev/null
+++ b/src/ActivityPub.Domain/Emojis/Emoji.cs
@@ -0,0 +1,39 @@
+namespace ActivityPub.Domain.Emojis;
+
+public class Emoji
+{
+ public Emoji(string shortCode, string url, string staticUrl,
+ bool isVisibleInPicker, string category)
+ {
+ ShortCode = shortCode;
+ Url = url;
+ StaticUrl = staticUrl;
+ IsVisibleInPicker = isVisibleInPicker;
+ Category = category;
+ }
+
+ ///
+ /// The name of the custom Emoji.
+ ///
+ public string ShortCode { get; set; }
+
+ ///
+ /// URL to the custom Emoji image.
+ ///
+ public string Url { get; set; }
+
+ ///
+ /// URL to the static version of the custom Emoji.
+ ///
+ public string StaticUrl { get; set; }
+
+ ///
+ /// Whether this Emoji should be visible in the picker or unlisted.
+ ///
+ public bool IsVisibleInPicker { get; set; }
+
+ ///
+ /// Used for grouping custom emojis.
+ ///
+ public string Category { get; set; }
+}
diff --git a/src/Infrastructure.Database/Infrastructure.Database.csproj b/src/Infrastructure.Database/Infrastructure.Database.csproj
new file mode 100644
index 0000000..4cb84ae
--- /dev/null
+++ b/src/Infrastructure.Database/Infrastructure.Database.csproj
@@ -0,0 +1,10 @@
+
+
+
+ net7.0
+ enable
+ enable
+ true
+
+
+