✨ Add notification to friend request
This commit is contained in:
@@ -1,10 +1,18 @@
|
|||||||
|
using DysonNetwork.Pass.Localization;
|
||||||
using DysonNetwork.Shared.Cache;
|
using DysonNetwork.Shared.Cache;
|
||||||
|
using DysonNetwork.Shared.Proto;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
using NodaTime;
|
using NodaTime;
|
||||||
|
|
||||||
namespace DysonNetwork.Pass.Account;
|
namespace DysonNetwork.Pass.Account;
|
||||||
|
|
||||||
public class RelationshipService(AppDatabase db, ICacheService cache)
|
public class RelationshipService(
|
||||||
|
AppDatabase db,
|
||||||
|
ICacheService cache,
|
||||||
|
PusherService.PusherServiceClient pusher,
|
||||||
|
IStringLocalizer<NotificationResource> localizer
|
||||||
|
)
|
||||||
{
|
{
|
||||||
private const string UserFriendsCacheKeyPrefix = "accounts:friends:";
|
private const string UserFriendsCacheKeyPrefix = "accounts:friends:";
|
||||||
private const string UserBlockedCacheKeyPrefix = "accounts:blocked:";
|
private const string UserBlockedCacheKeyPrefix = "accounts:blocked:";
|
||||||
@@ -92,6 +100,19 @@ public class RelationshipService(AppDatabase db, ICacheService cache)
|
|||||||
db.AccountRelationships.Add(relationship);
|
db.AccountRelationships.Add(relationship);
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
|
await pusher.SendPushNotificationToUserAsync(new SendPushNotificationToUserRequest
|
||||||
|
{
|
||||||
|
UserId = target.Id.ToString(),
|
||||||
|
Notification = new PushNotification
|
||||||
|
{
|
||||||
|
Topic = "relationships.friends.request",
|
||||||
|
Title = localizer["FriendRequestTitle", sender.Nick],
|
||||||
|
Body = localizer["FriendRequestBody"],
|
||||||
|
ActionUri = "/account/relationships",
|
||||||
|
IsSavable = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return relationship;
|
return relationship;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -142,13 +142,6 @@
|
|||||||
<AdditionalFiles Include="Pages\Emails\LandingEmail.razor" />
|
<AdditionalFiles Include="Pages\Emails\LandingEmail.razor" />
|
||||||
<AdditionalFiles Include="Pages\Emails\PasswordResetEmail.razor" />
|
<AdditionalFiles Include="Pages\Emails\PasswordResetEmail.razor" />
|
||||||
<AdditionalFiles Include="Pages\Emails\VerificationEmail.razor" />
|
<AdditionalFiles Include="Pages\Emails\VerificationEmail.razor" />
|
||||||
<AdditionalFiles Include="Resources\Localization\AccountEventResource.zh-hans.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\EmailResource.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\EmailResource.zh-hans.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\NotificationResource.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\NotificationResource.zh-hans.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\SharedResource.resx"/>
|
|
||||||
<AdditionalFiles Include="Resources\Localization\SharedResource.zh-hans.resx"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -86,4 +86,10 @@
|
|||||||
<data name="NewLoginBody" xml:space="preserve">
|
<data name="NewLoginBody" xml:space="preserve">
|
||||||
<value>Your account logged on to a device named {0} at {1}</value>
|
<value>Your account logged on to a device named {0} at {1}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FriendRequestTitle" xml:space="preserve">
|
||||||
|
<value>{0} requested to be your friend</value>
|
||||||
|
</data>
|
||||||
|
<data name="FriendRequestBody" xml:space="preserve">
|
||||||
|
<value>You can go to relationships page and decide accept their request or not.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@@ -78,4 +78,10 @@
|
|||||||
<data name="NewLoginBody" xml:space="preserve">
|
<data name="NewLoginBody" xml:space="preserve">
|
||||||
<value>您的帐号在位于 {1} 的设备 {0} 上刚刚登陆了</value>
|
<value>您的帐号在位于 {1} 的设备 {0} 上刚刚登陆了</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FriendRequestTitle" xml:space="preserve">
|
||||||
|
<value>{0} 请求成为您的好友</value>
|
||||||
|
</data>
|
||||||
|
<data name="FriendRequestBody" xml:space="preserve">
|
||||||
|
<value>您可以前往人际关系页面来决定时候要接受他们的邀请。</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@@ -149,8 +149,14 @@
|
|||||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||||
<Assembly Path="/opt/homebrew/Cellar/dotnet/9.0.6/libexec/packs/Microsoft.AspNetCore.App.Ref/9.0.6/ref/net9.0/Microsoft.AspNetCore.RateLimiting.dll" />
|
<Assembly Path="/opt/homebrew/Cellar/dotnet/9.0.6/libexec/packs/Microsoft.AspNetCore.App.Ref/9.0.6/ref/net9.0/Microsoft.AspNetCore.RateLimiting.dll" />
|
||||||
</AssemblyExplorer></s:String>
|
</AssemblyExplorer></s:String>
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FAccountEventResource/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FAccountEventResource/@EntryIndexedValue">False</s:Boolean>
|
||||||
|
|
||||||
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FEmailResource/@EntryIndexedValue">False</s:Boolean>
|
||||||
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FNotificationResource/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FNotificationResource/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|
||||||
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002EPass_002FResources_002FLocalization_002FSharedResource/@EntryIndexedValue">False</s:Boolean>
|
||||||
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FAccountEventResource/@EntryIndexedValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FAccountEventResource/@EntryIndexedValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FAccountEventResource/@EntryIndexRemoved">True</s:Boolean>
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FAccountEventResource/@EntryIndexRemoved">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FSharedResource/@EntryIndexedValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=DysonNetwork_002ESphere_002FLocalization_002FResources_002FSharedResource/@EntryIndexedValue">False</s:Boolean>
|
||||||
|
Reference in New Issue
Block a user