Skip to content

Commit

Permalink
Project Structure Suggestion (#18)
Browse files Browse the repository at this point in the history
* Adding Sample ClassLib Projects

* Sample Model Objects

* Add emoji comments

* Fix warnings
  • Loading branch information
benrick authored Nov 22, 2022
1 parent 112afac commit dc4c19f
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Smilodon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,13 +29,23 @@ 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
EndGlobalSection
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}
Expand Down
169 changes: 169 additions & 0 deletions src/ActivityPub.Domain/Accounts/Account.cs
Original file line number Diff line number Diff line change
@@ -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;
}

/// <summary>
/// The Account Id.
/// </summary>
public string Id { get; set; }

/// <summary>
/// The Username, not including domain.
/// </summary>
public string Username { get; set; }

/// <summary>
/// Same as Username for local, or Username@Domain for remote.
/// </summary>
public string AccountUri { get; set; }

/// <summary>
/// The location of the user’s profile page.
/// </summary>
public string Url { get; set; }

/// <summary>
/// The profile’s display name.
/// </summary>
public string DisplayName { get; set; }

/// <summary>
/// The profile’s bio or description (HTML).
/// </summary>
public string Note { get; set; }

/// <summary>
/// URL to the Avatar image for the account.
/// Shown on profile and next to posts.
/// </summary>
public string Avatar { get; set; }

/// <summary>
/// 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.
/// </summary>
public string AvatarStatic { get; set; }

/// <summary>
/// URL to a banner image shown above the profile.
/// </summary>
public string HeaderImage { get; set; }

/// <summary>
/// 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.
/// </summary>
public string HeaderStatic { get; set; }

/// <summary>
/// Whether the account manually approves follow requests.
/// </summary>
public bool IsLocked { get; set; }

/// <summary>
/// Additional metadata attached to a profile as name-value pairs.
/// </summary>
public ProfileField[] Fields { get; set; }

/// <summary>
/// Custom Emojis to be used when rendering the profile.
/// </summary>
public Emoji[] Emojis { get; set; }

/// <summary>
/// Indicates that the account may perform automated actions,
/// may not be monitored, or identifies as a robot.
/// </summary>
public bool IsBot { get; set; }

/// <summary>
/// Indicates that the account represents a Group actor.
/// </summary>
public bool IsGroup { get; set; }

/// <summary>
/// Whether the account has opted into discovery features
/// such as the profile directory.
/// </summary>
public bool? IsDiscoverable { get; set; }

/// <summary>
/// Indicates that the profile is currently inactive
/// and that its user has moved to a new account.
/// </summary>
public Account HasMovedTo { get; set; }

/// <summary>
/// An extra attribute returned only when an account is suspended.
/// </summary>
public bool? IsSuspended { get; set; }

/// <summary>
/// An extra attribute returned only when an account is silenced.
/// Indicates that the account should be hidden behind a warning screen.
/// </summary>
public bool IsLimited { get; set; }

/// <summary>
/// When the account was created.
/// </summary>
public DateTime CreatedAt { get; set; }

/// <summary>
/// When the most recent status was posted.
/// </summary>
public DateTime? LastStatusAt { get; set; }

/// <summary>
/// How many statuses are attached to this account.
/// </summary>
public int StatusCount { get; set; }

/// <summary>
/// The reported followers of this profile.
/// </summary>
public int FollowerCount { get; set; }

/// <summary>
/// The reported follows of this profile.
/// </summary>
public int FollowingCount { get; set; }
}
28 changes: 28 additions & 0 deletions src/ActivityPub.Domain/Accounts/ProfileField.cs
Original file line number Diff line number Diff line change
@@ -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;
}

/// <summary>
/// The key of a given field’s key-value pair.
/// </summary>
public string Name { get; set; }

/// <summary>
/// The value associated with the name key. Can have HTML.
/// </summary>
public string Value { get; set; }

/// <summary>
/// Timestamp of when the server verified a URL value for a rel=“me” link.
/// Null means not verified.
/// </summary>
public DateTime? VerifiedAt { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/ActivityPub.Domain/ActivityPub.Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
39 changes: 39 additions & 0 deletions src/ActivityPub.Domain/Emojis/Emoji.cs
Original file line number Diff line number Diff line change
@@ -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;
}

/// <summary>
/// The name of the custom Emoji.
/// </summary>
public string ShortCode { get; set; }

/// <summary>
/// URL to the custom Emoji image.
/// </summary>
public string Url { get; set; }

/// <summary>
/// URL to the static version of the custom Emoji.
/// </summary>
public string StaticUrl { get; set; }

/// <summary>
/// Whether this Emoji should be visible in the picker or unlisted.
/// </summary>
public bool IsVisibleInPicker { get; set; }

/// <summary>
/// Used for grouping custom emojis.
/// </summary>
public string Category { get; set; }
}
10 changes: 10 additions & 0 deletions src/Infrastructure.Database/Infrastructure.Database.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>

0 comments on commit dc4c19f

Please sign in to comment.