start adding client support for making status edits and viewing history

This commit is contained in:
kim 2024-12-16 13:03:19 +00:00
commit c8a465f9a0
15 changed files with 1544 additions and 431 deletions

View file

@ -31,6 +31,47 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/log"
)
// GetOwnStatus ...
func (p *Processor) GetOwnStatus(
ctx context.Context,
requester *gtsmodel.Account,
targetID string,
) (
*gtsmodel.Status,
gtserror.WithCode,
) {
target, err := p.state.DB.GetStatusByID(ctx, targetID)
if err != nil && !errors.Is(err, db.ErrNoEntries) {
err := gtserror.Newf("error getting from db: %w", err)
return nil, gtserror.NewErrorInternalError(err)
}
if target == nil {
const text = "target status not found"
return nil, gtserror.NewErrorNotFound(
errors.New(text),
text,
)
}
switch {
case target == nil:
const text = "target status not found"
return nil, gtserror.NewErrorNotFound(
errors.New(text),
text,
)
case target.AccountID != requester.ID:
return nil, gtserror.NewErrorNotFound(
errors.New("status does not belong to requester"),
"target status not found",
)
}
return target, nil
}
// GetTargetStatusBy fetches the target status with db load
// function, given the authorized (or, nil) requester's
// account. This returns an approprate gtserror.WithCode