diff options
author | 2021-06-17 18:02:33 +0200 | |
---|---|---|
committer | 2021-06-17 18:02:33 +0200 | |
commit | 82d9f88e424fffacfa9a9c1c26f2f702b97f3e3a (patch) | |
tree | 60379f8eb809e9019222f67a13b547e4a26bfc83 /internal/processing/federation.go | |
parent | Timeline manager (#40) (diff) | |
download | gotosocial-82d9f88e424fffacfa9a9c1c26f2f702b97f3e3a.tar.xz |
Timeline improvements (#41)
Tidying up.
Parent/child statuses now display correctly in status/id/context.
Diffstat (limited to 'internal/processing/federation.go')
-rw-r--r-- | internal/processing/federation.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/processing/federation.go b/internal/processing/federation.go index 1c0d67fc8..5693caf90 100644 --- a/internal/processing/federation.go +++ b/internal/processing/federation.go @@ -223,6 +223,8 @@ func (p *processor) GetFediStatus(requestedUsername string, requestedStatusID st return nil, gtserror.NewErrorNotAuthorized(err) } + // authorize the request: + // 1. check if a block exists between the requester and the requestee blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID) if err != nil { return nil, gtserror.NewErrorInternalError(err) @@ -232,6 +234,7 @@ func (p *processor) GetFediStatus(requestedUsername string, requestedStatusID st return nil, gtserror.NewErrorNotAuthorized(fmt.Errorf("block exists between accounts %s and %s", requestedAccount.ID, requestingAccount.ID)) } + // get the status out of the database here s := >smodel.Status{} if err := p.db.GetWhere([]db.Where{ {Key: "id", Value: requestedStatusID}, @@ -240,6 +243,15 @@ func (p *processor) GetFediStatus(requestedUsername string, requestedStatusID st return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting status with id %s and account id %s: %s", requestedStatusID, requestedAccount.ID, err)) } + visible, err := p.filter.StatusVisible(s, requestingAccount) + if err != nil { + return nil, gtserror.NewErrorInternalError(err) + } + if !visible { + return nil, gtserror.NewErrorNotFound(fmt.Errorf("status with id %s not visible to user with id %s", s.ID, requestingAccount.ID)) + } + + // requester is authorized to view the status, so convert it to AP representation and serialize it asStatus, err := p.tc.StatusToAS(s) if err != nil { return nil, gtserror.NewErrorInternalError(err) |