Fixed follower notification

This commit is contained in:
Eduard Urbach 2019-12-26 08:36:06 +09:00
parent ca85f5330d
commit fea14c0394
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0

View File

@ -17,29 +17,27 @@ func (user *User) Follow(followUserID UserID) error {
return errors.New("User " + followUserID + " has already been added")
}
followedUser, err := GetUser(followUserID)
if err != nil {
return err
}
user.FollowIDs = append(user.FollowIDs, followUserID)
// Send notification
user, err := GetUser(followUserID)
if err == nil {
if !user.Settings().Notification.NewFollowers {
return nil
}
follower, err := GetUser(user.ID)
if err == nil {
user.SendNotification(&PushNotification{
Title: "You have a new follower!",
Message: follower.Nick + " started following you.",
Icon: "https:" + follower.AvatarLink("large"),
Link: "https://notify.moe" + follower.Link(),
Type: NotificationTypeFollow,
})
}
if !followedUser.Settings().Notification.NewFollowers {
return nil
}
followedUser.SendNotification(&PushNotification{
Title: "You have a new follower!",
Message: user.Nick + " started following you.",
Icon: "https:" + user.AvatarLink("large"),
Link: "https://notify.moe" + user.Link(),
Type: NotificationTypeFollow,
})
return nil
}