summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-09-21 12:12:04 +0200
committerLibravatar GitHub <noreply@github.com>2023-09-21 12:12:04 +0200
commit183eaa5b298235acb8f25ba8f18b98e31471d965 (patch)
tree55f42887edeb5206122d92eb30e0eedf145a3615 /internal/typeutils/internaltofrontend.go
parent[docs] Add a note on cluster support (#2214) (diff)
downloadgotosocial-183eaa5b298235acb8f25ba8f18b98e31471d965.tar.xz
[feature] Implement explicit domain allows + allowlist federation mode (#2200)
* love like winter! wohoah, wohoah * domain allow side effects * tests! logging! unallow! * document federation modes * linty linterson * test * further adventures in documentation * finish up domain block documentation (i think) * change wording a wee little bit * docs, example * consolidate shared domainPermission code * call mode once * fetch federation mode within domain blocked func * read domain perm import in streaming manner * don't use pointer to slice for domain perms * don't bother copying blocks + allows before deleting * admonish! * change wording just a scooch * update docs
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go37
1 files changed, 22 insertions, 15 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index 050997bda..11838e2bd 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -1041,32 +1041,39 @@ func (c *converter) NotificationToAPINotification(ctx context.Context, n *gtsmod
}, nil
}
-func (c *converter) DomainBlockToAPIDomainBlock(ctx context.Context, b *gtsmodel.DomainBlock, export bool) (*apimodel.DomainBlock, error) {
+func (c *converter) DomainPermToAPIDomainPerm(
+ ctx context.Context,
+ d gtsmodel.DomainPermission,
+ export bool,
+) (*apimodel.DomainPermission, error) {
// Domain may be in Punycode,
// de-punify it just in case.
- d, err := util.DePunify(b.Domain)
+ domain, err := util.DePunify(d.GetDomain())
if err != nil {
- return nil, fmt.Errorf("DomainBlockToAPIDomainBlock: error de-punifying domain %s: %w", b.Domain, err)
+ return nil, gtserror.Newf("error de-punifying domain %s: %w", d.GetDomain(), err)
}
- domainBlock := &apimodel.DomainBlock{
+ domainPerm := &apimodel.DomainPermission{
Domain: apimodel.Domain{
- Domain: d,
- PublicComment: b.PublicComment,
+ Domain: domain,
+ PublicComment: d.GetPublicComment(),
},
}
- // 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 = util.FormatISO8601(b.CreatedAt)
+ // If we're exporting, provide
+ // only bare minimum detail.
+ if export {
+ return domainPerm, nil
}
- return domainBlock, nil
+ domainPerm.ID = d.GetID()
+ domainPerm.Obfuscate = *d.GetObfuscate()
+ domainPerm.PrivateComment = d.GetPrivateComment()
+ domainPerm.SubscriptionID = d.GetSubscriptionID()
+ domainPerm.CreatedBy = d.GetCreatedByAccountID()
+ domainPerm.CreatedAt = util.FormatISO8601(d.GetCreatedAt())
+
+ return domainPerm, nil
}
func (c *converter) ReportToAPIReport(ctx context.Context, r *gtsmodel.Report) (*apimodel.Report, error) {