mention notifications working
This commit is contained in:
@ -226,7 +226,7 @@ func (c *converter) ASStatusToStatus(statusable Statusable) (*gtsmodel.Status, e
|
||||
return nil, fmt.Errorf("couldn't get status owner from db: %s", err)
|
||||
}
|
||||
status.AccountID = statusOwner.ID
|
||||
status.GTSAccount = statusOwner
|
||||
status.GTSAuthorAccount = statusOwner
|
||||
|
||||
// check if there's a post that this is a reply to
|
||||
inReplyToURI, err := extractInReplyToURI(statusable)
|
||||
|
||||
@ -65,7 +65,7 @@ type TypeConverter interface {
|
||||
// TagToMasto converts a gts model tag into its mastodon (frontend) representation for serialization on the API.
|
||||
TagToMasto(t *gtsmodel.Tag) (model.Tag, error)
|
||||
// StatusToMasto converts a gts model status into its mastodon (frontend) representation for serialization on the API.
|
||||
StatusToMasto(s *gtsmodel.Status, targetAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account, boostOfAccount *gtsmodel.Account, replyToAccount *gtsmodel.Account, reblogOfStatus *gtsmodel.Status) (*model.Status, error)
|
||||
StatusToMasto(s *gtsmodel.Status, statusAuthor *gtsmodel.Account, requestingAccount *gtsmodel.Account, boostOfAccount *gtsmodel.Account, replyToAccount *gtsmodel.Account, reblogOfStatus *gtsmodel.Status) (*model.Status, error)
|
||||
// VisToMasto converts a gts visibility into its mastodon equivalent
|
||||
VisToMasto(m gtsmodel.Visibility) model.Visibility
|
||||
// InstanceToMasto converts a gts instance into its mastodon equivalent for serving at /api/v1/instance
|
||||
|
||||
@ -262,12 +262,12 @@ func (c *converter) StatusToAS(s *gtsmodel.Status) (vocab.ActivityStreamsNote, e
|
||||
|
||||
// check if author account is already attached to status and attach it if not
|
||||
// if we can't retrieve this, bail here already because we can't attribute the status to anyone
|
||||
if s.GTSAccount == nil {
|
||||
if s.GTSAuthorAccount == nil {
|
||||
a := >smodel.Account{}
|
||||
if err := c.db.GetByID(s.AccountID, a); err != nil {
|
||||
return nil, fmt.Errorf("StatusToAS: error retrieving author account from db: %s", err)
|
||||
}
|
||||
s.GTSAccount = a
|
||||
s.GTSAuthorAccount = a
|
||||
}
|
||||
|
||||
// create the Note!
|
||||
@ -328,9 +328,9 @@ func (c *converter) StatusToAS(s *gtsmodel.Status) (vocab.ActivityStreamsNote, e
|
||||
}
|
||||
|
||||
// attributedTo
|
||||
authorAccountURI, err := url.Parse(s.GTSAccount.URI)
|
||||
authorAccountURI, err := url.Parse(s.GTSAuthorAccount.URI)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("StatusToAS: error parsing url %s: %s", s.GTSAccount.URI, err)
|
||||
return nil, fmt.Errorf("StatusToAS: error parsing url %s: %s", s.GTSAuthorAccount.URI, err)
|
||||
}
|
||||
attributedToProp := streams.NewActivityStreamsAttributedToProperty()
|
||||
attributedToProp.AppendIRI(authorAccountURI)
|
||||
@ -357,9 +357,9 @@ func (c *converter) StatusToAS(s *gtsmodel.Status) (vocab.ActivityStreamsNote, e
|
||||
status.SetActivityStreamsTag(tagProp)
|
||||
|
||||
// parse out some URIs we need here
|
||||
authorFollowersURI, err := url.Parse(s.GTSAccount.FollowersURI)
|
||||
authorFollowersURI, err := url.Parse(s.GTSAuthorAccount.FollowersURI)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("StatusToAS: error parsing url %s: %s", s.GTSAccount.FollowersURI, err)
|
||||
return nil, fmt.Errorf("StatusToAS: error parsing url %s: %s", s.GTSAuthorAccount.FollowersURI, err)
|
||||
}
|
||||
|
||||
publicURI, err := url.Parse(asPublicURI)
|
||||
|
||||
@ -270,7 +270,7 @@ func (c *converter) TagToMasto(t *gtsmodel.Tag) (model.Tag, error) {
|
||||
|
||||
func (c *converter) StatusToMasto(
|
||||
s *gtsmodel.Status,
|
||||
targetAccount *gtsmodel.Account,
|
||||
statusAuthor *gtsmodel.Account,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
boostOfAccount *gtsmodel.Account,
|
||||
replyToAccount *gtsmodel.Account,
|
||||
@ -382,7 +382,7 @@ func (c *converter) StatusToMasto(
|
||||
}
|
||||
}
|
||||
|
||||
mastoTargetAccount, err := c.AccountToMastoPublic(targetAccount)
|
||||
mastoAuthorAccount, err := c.AccountToMastoPublic(statusAuthor)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing account of status author: %s", err)
|
||||
}
|
||||
@ -520,7 +520,7 @@ func (c *converter) StatusToMasto(
|
||||
Content: s.Content,
|
||||
Reblog: mastoRebloggedStatus,
|
||||
Application: mastoApplication,
|
||||
Account: mastoTargetAccount,
|
||||
Account: mastoAuthorAccount,
|
||||
MediaAttachments: mastoAttachments,
|
||||
Mentions: mastoMentions,
|
||||
Tags: mastoTags,
|
||||
@ -639,8 +639,16 @@ func (c *converter) NotificationToMasto(n *gtsmodel.Notification) (*model.Notifi
|
||||
replyToAccount = r
|
||||
}
|
||||
|
||||
if n.GTSStatus.GTSAuthorAccount == nil {
|
||||
if n.GTSStatus.AccountID == n.GTSTargetAccount.ID {
|
||||
n.GTSStatus.GTSAuthorAccount = n.GTSTargetAccount
|
||||
} else if n.GTSStatus.AccountID == n.GTSOriginAccount.ID {
|
||||
n.GTSStatus.GTSAuthorAccount = n.GTSOriginAccount
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
mastoStatus, err = c.StatusToMasto(n.GTSStatus, n.GTSTargetAccount, n.GTSTargetAccount, nil, replyToAccount, nil)
|
||||
mastoStatus, err = c.StatusToMasto(n.GTSStatus, n.GTSStatus.GTSAuthorAccount, n.GTSTargetAccount, nil, replyToAccount, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("NotificationToMasto: error converting status to masto: %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user