domain blocky block block

This commit is contained in:
tsmethurst 2021-07-02 15:52:16 +02:00
commit 6f20eaee75
16 changed files with 193 additions and 29 deletions

View file

@ -77,7 +77,7 @@ type TypeConverter interface {
// NotificationToMasto converts a gts notification into a mastodon notification
NotificationToMasto(n *gtsmodel.Notification) (*model.Notification, error)
// DomainBlockTomasto converts a gts model domin block into a mastodon domain block, for serving at /api/v1/admin/domain_blocks
DomainBlockToMasto(b *gtsmodel.DomainBlock) (*model.DomainBlock, error)
DomainBlockToMasto(b *gtsmodel.DomainBlock, export bool) (*model.DomainBlock, error)
/*
FRONTEND (mastodon) MODEL TO INTERNAL (gts) MODEL

View file

@ -645,15 +645,22 @@ func (c *converter) NotificationToMasto(n *gtsmodel.Notification) (*model.Notifi
}, nil
}
func (c *converter) DomainBlockToMasto(b *gtsmodel.DomainBlock) (*model.DomainBlock, error) {
return &model.DomainBlock{
ID: b.ID,
func (c *converter) DomainBlockToMasto(b *gtsmodel.DomainBlock, export bool) (*model.DomainBlock, error) {
domainBlock := &model.DomainBlock{
Domain: b.Domain,
Obfuscate: b.Obfuscate,
PrivateComment: b.PrivateComment,
PublicComment: b.PublicComment,
SubscriptionID: b.SubscriptionID,
CreatedBy: b.CreatedByAccountID,
CreatedAt: b.CreatedAt.Format(time.RFC3339),
}, nil
}
// if we're exporting a domain block, return it with minimal information attached
if !export {
domainBlock.ID = b.ID
domainBlock.Obfuscate = b.Obfuscate
domainBlock.PrivateComment = b.PrivateComment
domainBlock.SubscriptionID = b.SubscriptionID
domainBlock.CreatedBy = b.CreatedByAccountID
domainBlock.CreatedAt = b.CreatedAt.Format(time.RFC3339)
}
return domainBlock, nil
}