🐛 Fix subscriptions
This commit is contained in:
parent
79c34c1225
commit
c454bd0d5c
@ -5,11 +5,8 @@ import "git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
|
|||||||
type Subscription struct {
|
type Subscription struct {
|
||||||
cruda.BaseModel
|
cruda.BaseModel
|
||||||
|
|
||||||
FollowerID uint `json:"follower_id"`
|
FollowerID uint `json:"follower_id"`
|
||||||
AccountID *uint `json:"account_id,omitempty"`
|
AccountID *uint `json:"account_id,omitempty"`
|
||||||
Account *Publisher `json:"account,omitempty"`
|
TagID *uint `json:"tag_id,omitempty"`
|
||||||
TagID *uint `json:"tag_id,omitempty"`
|
CategoryID *uint `json:"category_id,omitempty"`
|
||||||
Tag Tag `json:"tag,omitempty"`
|
|
||||||
CategoryID *uint `json:"category_id,omitempty"`
|
|
||||||
Category Category `json:"category,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func NotifyUserSubscription(poster models.Publisher, item models.Post, content s
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subscriptions []models.Subscription
|
var subscriptions []models.Subscription
|
||||||
if err := database.C.Where("account_id = ?", poster.ID).Preload("Follower").Find(&subscriptions).Error; err != nil {
|
if err := database.C.Where("account_id = ?", poster.ID).Find(&subscriptions).Error; err != nil {
|
||||||
return fmt.Errorf("unable to get subscriptions: %v", err)
|
return fmt.Errorf("unable to get subscriptions: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ func NotifyUserSubscription(poster models.Publisher, item models.Post, content s
|
|||||||
|
|
||||||
userIDs := make([]uint64, 0, len(subscriptions))
|
userIDs := make([]uint64, 0, len(subscriptions))
|
||||||
for _, subscription := range subscriptions {
|
for _, subscription := range subscriptions {
|
||||||
userIDs = append(userIDs, uint64(subscription.Follower.ID))
|
userIDs = append(userIDs, uint64(subscription.FollowerID))
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Visibility == models.PostVisibilitySelected {
|
if item.Visibility == models.PostVisibilitySelected {
|
||||||
@ -192,7 +192,7 @@ func NotifyTagSubscription(poster models.Tag, og models.Publisher, item models.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subscriptions []models.Subscription
|
var subscriptions []models.Subscription
|
||||||
if err := database.C.Where("tag_id = ?", poster.ID).Preload("Follower").Find(&subscriptions).Error; err != nil {
|
if err := database.C.Where("tag_id = ?", poster.ID).Find(&subscriptions).Error; err != nil {
|
||||||
return fmt.Errorf("unable to get subscriptions: %v", err)
|
return fmt.Errorf("unable to get subscriptions: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ func NotifyTagSubscription(poster models.Tag, og models.Publisher, item models.P
|
|||||||
|
|
||||||
userIDs := make([]uint64, 0, len(subscriptions))
|
userIDs := make([]uint64, 0, len(subscriptions))
|
||||||
for _, subscription := range subscriptions {
|
for _, subscription := range subscriptions {
|
||||||
userIDs = append(userIDs, uint64(subscription.Follower.ID))
|
userIDs = append(userIDs, uint64(subscription.FollowerID))
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Visibility == models.PostVisibilitySelected {
|
if item.Visibility == models.PostVisibilitySelected {
|
||||||
@ -240,7 +240,7 @@ func NotifyCategorySubscription(poster models.Category, og models.Publisher, ite
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subscriptions []models.Subscription
|
var subscriptions []models.Subscription
|
||||||
if err := database.C.Where("category_id = ?", poster.ID).Preload("Follower").Find(&subscriptions).Error; err != nil {
|
if err := database.C.Where("category_id = ?", poster.ID).Find(&subscriptions).Error; err != nil {
|
||||||
return fmt.Errorf("unable to get subscriptions: %v", err)
|
return fmt.Errorf("unable to get subscriptions: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ func NotifyCategorySubscription(poster models.Category, og models.Publisher, ite
|
|||||||
|
|
||||||
userIDs := make([]uint64, 0, len(subscriptions))
|
userIDs := make([]uint64, 0, len(subscriptions))
|
||||||
for _, subscription := range subscriptions {
|
for _, subscription := range subscriptions {
|
||||||
userIDs = append(userIDs, uint64(subscription.Follower.ID))
|
userIDs = append(userIDs, uint64(subscription.FollowerID))
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Visibility == models.PostVisibilitySelected {
|
if item.Visibility == models.PostVisibilitySelected {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user