mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-04-16 22:34:05 +00: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(`[
|
||||
{
|
||||
"domain": "bumfaces.net",
|
||||
"public_comment": "big jerks"
|
||||
"public_comment": "big jerks",
|
||||
"obfuscate": false,
|
||||
"private_comment": ""
|
||||
},
|
||||
{
|
||||
"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())
|
||||
|
||||
|
@ -177,13 +184,22 @@ func (suite *DomainPermissionSubscriptionTestTestSuite) TestDomainPermissionSubs
|
|||
// Ensure expected.
|
||||
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())
|
||||
|
||||
|
|
|
@ -564,13 +564,13 @@ func permsFromCSV(
|
|||
|
||||
for i, columnHeader := range columnHeaders {
|
||||
// Remove leading # if present.
|
||||
normal := strings.TrimLeft(columnHeader, "#")
|
||||
columnHeader = strings.TrimLeft(columnHeader, "#")
|
||||
|
||||
// Find index of each column header we
|
||||
// care about, ensuring no duplicates.
|
||||
switch normal {
|
||||
switch {
|
||||
|
||||
case "domain":
|
||||
case columnHeader == "domain":
|
||||
if domainI != nil {
|
||||
body.Close()
|
||||
err := gtserror.NewfAt(3, "duplicate domain column header in csv: %+v", columnHeaders)
|
||||
|
@ -578,7 +578,7 @@ func permsFromCSV(
|
|||
}
|
||||
domainI = &i
|
||||
|
||||
case "severity":
|
||||
case columnHeader == "severity":
|
||||
if severityI != nil {
|
||||
body.Close()
|
||||
err := gtserror.NewfAt(3, "duplicate severity column header in csv: %+v", columnHeaders)
|
||||
|
@ -586,15 +586,15 @@ func permsFromCSV(
|
|||
}
|
||||
severityI = &i
|
||||
|
||||
case "public_comment":
|
||||
case columnHeader == "public_comment" || columnHeader == "comment":
|
||||
if publicCommentI != nil {
|
||||
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
|
||||
}
|
||||
publicCommentI = &i
|
||||
|
||||
case "obfuscate":
|
||||
case columnHeader == "obfuscate":
|
||||
if obfuscateI != nil {
|
||||
body.Close()
|
||||
err := gtserror.NewfAt(3, "duplicate obfuscate column header in csv: %+v", columnHeaders)
|
||||
|
@ -674,15 +674,15 @@ func permsFromCSV(
|
|||
perm.SetPublicComment(record[*publicCommentI])
|
||||
}
|
||||
|
||||
var obfuscate bool
|
||||
if obfuscateI != nil {
|
||||
obfuscate, err := strconv.ParseBool(record[*obfuscateI])
|
||||
obfuscate, err = strconv.ParseBool(record[*obfuscateI])
|
||||
if err != nil {
|
||||
l.Warnf("couldn't parse obfuscate field of record: %+v", record)
|
||||
continue
|
||||
}
|
||||
|
||||
perm.SetObfuscate(&obfuscate)
|
||||
}
|
||||
perm.SetObfuscate(&obfuscate)
|
||||
|
||||
// We're done.
|
||||
perms = append(perms, perm)
|
||||
|
@ -793,9 +793,15 @@ func permsFromPlain(
|
|||
var perm gtsmodel.DomainPermission
|
||||
switch permType {
|
||||
case gtsmodel.DomainPermissionBlock:
|
||||
perm = >smodel.DomainBlock{Domain: domain}
|
||||
perm = >smodel.DomainBlock{
|
||||
Domain: domain,
|
||||
Obfuscate: util.Ptr(false),
|
||||
}
|
||||
case gtsmodel.DomainPermissionAllow:
|
||||
perm = >smodel.DomainAllow{Domain: domain}
|
||||
perm = >smodel.DomainAllow{
|
||||
Domain: domain,
|
||||
Obfuscate: util.Ptr(false),
|
||||
}
|
||||
}
|
||||
|
||||
// We're done.
|
||||
|
|
Loading…
Reference in a new issue