mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 11:16:14 -06:00
fix the stuff
This commit is contained in:
parent
3409e6414c
commit
30edcb5099
2 changed files with 40 additions and 18 deletions
|
|
@ -97,14 +97,21 @@ func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubs
|
||||||
suite.Equal(`[
|
suite.Equal(`[
|
||||||
{
|
{
|
||||||
"domain": "bumfaces.net",
|
"domain": "bumfaces.net",
|
||||||
"public_comment": "big jerks"
|
"public_comment": "big jerks",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"domain": "peepee.poopoo",
|
"domain": "peepee.poopoo",
|
||||||
"public_comment": "harassment"
|
"public_comment": "harassment",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"domain": "nothanks.com"
|
"domain": "nothanks.com",
|
||||||
|
"public_comment": "",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
}
|
}
|
||||||
]`, dst.String())
|
]`, dst.String())
|
||||||
|
|
||||||
|
|
@ -177,13 +184,22 @@ func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubs
|
||||||
// Ensure expected.
|
// Ensure expected.
|
||||||
suite.Equal(`[
|
suite.Equal(`[
|
||||||
{
|
{
|
||||||
"domain": "bumfaces.net"
|
"domain": "bumfaces.net",
|
||||||
|
"public_comment": "",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"domain": "peepee.poopoo"
|
"domain": "peepee.poopoo",
|
||||||
|
"public_comment": "",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"domain": "nothanks.com"
|
"domain": "nothanks.com",
|
||||||
|
"public_comment": "",
|
||||||
|
"obfuscate": false,
|
||||||
|
"private_comment": ""
|
||||||
}
|
}
|
||||||
]`, dst.String())
|
]`, dst.String())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -564,13 +564,13 @@ func permsFromCSV(
|
||||||
|
|
||||||
for i, columnHeader := range columnHeaders {
|
for i, columnHeader := range columnHeaders {
|
||||||
// Remove leading # if present.
|
// Remove leading # if present.
|
||||||
normal := strings.TrimLeft(columnHeader, "#")
|
columnHeader = strings.TrimLeft(columnHeader, "#")
|
||||||
|
|
||||||
// Find index of each column header we
|
// Find index of each column header we
|
||||||
// care about, ensuring no duplicates.
|
// care about, ensuring no duplicates.
|
||||||
switch normal {
|
switch {
|
||||||
|
|
||||||
case "domain":
|
case columnHeader == "domain":
|
||||||
if domainI != nil {
|
if domainI != nil {
|
||||||
body.Close()
|
body.Close()
|
||||||
err := gtserror.NewfAt(3, "duplicate domain column header in csv: %+v", columnHeaders)
|
err := gtserror.NewfAt(3, "duplicate domain column header in csv: %+v", columnHeaders)
|
||||||
|
|
@ -578,7 +578,7 @@ func permsFromCSV(
|
||||||
}
|
}
|
||||||
domainI = &i
|
domainI = &i
|
||||||
|
|
||||||
case "severity":
|
case columnHeader == "severity":
|
||||||
if severityI != nil {
|
if severityI != nil {
|
||||||
body.Close()
|
body.Close()
|
||||||
err := gtserror.NewfAt(3, "duplicate severity column header in csv: %+v", columnHeaders)
|
err := gtserror.NewfAt(3, "duplicate severity column header in csv: %+v", columnHeaders)
|
||||||
|
|
@ -586,15 +586,15 @@ func permsFromCSV(
|
||||||
}
|
}
|
||||||
severityI = &i
|
severityI = &i
|
||||||
|
|
||||||
case "public_comment":
|
case columnHeader == "public_comment" || columnHeader == "comment":
|
||||||
if publicCommentI != nil {
|
if publicCommentI != nil {
|
||||||
body.Close()
|
body.Close()
|
||||||
err := gtserror.NewfAt(3, "duplicate public_comment column header in csv: %+v", columnHeaders)
|
err := gtserror.NewfAt(3, "duplicate public_comment or comment column header in csv: %+v", columnHeaders)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
publicCommentI = &i
|
publicCommentI = &i
|
||||||
|
|
||||||
case "obfuscate":
|
case columnHeader == "obfuscate":
|
||||||
if obfuscateI != nil {
|
if obfuscateI != nil {
|
||||||
body.Close()
|
body.Close()
|
||||||
err := gtserror.NewfAt(3, "duplicate obfuscate column header in csv: %+v", columnHeaders)
|
err := gtserror.NewfAt(3, "duplicate obfuscate column header in csv: %+v", columnHeaders)
|
||||||
|
|
@ -674,15 +674,15 @@ func permsFromCSV(
|
||||||
perm.SetPublicComment(record[*publicCommentI])
|
perm.SetPublicComment(record[*publicCommentI])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var obfuscate bool
|
||||||
if obfuscateI != nil {
|
if obfuscateI != nil {
|
||||||
obfuscate, err := strconv.ParseBool(record[*obfuscateI])
|
obfuscate, err = strconv.ParseBool(record[*obfuscateI])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Warnf("couldn't parse obfuscate field of record: %+v", record)
|
l.Warnf("couldn't parse obfuscate field of record: %+v", record)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
perm.SetObfuscate(&obfuscate)
|
|
||||||
}
|
}
|
||||||
|
perm.SetObfuscate(&obfuscate)
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
perms = append(perms, perm)
|
perms = append(perms, perm)
|
||||||
|
|
@ -793,9 +793,15 @@ func permsFromPlain(
|
||||||
var perm gtsmodel.DomainPermission
|
var perm gtsmodel.DomainPermission
|
||||||
switch permType {
|
switch permType {
|
||||||
case gtsmodel.DomainPermissionBlock:
|
case gtsmodel.DomainPermissionBlock:
|
||||||
perm = >smodel.DomainBlock{Domain: domain}
|
perm = >smodel.DomainBlock{
|
||||||
|
Domain: domain,
|
||||||
|
Obfuscate: util.Ptr(false),
|
||||||
|
}
|
||||||
case gtsmodel.DomainPermissionAllow:
|
case gtsmodel.DomainPermissionAllow:
|
||||||
perm = >smodel.DomainAllow{Domain: domain}
|
perm = >smodel.DomainAllow{
|
||||||
|
Domain: domain,
|
||||||
|
Obfuscate: util.Ptr(false),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue