Skip to content

Commit 3973bb3

Browse files
committed
Remove RS_ prefix
1 parent bd5c9a9 commit 3973bb3

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

docs/api.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The rageshake server will respond with a specific JSON payload when encountering
8787
```json
8888
{
8989
"error": "A human readable error string.",
90-
"errcode": "RS_UNKNOWN",
90+
"errcode": "UNKNOWN",
9191
"policy_url": "https://github.com/matrix-org/rageshake/blob/master/docs/blocked_rageshake.md"
9292
}
9393
```
@@ -100,16 +100,16 @@ Where the fields are as follows:
100100

101101
### Error codes
102102

103-
- `RS_UNKNOWN` is a catch-all error when the appliation does not have a specific error.
104-
- `RS_METHOD_NOT_ALLOWED` is reported when you have used the wrong method for an endpoint. E.g. GET instead of POST.
105-
- `RS_DISALLOWED_APP` is reported when a report was rejected due to the report being sent from an unsupported
103+
- `UNKNOWN` is a catch-all error when the appliation does not have a specific error.
104+
- `METHOD_NOT_ALLOWED` is reported when you have used the wrong method for an endpoint. E.g. GET instead of POST.
105+
- `DISALLOWED_APP` is reported when a report was rejected due to the report being sent from an unsupported
106106
app (see the `allowed_app_names` config option).
107-
- `RS_BAD_HEADER` is reported when a header was not able to be parsed, such as `Content-Length`.
108-
- `RS_CONTENT_TOO_LARGE` is reported when the reported content size is too large.
109-
- `RS_BAD_CONTENT` is reported when the reports content could not be parsed.
110-
- `RS_REJECTED` is reported when the submission could be understood but was rejected by `rejection_conditions`.
107+
- `BAD_HEADER` is reported when a header was not able to be parsed, such as `Content-Length`.
108+
- `CONTENT_TOO_LARGE` is reported when the reported content size is too large.
109+
- `BAD_CONTENT` is reported when the reports content could not be parsed.
110+
- `REJECTED` is reported when the submission could be understood but was rejected by `rejection_conditions`.
111111
This is the default value, see below for more information.
112112

113113
In addition to these error codes, the configuration allows application developers to specify specific error codes
114-
for report rejection under the `RS_REJECTED_*` namespace. (see the `rejection_conditions` config option). Consult the
114+
for report rejection under the `REJECTED_*` namespace. (see the `rejection_conditions` config option). Consult the
115115
administrator of your rageshake server in order to determine what error codes may be presented.

errors.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package main
22
const (
33
// ErrCodeBadContent is reported when the reports content could not be parsed.
4-
ErrCodeBadContent = "RS_BAD_CONTENT";
4+
ErrCodeBadContent = "BAD_CONTENT";
55
// ErrCodeBadHeader is reported when a header was not able to be parsed.
6-
ErrCodeBadHeader = "RS_BAD_HEADER";
6+
ErrCodeBadHeader = "BAD_HEADER";
77
// ErrCodeContentTooLarge is reported when the reported content size is too large.
8-
ErrCodeContentTooLarge = "RS_CONTENT_TOO_LARGE";
8+
ErrCodeContentTooLarge = "CONTENT_TOO_LARGE";
99
// ErrCodeDisallowedApp is reported when a report was rejected due to the report being sent from an unsupported
10-
ErrCodeDisallowedApp = "RS_DISALLOWED_APP";
10+
ErrCodeDisallowedApp = "DISALLOWED_APP";
1111
// ErrCodeMethodNotAllowed is reported when you have used the wrong method for an endpoint.
12-
ErrCodeMethodNotAllowed = "RS_METHOD_NOT_ALLOWED";
12+
ErrCodeMethodNotAllowed = "METHOD_NOT_ALLOWED";
1313
// ErrCodeRejected is reported when the submission could be understood but was rejected by RejectionConditions.
14-
ErrCodeRejected = "RS_REJECTED";
14+
ErrCodeRejected = "REJECTED";
1515
// ErrCodeUnknown is a catch-all error when the appliation does not have a specific error.
16-
ErrCodeUnknown = "RS_UNKNOWN";
16+
ErrCodeUnknown = "UNKNOWN";
1717
)

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ type RejectionCondition struct {
115115
UserTextMatch string `yaml:"usertext"`
116116
// Send this text to the client-side to inform the user why the server rejects the rageshake. Uses a default generic value if empty.
117117
Reason string `yaml:"reason"`
118-
// Send this text to the client-side to inform the user why the server rejects the rageshake. Uses a default error code RS_REJECTED if empty.
118+
// Send this text to the client-side to inform the user why the server rejects the rageshake. Uses a default error code REJECTED if empty.
119119
ErrorCode string `yaml:"errorcode"`
120120
}
121121

@@ -355,8 +355,8 @@ func loadConfig(configPath string) (*config, error) {
355355
}
356356

357357
for idx, condition := range cfg.RejectionConditions {
358-
if condition.ErrorCode != "" && !strings.HasPrefix(condition.ErrorCode, "RS_REJECTED_") {
359-
return nil, fmt.Errorf("Rejected condition %d was invalid. `errorcode` must be use the namespace RS_REJECTED_", idx);
358+
if condition.ErrorCode != "" && !strings.HasPrefix(condition.ErrorCode, "REJECTED_") {
359+
return nil, fmt.Errorf("Rejected condition %d was invalid. `errorcode` must be use the namespace REJECTED_", idx);
360360
}
361361
}
362362
return &cfg, nil

main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ func TestConfigRejectionCondition(t *testing.T) {
1818
Version: "0.1.2",
1919
Label: "nightly",
2020
Reason: "no nightlies",
21-
ErrorCode: "RS_BAD_VERSION",
21+
ErrorCode: "BAD_VERSION",
2222
},
2323
{
2424
App: "block-my-app",
2525
},
2626
{
2727
UserTextMatch: "(\\w{4}\\s){11}\\w{4}",
2828
Reason: "it matches a recovery key and recovery keys are private",
29-
ErrorCode: "RS_EXPOSED_RECOVERY_KEY",
29+
ErrorCode: "EXPOSED_RECOVERY_KEY",
3030
},
3131
},
3232
}
@@ -55,7 +55,7 @@ func TestConfigRejectionCondition(t *testing.T) {
5555
Data: map[string]string{
5656
"Version": "0.1.2",
5757
"ExpectedRejectReason": "no nightlies",
58-
"ExpectedErrorCode": "RS_BAD_VERSION",
58+
"ExpectedErrorCode": "BAD_VERSION",
5959
},
6060
},
6161
{
@@ -95,7 +95,7 @@ func TestConfigRejectionCondition(t *testing.T) {
9595
UserText: "Looks like a recover key abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd",
9696
Data: map[string]string{
9797
"ExpectedRejectReason": "it matches a recovery key and recovery keys are private",
98-
"ExpectedErrorCode": "RS_EXPOSED_RECOVERY_KEY",
98+
"ExpectedErrorCode": "EXPOSED_RECOVERY_KEY",
9999
},
100100
},
101101
}

rageshake.sample.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ allowed_app_names: []
1313
# If any submission matches one of these rejection conditions, the submission is rejected.
1414
# A condition is made by an union of optional fields: app, version, labels, user text. They all need to match for rejecting the rageshake
1515
# It can also contain an optional reason to explain why this server is rejecting a user's submission.
16-
# An errorcode can be provided to give a precise machine-readable error description under the `RS_REJECTED_` namespace.
17-
# Otherwise, this defaults to RS_REJECTED.
16+
# An errorcode can be provided to give a precise machine-readable error description under the `REJECTED_` namespace.
17+
# Otherwise, this defaults to REJECTED.
1818
rejection_conditions:
1919
- app: my-app
2020
version: "0.4.9" # if the submission has a Version which is exactly this value, reject the submission.
@@ -24,10 +24,10 @@ rejection_conditions:
2424
version: "0.4.9"
2525
label: "nightly" # both label and Version must match for this condition to be true
2626
reason: "this server does not accept rageshakes from nightlies"
27-
errorcode: "RS_REJECTED_BAD_VERSION"
27+
errorcode: "REJECTED_BAD_VERSION"
2828
- usertext: "(\\w{4}\\s){11}\\w{4}" # reject text containing possible recovery keys
2929
reason: "it matches a recovery key and recovery keys are private"
30-
errorcode: "RS_REJECTED_UNEXPECTED_RECOVERY_KEY"
30+
errorcode: "REJECTED_UNEXPECTED_RECOVERY_KEY"
3131

3232
# a GitHub personal access token (https://github.com/settings/tokens), which
3333
# will be used to create a GitHub issue for each report. It requires

submit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (s *submitServer) handleSubmission(w http.ResponseWriter, req *http.Request
231231
log.Printf("Unable to remove report dir %s after rejected upload: %v\n",
232232
reportDir, err)
233233
}
234-
writeError(w, 400, submitErrorResponse{"This server does not accept rageshakes from your application.", "RS_DISALLOWED_APP", "https://github.com/matrix-org/rageshake/blob/master/docs/blocked_rageshake.md"})
234+
writeError(w, 400, submitErrorResponse{"This server does not accept rageshakes from your application.", ErrCodeDisallowedApp, "https://github.com/matrix-org/rageshake/blob/master/docs/blocked_rageshake.md"})
235235
return
236236
}
237237
rejection, code := s.cfg.matchesRejectionCondition(p)

0 commit comments

Comments
 (0)