diff options
Diffstat (limited to 'internal/gtsmodel')
| -rw-r--r-- | internal/gtsmodel/account.go | 16 | ||||
| -rw-r--r-- | internal/gtsmodel/adminaction.go | 5 | 
2 files changed, 19 insertions, 2 deletions
| diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index 7b27f076a..578d4c811 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -72,9 +72,10 @@ type Account struct {  	FollowersURI            string           `bun:",nullzero,unique"`               // URI for getting the followers list of this account  	FeaturedCollectionURI   string           `bun:",nullzero,unique"`               // URL for getting the featured collection list of this account  	ActorType               string           `bun:",nullzero,notnull"`              // What type of activitypub actor is this account? -	PrivateKey              *rsa.PrivateKey  `bun:""`                               // Privatekey for validating activitypub requests, will only be defined for local accounts -	PublicKey               *rsa.PublicKey   `bun:",notnull"`                       // Publickey for encoding activitypub requests, will be defined for both local and remote accounts +	PrivateKey              *rsa.PrivateKey  `bun:""`                               // Privatekey for signing activitypub requests, will only be defined for local accounts +	PublicKey               *rsa.PublicKey   `bun:",notnull"`                       // Publickey for authorizing signed activitypub requests, will be defined for both local and remote accounts  	PublicKeyURI            string           `bun:",nullzero,notnull,unique"`       // Web-reachable location of this account's public key +	PublicKeyExpiresAt      time.Time        `bun:"type:timestamptz,nullzero"`      // PublicKey will expire/has expired at given time, and should be fetched again as appropriate. Only ever set for remote accounts.  	SensitizedAt            time.Time        `bun:"type:timestamptz,nullzero"`      // When was this account set to have all its media shown as sensitive?  	SilencedAt              time.Time        `bun:"type:timestamptz,nullzero"`      // When was this account silenced (eg., statuses only visible to followers, not public)?  	SuspendedAt             time.Time        `bun:"type:timestamptz,nullzero"`      // When was this account suspended (eg., don't allow it to log in/post, don't accept media/posts from this account) @@ -129,6 +130,17 @@ func (a *Account) EmojisPopulated() bool {  	return true  } +// PubKeyExpired returns true if the account's public key +// has been marked as expired, and the expiry time has passed. +func (a *Account) PubKeyExpired() bool { +	if a == nil { +		return false +	} + +	return !a.PublicKeyExpiresAt.IsZero() && +		a.PublicKeyExpiresAt.Before(time.Now()) +} +  // AccountToEmoji is an intermediate struct to facilitate the many2many relationship between an account and one or more emojis.  type AccountToEmoji struct {  	AccountID string   `bun:"type:CHAR(26),unique:accountemoji,nullzero,notnull"` diff --git a/internal/gtsmodel/adminaction.go b/internal/gtsmodel/adminaction.go index c6c598b32..1e55a33f9 100644 --- a/internal/gtsmodel/adminaction.go +++ b/internal/gtsmodel/adminaction.go @@ -72,6 +72,7 @@ const (  	AdminActionUnsilence  	AdminActionSuspend  	AdminActionUnsuspend +	AdminActionExpireKeys  )  func (t AdminActionType) String() string { @@ -88,6 +89,8 @@ func (t AdminActionType) String() string {  		return "suspend"  	case AdminActionUnsuspend:  		return "unsuspend" +	case AdminActionExpireKeys: +		return "expire-keys"  	default:  		return "unknown"  	} @@ -107,6 +110,8 @@ func NewAdminActionType(in string) AdminActionType {  		return AdminActionSuspend  	case "unsuspend":  		return AdminActionUnsuspend +	case "expire-keys": +		return AdminActionExpireKeys  	default:  		return AdminActionUnknown  	} | 
