summaryrefslogtreecommitdiff
path: root/internal/processing/fromcommon.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-05-31 17:36:35 +0200
committerLibravatar GitHub <noreply@github.com>2021-05-31 17:36:35 +0200
commit6ac6f8d614d17910d929981bde7d80d8ec2c0b6e (patch)
treee7a51ba572a7cc880bbc22dacb999236ac6e36e6 /internal/processing/fromcommon.go
parentMove a lot of stuff + tidy stuff (#37) (diff)
downloadgotosocial-6ac6f8d614d17910d929981bde7d80d8ec2c0b6e.tar.xz
Tidy + timeline embetterment (#38)
* tidy up timelines a bit + stub out some endpoints * who's faved and who's boosted, reblog notifs * linting * Update progress with new endpoints
Diffstat (limited to 'internal/processing/fromcommon.go')
-rw-r--r--internal/processing/fromcommon.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/processing/fromcommon.go b/internal/processing/fromcommon.go
index cb38d4bb4..bdb2a599b 100644
--- a/internal/processing/fromcommon.go
+++ b/internal/processing/fromcommon.go
@@ -160,5 +160,54 @@ func (p *processor) notifyFave(fave *gtsmodel.StatusFave, receivingAccount *gtsm
}
func (p *processor) notifyAnnounce(status *gtsmodel.Status) error {
+ if status.BoostOfID == "" {
+ // not a boost, nothing to do
+ return nil
+ }
+
+ boostedStatus := &gtsmodel.Status{}
+ if err := p.db.GetByID(status.BoostOfID, boostedStatus); err != nil {
+ return fmt.Errorf("notifyAnnounce: error getting status with id %s: %s", status.BoostOfID, err)
+ }
+
+ boostedAcct := &gtsmodel.Account{}
+ if err := p.db.GetByID(boostedStatus.AccountID, boostedAcct); err != nil {
+ return fmt.Errorf("notifyAnnounce: error getting account with id %s: %s", boostedStatus.AccountID, err)
+ }
+
+ if boostedAcct.Domain != "" {
+ // remote account, nothing to do
+ return nil
+ }
+
+ if boostedStatus.AccountID == status.AccountID {
+ // it's a self boost, nothing to do
+ return nil
+ }
+
+ // make sure a notif doesn't already exist for this announce
+ err := p.db.GetWhere([]db.Where{
+ {Key: "notification_type", Value: gtsmodel.NotificationReblog},
+ {Key: "target_account_id", Value: boostedAcct.ID},
+ {Key: "origin_account_id", Value: status.AccountID},
+ {Key: "status_id", Value: status.ID},
+ }, &gtsmodel.Notification{})
+ if err == nil {
+ // notification exists already so just bail
+ return nil
+ }
+
+ // now create the new reblog notification
+ notif := &gtsmodel.Notification{
+ NotificationType: gtsmodel.NotificationReblog,
+ TargetAccountID: boostedAcct.ID,
+ OriginAccountID: status.AccountID,
+ StatusID: status.ID,
+ }
+
+ if err := p.db.Put(notif); err != nil {
+ return fmt.Errorf("notifyAnnounce: error putting notification in database: %s", err)
+ }
+
return nil
}