mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-06 05:18:08 -06:00
[bugfix] Use "comment" via /api/v1/instance
This commit is contained in:
parent
e856d09f8e
commit
3409e6414c
8 changed files with 59 additions and 13 deletions
|
|
@ -113,6 +113,27 @@ nothanks.com,suspend,false,false,,false
|
|||
|
||||
JSON lists use content type `application/json`.
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"domain": "bumfaces.net",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"comment": "big jerks"
|
||||
},
|
||||
{
|
||||
"domain": "peepee.poopoo",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"comment": "harassment"
|
||||
},
|
||||
{
|
||||
"domain": "nothanks.com",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
As an alternative to `"comment"`, `"public_comment"` will also work:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1099,13 +1099,22 @@ definitions:
|
|||
domain:
|
||||
description: Domain represents a remote domain
|
||||
properties:
|
||||
comment:
|
||||
description: |-
|
||||
If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
Alternative to `public_comment` to be used when serializing/deserializing via /api/v1/instance.
|
||||
example: they smell
|
||||
type: string
|
||||
x-go-name: Comment
|
||||
domain:
|
||||
description: The hostname of the domain.
|
||||
example: example.org
|
||||
type: string
|
||||
x-go-name: Domain
|
||||
public_comment:
|
||||
description: If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
description: |-
|
||||
If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
Alternative to `comment` to be used when serializing/deserializing NOT via /api/v1/instance.
|
||||
example: they smell
|
||||
type: string
|
||||
x-go-name: PublicComment
|
||||
|
|
@ -1124,6 +1133,13 @@ definitions:
|
|||
x-go-package: github.com/superseriousbusiness/gotosocial/internal/api/model
|
||||
domainPermission:
|
||||
properties:
|
||||
comment:
|
||||
description: |-
|
||||
If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
Alternative to `public_comment` to be used when serializing/deserializing via /api/v1/instance.
|
||||
example: they smell
|
||||
type: string
|
||||
x-go-name: Comment
|
||||
created_at:
|
||||
description: Time at which the permission entry was created (ISO 8601 Datetime).
|
||||
example: "2021-07-30T09:20:25+00:00"
|
||||
|
|
@ -1162,7 +1178,9 @@ definitions:
|
|||
type: string
|
||||
x-go-name: PrivateComment
|
||||
public_comment:
|
||||
description: If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
description: |-
|
||||
If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
Alternative to `comment` to be used when serializing/deserializing NOT via /api/v1/instance.
|
||||
example: they smell
|
||||
type: string
|
||||
x-go-name: PublicComment
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetOnlySuspended() {
|
|||
{
|
||||
"domain": "replyguys.com",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"public_comment": "reply-guying to tech posts"
|
||||
"comment": "reply-guying to tech posts"
|
||||
}
|
||||
]`, dst.String())
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetOnlySuspendedAuthori
|
|||
{
|
||||
"domain": "replyguys.com",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"public_comment": "reply-guying to tech posts"
|
||||
"comment": "reply-guying to tech posts"
|
||||
}
|
||||
]`, dst.String())
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAll() {
|
|||
{
|
||||
"domain": "replyguys.com",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"public_comment": "reply-guying to tech posts"
|
||||
"comment": "reply-guying to tech posts"
|
||||
}
|
||||
]`, dst.String())
|
||||
}
|
||||
|
|
@ -263,12 +263,12 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated()
|
|||
{
|
||||
"domain": "o*g.*u**.t**.*or*t.*r**ev**",
|
||||
"suspended_at": "2021-06-09T10:34:55.000Z",
|
||||
"public_comment": "just absolutely the worst, wowza"
|
||||
"comment": "just absolutely the worst, wowza"
|
||||
},
|
||||
{
|
||||
"domain": "replyguys.com",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"public_comment": "reply-guying to tech posts"
|
||||
"comment": "reply-guying to tech posts"
|
||||
}
|
||||
]`, dst.String())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ type Domain struct {
|
|||
// example: 2021-07-30T09:20:25+00:00
|
||||
SilencedAt string `json:"silenced_at,omitempty"`
|
||||
// If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
// Alternative to `public_comment` to be used when serializing/deserializing via /api/v1/instance.
|
||||
// example: they smell
|
||||
Comment *string `form:"comment" json:"comment,omitempty"`
|
||||
// If the domain is blocked, what's the publicly-stated reason for the block.
|
||||
// Alternative to `comment` to be used when serializing/deserializing NOT via /api/v1/instance.
|
||||
// example: they smell
|
||||
PublicComment *string `form:"public_comment" json:"public_comment,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
|
@ -239,7 +240,7 @@ func (p *Processor) importOrUpdateDomainPerm(
|
|||
var (
|
||||
domain = apiDomainPerm.Domain.Domain
|
||||
obfuscate = apiDomainPerm.Obfuscate
|
||||
publicComment = apiDomainPerm.PublicComment
|
||||
publicComment = cmp.Or(apiDomainPerm.PublicComment, apiDomainPerm.Comment)
|
||||
privateComment = apiDomainPerm.PrivateComment
|
||||
subscriptionID = "" // No sub ID for imports.
|
||||
)
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@ func (p *Processor) InstancePeersGet(ctx context.Context, includeSuspended bool,
|
|||
}
|
||||
|
||||
domains = append(domains, &apimodel.Domain{
|
||||
Domain: d,
|
||||
SuspendedAt: util.FormatISO8601(domainBlock.CreatedAt),
|
||||
PublicComment: &domainBlock.PublicComment,
|
||||
Domain: d,
|
||||
SuspendedAt: util.FormatISO8601(domainBlock.CreatedAt),
|
||||
Comment: &domainBlock.PublicComment,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -742,7 +742,8 @@ func permsFromJSON(
|
|||
}
|
||||
|
||||
// Set remaining fields.
|
||||
perm.SetPublicComment(util.PtrOrZero(apiPerm.PublicComment))
|
||||
publicComment := cmp.Or(apiPerm.PublicComment, apiPerm.Comment)
|
||||
perm.SetPublicComment(util.PtrOrZero(publicComment))
|
||||
perm.SetObfuscate(util.Ptr(util.PtrOrZero(apiPerm.Obfuscate)))
|
||||
|
||||
// We're done.
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ nothanks.com`
|
|||
{
|
||||
"domain": "bumfaces.net",
|
||||
"suspended_at": "2020-05-13T13:29:12.000Z",
|
||||
"public_comment": "big jerks"
|
||||
"comment": "big jerks"
|
||||
},
|
||||
{
|
||||
"domain": "peepee.poopoo",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue