Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend implementation of mentions #226

Merged
merged 46 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
eda44c4
feat(`Core`): add `MentionTargets.cs`
JonasMuehlmann Jul 6, 2021
136c17e
feat(`MentionTargets`): add target `message` and replace `team` with …
JonasMuehlmann Jul 6, 2021
1672f72
feat(`MentionService`): add method to create mention
JonasMuehlmann Jul 6, 2021
a5d60ae
feat(`MentionService`): add method to remove mention
JonasMuehlmann Jul 6, 2021
9c1cb01
fix: provide proper mechanism to use production/test DB
JonasMuehlmann Jul 1, 2021
1513b2d
fix(`MentionService`): fix syntax error in SQL query
JonasMuehlmann Jul 6, 2021
aa23ed2
test(`MentionService`): add basic tests for create and remove
JonasMuehlmann Jul 6, 2021
7832302
feat(`MentionService`): add method to retrieve mentions
JonasMuehlmann Jul 6, 2021
cfccc3c
feat(`Mapper`): Add mapper for `Mention`
JonasMuehlmann Jul 6, 2021
f64668f
feat(`Model`): add model for `mention`
JonasMuehlmann Jul 6, 2021
fd9b5c9
fix(`Mapper`): fix mapper for `mention`
JonasMuehlmann Jul 6, 2021
7050487
feat(`MentionService`): partial implementation of method to resolve m…
JonasMuehlmann Jul 6, 2021
051b883
fix(`MentionServiceTest`): fix missing initialization of `mentionServ…
JonasMuehlmann Jul 6, 2021
8f0af2f
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 8, 2021
f5806e1
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 8, 2021
57f8c3a
fix(`MessageService`): fix merge error in `RetrieveMessage()`
JonasMuehlmann Jul 12, 2021
7a8a634
fix: fix merge error in test files
JonasMuehlmann Jul 12, 2021
68139e2
feat(`TeamService`): add method to retrieve single role from id
JonasMuehlmann Jul 12, 2021
78126be
feat(`MentionService`): extend `ResolveMentions()`
JonasMuehlmann Jul 12, 2021
de5f1c2
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 13, 2021
c86f9d8
Merge branch 'mentions' of https://github.com/JonasMuehlmann/BIB_VPR …
JonasMuehlmann Jul 13, 2021
b9c20a3
feat(`Models`): add `Mentionable` model
JonasMuehlmann Jul 13, 2021
a2cc98c
feat(`Mapper`): add mapper for `Mentionable`
JonasMuehlmann Jul 13, 2021
1e26e4f
feat(`MentionSerbice`): add method to search mentionables
JonasMuehlmann Jul 13, 2021
f28af55
feat(`MentionSerbice`): add method to search users
JonasMuehlmann Jul 13, 2021
888227a
feat(`MentionSerbice`): add method to search roles
JonasMuehlmann Jul 13, 2021
af3f821
feat(`MentionSerbice`): add method to search channels
JonasMuehlmann Jul 13, 2021
8104195
feat(`MentionSerbice`): add method to search messages
JonasMuehlmann Jul 13, 2021
7cdc4a2
fix(`MentionService`): fix syntax errors
JonasMuehlmann Jul 13, 2021
e03c735
!fix(`MentionService`): filter search for mentionables by team with n…
JonasMuehlmann Jul 14, 2021
9289a66
refactor(`MentionService`): make all methods static
JonasMuehlmann Jul 14, 2021
69d4a78
test(`MentionService`): add more tests for `ResolveMentions()`
JonasMuehlmann Jul 14, 2021
c75cf27
Merge remote-tracking branch 'origin' into mentions
JonasMuehlmann Jul 14, 2021
c9b9331
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 14, 2021
518bba6
fix(`MentionService`): fix use of `this` in logging code
JonasMuehlmann Jul 14, 2021
4d4e556
fix(`MentionService`): fix regex and add logging to `ResolveMentions()`
JonasMuehlmann Jul 14, 2021
270213c
fix(`MentionService`): fix some errors in queries used for searching …
JonasMuehlmann Jul 15, 2021
6907185
fix(`MentionService`): add missing `else` branch in `SearchMentionabl…
JonasMuehlmann Jul 15, 2021
3980605
fix(`MentionService`): fix some errors in queries used for searching …
JonasMuehlmann Jul 15, 2021
7c7ef03
test(`MentionService`): add test for searching users
JonasMuehlmann Jul 15, 2021
9237bcf
test(`MentionService`): add test for searching roles
JonasMuehlmann Jul 15, 2021
4ca3200
test(`MentionService`): add test for searching channels
JonasMuehlmann Jul 15, 2021
695dea5
test(`MentionService`): add test for searching messages
JonasMuehlmann Jul 15, 2021
fccd580
fix(`MentionService`): fix some errors in queries used for searching …
JonasMuehlmann Jul 15, 2021
66f3378
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 16, 2021
f213110
Merge branch 'unstable' into mentions
JonasMuehlmann Jul 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
424 changes: 424 additions & 0 deletions Messenger/Messenger.Core.Tests.MSTest/Services/MentionServiceTest.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MessageServiceTest
public void CreateMessage_Test()
{
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;

Task.Run(async () =>
{
var _ = await UserService.GetOrCreateApplicationUser(new User(){Id= testName + "User"});
Expand Down
34 changes: 34 additions & 0 deletions Messenger/Messenger.Core/Helpers/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,40 @@ public static Reaction ReactionFromDataRow(DataRow row)
}

/// <summary>
/// Maps to a full Mention model from the data rows
/// </summary>
/// <param name="row">DataRow from the DataSet</param>
/// <returns>A fully mapped Mention object</returns>
public static Mention MentionFromDataRow(DataRow row)
{
return new Mention()
{
Id = SqlHelpers.TryConvertDbValue(row["Id"], Convert.ToUInt32),
TargetType = SqlHelpers.TryConvertDbValue(row["TargetType"], StringToEnum<MentionTarget>),
TargetId = SqlHelpers.TryConvertDbValue(row["TargetId"], Convert.ToString)
};
}

/// <summary>
/// Maps to a full Mentionable model from the data rows
/// </summary>
/// <param name="row">DataRow from the DataSet</param>
/// <returns>A fully mapped Mentionable object</returns>
public static Mentionable MentionableFromDataRow(DataRow row)
{
return new Mentionable()
{
TargetType = SqlHelpers.TryConvertDbValue(row["TargetType"], StringToEnum<MentionTarget>),
TargetName = SqlHelpers.TryConvertDbValue(row["TargetName"], Convert.ToString),
TargetId = SqlHelpers.TryConvertDbValue(row["TargetId"], Convert.ToString)
};
}

public static T StringToEnum<T>(object value)
{
return (T)Enum.Parse(typeof(T), value as string);
}

/// Maps to a full TeamRole model from the data rows
/// </summary>
/// <param name="row">DataRow from the DataSet</param>
Expand Down
21 changes: 21 additions & 0 deletions Messenger/Messenger.Core/Models/Mention.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Messenger.Core.Models
{
public class Mention
{
public uint Id { get; set; }

public MentionTarget TargetType { get; set; }

public string TargetId { get; set; }

public Mention()
{
TargetId = "";
}

public override string ToString()
{
return $"Mention: Id={Id}, TargetType={TargetType}, TargetId={TargetId}";
}
}
}
14 changes: 14 additions & 0 deletions Messenger/Messenger.Core/Models/MentionTargets.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Messenger.Core.Models
{
/// <summary>
/// Represents an entity that can be mentioned in a message
/// </summary>
public enum MentionTarget
{
User,
Role,
Channel,
Message,
All
}
}
25 changes: 25 additions & 0 deletions Messenger/Messenger.Core/Models/Mentionable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Messenger.Core.Models
{
/// <summary>
/// Holds information about a mentionable entity
/// </summary>
public class Mentionable
{
public MentionTarget TargetType { get; set; }

public string TargetId { get; set; }

public string TargetName { get; set; }

public Mentionable()
{
TargetId = "";
TargetName = "";
}

public override string ToString()
{
return $"Mentionble: TargetType={TargetType}, TargetId={TargetId}, TargetName={TargetName}";
}
}
}
Loading