mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-18 19:30:50 +01:00
Always load target account settings
This commit is contained in:
parent
b982944e85
commit
a8ae0e3173
@ -85,7 +85,7 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load VAPID keys into webpush-go options struct.
|
// Get VAPID keys.
|
||||||
vapidKeyPair, err := r.state.DB.GetVAPIDKeyPair(ctx)
|
vapidKeyPair, err := r.state.DB.GetVAPIDKeyPair(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return gtserror.Newf("error getting VAPID key pair: %w", err)
|
return gtserror.Newf("error getting VAPID key pair: %w", err)
|
||||||
@ -103,8 +103,13 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
|||||||
vapidSubjectEmail = "admin@" + domain
|
vapidSubjectEmail = "admin@" + domain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get target account settings.
|
||||||
|
targetAccountSettings, err := r.state.DB.GetAccountSettings(ctx, notification.TargetAccountID)
|
||||||
|
if err != nil {
|
||||||
|
return gtserror.Newf("error getting settings for account %s: %w", notification.TargetAccountID, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Get API representations of notification and accounts involved.
|
// Get API representations of notification and accounts involved.
|
||||||
// This also loads the target account's settings.
|
|
||||||
apiNotification, err := r.tc.NotificationToAPINotification(ctx, notification, filters, mutes)
|
apiNotification, err := r.tc.NotificationToAPINotification(ctx, notification, filters, mutes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return gtserror.Newf("error converting notification %s to API representation: %w", notification.ID, err)
|
return gtserror.Newf("error converting notification %s to API representation: %w", notification.ID, err)
|
||||||
@ -117,6 +122,7 @@ func(subscription *gtsmodel.WebPushSubscription) bool {
|
|||||||
ctx,
|
ctx,
|
||||||
vapidKeyPair,
|
vapidKeyPair,
|
||||||
vapidSubjectEmail,
|
vapidSubjectEmail,
|
||||||
|
targetAccountSettings,
|
||||||
subscription,
|
subscription,
|
||||||
notification,
|
notification,
|
||||||
apiNotification,
|
apiNotification,
|
||||||
@ -139,6 +145,7 @@ func (r *realSender) sendToSubscription(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
vapidKeyPair *gtsmodel.VAPIDKeyPair,
|
vapidKeyPair *gtsmodel.VAPIDKeyPair,
|
||||||
vapidSubjectEmail string,
|
vapidSubjectEmail string,
|
||||||
|
targetAccountSettings *gtsmodel.AccountSettings,
|
||||||
subscription *gtsmodel.WebPushSubscription,
|
subscription *gtsmodel.WebPushSubscription,
|
||||||
notification *gtsmodel.Notification,
|
notification *gtsmodel.Notification,
|
||||||
apiNotification *apimodel.Notification,
|
apiNotification *apimodel.Notification,
|
||||||
@ -165,7 +172,7 @@ func (r *realSender) sendToSubscription(
|
|||||||
Title: formatNotificationTitle(ctx, subscription, notification, apiNotification),
|
Title: formatNotificationTitle(ctx, subscription, notification, apiNotification),
|
||||||
Body: formatNotificationBody(apiNotification),
|
Body: formatNotificationBody(apiNotification),
|
||||||
Icon: apiNotification.Account.Avatar,
|
Icon: apiNotification.Account.Avatar,
|
||||||
PreferredLocale: notification.TargetAccount.Settings.Language,
|
PreferredLocale: targetAccountSettings.Language,
|
||||||
AccessToken: token.Access,
|
AccessToken: token.Access,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user