mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-19 18:16:16 -06:00
improve blocking stuff
This commit is contained in:
parent
861cc1dff1
commit
f4dc4d0aa0
19 changed files with 270 additions and 22 deletions
|
|
@ -48,6 +48,10 @@ type TypeConverter interface {
|
|||
// if something goes wrong. The returned account should be ready to serialize on an API level, and may NOT have sensitive fields.
|
||||
// In other words, this is the public record that the server has of an account.
|
||||
AccountToMastoPublic(account *gtsmodel.Account) (*model.Account, error)
|
||||
// AccountToMastoBlocked takes a db model account as a param, and returns a mastotype account, or an error if
|
||||
// something goes wrong. The returned account will be a bare minimum representation of the account. This function should be used
|
||||
// when someone wants to view an account they've blocked.
|
||||
AccountToMastoBlocked(account *gtsmodel.Account) (*model.Account, error)
|
||||
// AppToMastoSensitive takes a db model application as a param, and returns a populated mastotype application, or an error
|
||||
// if something goes wrong. The returned application should be ready to serialize on an API level, and may have sensitive fields
|
||||
// (such as client id and client secret), so serve it only to an authorized user who should have permission to see it.
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ func (c *converter) StatusToBoost(s *gtsmodel.Status, boostingAccount *gtsmodel.
|
|||
Language: s.Language,
|
||||
Text: s.Text,
|
||||
BoostOfID: s.ID,
|
||||
BoostOfAccountID: s.AccountID,
|
||||
Visibility: s.Visibility,
|
||||
VisibilityAdvanced: s.VisibilityAdvanced,
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,27 @@ func (c *converter) AccountToMastoPublic(a *gtsmodel.Account) (*model.Account, e
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (c *converter) AccountToMastoBlocked(a *gtsmodel.Account) (*model.Account, error) {
|
||||
var acct string
|
||||
if a.Domain != "" {
|
||||
// this is a remote user
|
||||
acct = fmt.Sprintf("%s@%s", a.Username, a.Domain)
|
||||
} else {
|
||||
// this is a local user
|
||||
acct = a.Username
|
||||
}
|
||||
|
||||
return &model.Account{
|
||||
ID: a.ID,
|
||||
Username: a.Username,
|
||||
Acct: acct,
|
||||
DisplayName: a.Username,
|
||||
Bot: a.Bot,
|
||||
CreatedAt: a.CreatedAt.Format(time.RFC3339),
|
||||
URL: a.URL,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *converter) AppToMastoSensitive(a *gtsmodel.Application) (*model.Application, error) {
|
||||
return &model.Application{
|
||||
ID: a.ID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue