mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-04 15:43:16 -06:00
Merge branch 'main' into feat/check-robots-for-derefinstance
This commit is contained in:
commit
cd6e6c80db
136 changed files with 2863 additions and 339 deletions
|
|
@ -145,12 +145,18 @@ func (m *Module) CallbackGETHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Since we require lowercase usernames at this point, lowercase the one
|
||||
// from the claims and use this to autofill the form with a suggestion.
|
||||
//
|
||||
// Pending https://github.com/superseriousbusiness/gotosocial/issues/1813
|
||||
suggestedUsername := strings.ToLower(claims.PreferredUsername)
|
||||
|
||||
page := apiutil.WebPage{
|
||||
Template: "finalize.tmpl",
|
||||
Instance: instance,
|
||||
Extra: map[string]any{
|
||||
"name": claims.Name,
|
||||
"preferredUsername": claims.PreferredUsername,
|
||||
"suggestedUsername": suggestedUsername,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -169,7 +170,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -216,7 +218,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -266,7 +269,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -313,7 +317,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -360,7 +365,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 1,
|
||||
"last_status_at": "2023-11-02",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -406,7 +412,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -453,7 +460,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -499,7 +507,8 @@ func (suite *AccountsGetTestSuite) TestAccountsGetFromTop() {
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, dst.String())
|
||||
|
|
@ -584,7 +593,8 @@ func (suite *AccountsGetTestSuite) TestAccountsMinID() {
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, dst.String())
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"target_account": {
|
||||
|
|
@ -247,7 +248,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -302,7 +304,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -357,7 +360,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -429,7 +433,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -476,7 +481,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"assigned_account": null,
|
||||
|
|
@ -525,7 +531,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetAll() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -683,7 +690,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -730,7 +738,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"assigned_account": null,
|
||||
|
|
@ -779,7 +788,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetCreatedByAccount() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -937,7 +947,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -984,7 +995,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"assigned_account": null,
|
||||
|
|
@ -1033,7 +1045,8 @@ func (suite *ReportsGetTestSuite) TestReportsGetTargetAccount() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ func (suite *GetTestSuite) TestGet() {
|
|||
"statuses_count": 1,
|
||||
"last_status_at": "2023-11-02",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
]`, dst.String())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
@ -333,7 +334,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
@ -475,7 +477,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
@ -668,7 +671,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
@ -836,7 +840,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
@ -1015,7 +1020,8 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ func (suite *MutesTestSuite) TestIndefinitelyMutedAccountSerializesMuteExpiratio
|
|||
|
||||
// Fetch all muted accounts for the logged-in account.
|
||||
// The expected body contains `"mute_expires_at":null`.
|
||||
_, err = suite.getMutedAccounts(http.StatusOK, `[{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"discoverable":true,"bot":false,"created_at":"2021-09-26T10:52:36.000Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.webp","header_static":"http://localhost:8080/assets/default_header.webp","header_description":"Flat gray background (default header).","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2024-11-01","emojis":[],"fields":[],"mute_expires_at":null}]`)
|
||||
_, err = suite.getMutedAccounts(http.StatusOK, `[{"id":"01F8MH5ZK5VRH73AKHQM6Y9VNX","username":"foss_satan","acct":"foss_satan@fossbros-anonymous.io","display_name":"big gerald","locked":false,"discoverable":true,"bot":false,"created_at":"2021-09-26T10:52:36.000Z","note":"i post about like, i dunno, stuff, or whatever!!!!","url":"http://fossbros-anonymous.io/@foss_satan","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.webp","header_static":"http://localhost:8080/assets/default_header.webp","header_description":"Flat gray background (default header).","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2024-11-01","emojis":[],"fields":[],"group":false,"mute_expires_at":null}]`)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ func (suite *ReportGetTestSuite) TestGetReport1() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ func (suite *ReportsGetTestSuite) TestGetReports() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, string(b))
|
||||
|
|
@ -250,7 +251,8 @@ func (suite *ReportsGetTestSuite) TestGetReports4() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, string(b))
|
||||
|
|
@ -325,7 +327,8 @@ func (suite *ReportsGetTestSuite) TestGetReports6() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, string(b))
|
||||
|
|
@ -384,7 +387,8 @@ func (suite *ReportsGetTestSuite) TestGetReports7() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}
|
||||
]`, string(b))
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ func (suite *StatusHistoryTestSuite) TestGetHistory() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"poll": null,
|
||||
"media_attachments": [],
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -227,7 +228,8 @@ func (suite *StatusMuteTestSuite) TestMuteUnmuteStatus() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ type Account struct {
|
|||
// If set, indicates that this account is currently inactive, and has migrated to the given account.
|
||||
// Key/value omitted for accounts that haven't moved, and for suspended accounts.
|
||||
Moved *Account `json:"moved,omitempty"`
|
||||
// Account identifies as a Group actor.
|
||||
Group bool `json:"group"`
|
||||
}
|
||||
|
||||
// WebAccount is like Account, but with
|
||||
|
|
|
|||
|
|
@ -92,10 +92,12 @@ type Configuration struct {
|
|||
InstanceSubscriptionsProcessEvery time.Duration `name:"instance-subscriptions-process-every" usage:"Period to elapse between instance subscriptions processing jobs, starting from instance-subscriptions-process-from."`
|
||||
InstanceStatsMode string `name:"instance-stats-mode" usage:"Allows you to customize the way stats are served to crawlers: one of '', 'serve', 'zero', 'baffle'. Home page stats remain unchanged."`
|
||||
|
||||
AccountsRegistrationOpen bool `name:"accounts-registration-open" usage:"Allow anyone to submit an account signup request. If false, server will be invite-only."`
|
||||
AccountsReasonRequired bool `name:"accounts-reason-required" usage:"Do new account signups require a reason to be submitted on registration?"`
|
||||
AccountsAllowCustomCSS bool `name:"accounts-allow-custom-css" usage:"Allow accounts to enable custom CSS for their profile pages and statuses."`
|
||||
AccountsCustomCSSLength int `name:"accounts-custom-css-length" usage:"Maximum permitted length (characters) of custom CSS for accounts."`
|
||||
AccountsRegistrationOpen bool `name:"accounts-registration-open" usage:"Allow anyone to submit an account signup request. If false, server will be invite-only."`
|
||||
AccountsReasonRequired bool `name:"accounts-reason-required" usage:"Do new account signups require a reason to be submitted on registration?"`
|
||||
AccountsRegistrationDailyLimit int `name:"accounts-registration-daily-limit" usage:"Limit amount of approved account sign-ups allowed per 24hrs before registration is closed. 0 or less = no limit."`
|
||||
AccountsRegistrationBacklogLimit int `name:"accounts-registration-backlog-limit" usage:"Limit how big the 'accounts pending approval' queue can grow before registration is closed. 0 or less = no limit."`
|
||||
AccountsAllowCustomCSS bool `name:"accounts-allow-custom-css" usage:"Allow accounts to enable custom CSS for their profile pages and statuses."`
|
||||
AccountsCustomCSSLength int `name:"accounts-custom-css-length" usage:"Maximum permitted length (characters) of custom CSS for accounts."`
|
||||
|
||||
MediaDescriptionMinChars int `name:"media-description-min-chars" usage:"Min required chars for an image description"`
|
||||
MediaDescriptionMaxChars int `name:"media-description-max-chars" usage:"Max permitted chars for an image description"`
|
||||
|
|
|
|||
|
|
@ -68,10 +68,12 @@ var Defaults = Configuration{
|
|||
InstanceSubscriptionsProcessFrom: "23:00", // 11pm,
|
||||
InstanceSubscriptionsProcessEvery: 24 * time.Hour, // 1/day.
|
||||
|
||||
AccountsRegistrationOpen: false,
|
||||
AccountsReasonRequired: true,
|
||||
AccountsAllowCustomCSS: false,
|
||||
AccountsCustomCSSLength: 10000,
|
||||
AccountsRegistrationOpen: false,
|
||||
AccountsReasonRequired: true,
|
||||
AccountsRegistrationDailyLimit: 10,
|
||||
AccountsRegistrationBacklogLimit: 20,
|
||||
AccountsAllowCustomCSS: false,
|
||||
AccountsCustomCSSLength: 10000,
|
||||
|
||||
MediaDescriptionMinChars: 0,
|
||||
MediaDescriptionMaxChars: 1500,
|
||||
|
|
|
|||
|
|
@ -1132,6 +1132,56 @@ func GetAccountsReasonRequired() bool { return global.GetAccountsReasonRequired(
|
|||
// SetAccountsReasonRequired safely sets the value for global configuration 'AccountsReasonRequired' field
|
||||
func SetAccountsReasonRequired(v bool) { global.SetAccountsReasonRequired(v) }
|
||||
|
||||
// GetAccountsRegistrationDailyLimit safely fetches the Configuration value for state's 'AccountsRegistrationDailyLimit' field
|
||||
func (st *ConfigState) GetAccountsRegistrationDailyLimit() (v int) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.AccountsRegistrationDailyLimit
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetAccountsRegistrationDailyLimit safely sets the Configuration value for state's 'AccountsRegistrationDailyLimit' field
|
||||
func (st *ConfigState) SetAccountsRegistrationDailyLimit(v int) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.AccountsRegistrationDailyLimit = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// AccountsRegistrationDailyLimitFlag returns the flag name for the 'AccountsRegistrationDailyLimit' field
|
||||
func AccountsRegistrationDailyLimitFlag() string { return "accounts-registration-daily-limit" }
|
||||
|
||||
// GetAccountsRegistrationDailyLimit safely fetches the value for global configuration 'AccountsRegistrationDailyLimit' field
|
||||
func GetAccountsRegistrationDailyLimit() int { return global.GetAccountsRegistrationDailyLimit() }
|
||||
|
||||
// SetAccountsRegistrationDailyLimit safely sets the value for global configuration 'AccountsRegistrationDailyLimit' field
|
||||
func SetAccountsRegistrationDailyLimit(v int) { global.SetAccountsRegistrationDailyLimit(v) }
|
||||
|
||||
// GetAccountsRegistrationBacklogLimit safely fetches the Configuration value for state's 'AccountsRegistrationBacklogLimit' field
|
||||
func (st *ConfigState) GetAccountsRegistrationBacklogLimit() (v int) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.AccountsRegistrationBacklogLimit
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetAccountsRegistrationBacklogLimit safely sets the Configuration value for state's 'AccountsRegistrationBacklogLimit' field
|
||||
func (st *ConfigState) SetAccountsRegistrationBacklogLimit(v int) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.AccountsRegistrationBacklogLimit = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// AccountsRegistrationBacklogLimitFlag returns the flag name for the 'AccountsRegistrationBacklogLimit' field
|
||||
func AccountsRegistrationBacklogLimitFlag() string { return "accounts-registration-backlog-limit" }
|
||||
|
||||
// GetAccountsRegistrationBacklogLimit safely fetches the value for global configuration 'AccountsRegistrationBacklogLimit' field
|
||||
func GetAccountsRegistrationBacklogLimit() int { return global.GetAccountsRegistrationBacklogLimit() }
|
||||
|
||||
// SetAccountsRegistrationBacklogLimit safely sets the value for global configuration 'AccountsRegistrationBacklogLimit' field
|
||||
func SetAccountsRegistrationBacklogLimit(v int) { global.SetAccountsRegistrationBacklogLimit(v) }
|
||||
|
||||
// GetAccountsAllowCustomCSS safely fetches the Configuration value for state's 'AccountsAllowCustomCSS' field
|
||||
func (st *ConfigState) GetAccountsAllowCustomCSS() (v bool) {
|
||||
st.mutex.RLock()
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ func (suite *NotificationTestSuite) TestStreamNotification() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}`, dst.String())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ func (suite *StatusUpdateTestSuite) TestStreamNotification() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,34 +44,43 @@ func (p *Processor) Create(
|
|||
app *gtsmodel.Application,
|
||||
form *apimodel.AccountCreateRequest,
|
||||
) (*gtsmodel.User, gtserror.WithCode) {
|
||||
const (
|
||||
usersPerDay = 10
|
||||
regBacklog = 20
|
||||
var (
|
||||
usersPerDay = config.GetAccountsRegistrationDailyLimit()
|
||||
regBacklog = config.GetAccountsRegistrationBacklogLimit()
|
||||
)
|
||||
|
||||
// Ensure no more than usersPerDay
|
||||
// If usersPerDay limit is in place,
|
||||
// ensure no more than usersPerDay
|
||||
// have registered in the last 24h.
|
||||
newUsersCount, err := p.state.DB.CountApprovedSignupsSince(ctx, time.Now().Add(-24*time.Hour))
|
||||
if err != nil {
|
||||
err := fmt.Errorf("db error counting new users: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
if usersPerDay > 0 {
|
||||
newUsersCount, err := p.state.DB.CountApprovedSignupsSince(ctx, time.Now().Add(-24*time.Hour))
|
||||
if err != nil {
|
||||
err := fmt.Errorf("db error counting new users: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
if newUsersCount >= usersPerDay {
|
||||
err := fmt.Errorf("this instance has hit its limit of new sign-ups for today (%d); you can try again tomorrow", usersPerDay)
|
||||
return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if newUsersCount >= usersPerDay {
|
||||
err := fmt.Errorf("this instance has hit its limit of new sign-ups for today; you can try again tomorrow")
|
||||
return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
|
||||
}
|
||||
// If registration backlog limit is
|
||||
// in place, ensure backlog isn't full.
|
||||
if regBacklog > 0 {
|
||||
backlogLen, err := p.state.DB.CountUnhandledSignups(ctx)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("db error counting registration backlog length: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// Ensure the new users backlog isn't full.
|
||||
backlogLen, err := p.state.DB.CountUnhandledSignups(ctx)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("db error counting registration backlog length: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
if backlogLen >= regBacklog {
|
||||
err := fmt.Errorf("this instance's sign-up backlog is currently full; you must wait until pending sign-ups are handled by the admin(s)")
|
||||
return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
|
||||
if backlogLen >= regBacklog {
|
||||
err := fmt.Errorf(
|
||||
"this instance's sign-up backlog is currently full (%d sign-ups pending approval); "+
|
||||
"you must wait until some pending sign-ups are handled by the admin(s)", regBacklog,
|
||||
)
|
||||
return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
emailAvailable, err := p.state.DB.IsEmailAvailable(ctx, form.Email)
|
||||
|
|
|
|||
74
internal/processing/user/create_test.go
Normal file
74
internal/processing/user/create_test.go
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
// GoToSocial
|
||||
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package user_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
)
|
||||
|
||||
type CreateTestSuite struct {
|
||||
UserStandardTestSuite
|
||||
}
|
||||
|
||||
func (suite *CreateTestSuite) TestCreateOK() {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
app = suite.testApps["application_1"]
|
||||
appToken = suite.testTokens["local_account_1_client_application_token"]
|
||||
form = &apimodel.AccountCreateRequest{
|
||||
Reason: "a long enough explanation of why I am doing api calls",
|
||||
Username: "someone_new",
|
||||
Email: "someone_new@example.org",
|
||||
Password: "a long enough password for this endpoint",
|
||||
Agreement: true,
|
||||
Locale: "en-us",
|
||||
IP: net.ParseIP("192.0.2.128"),
|
||||
}
|
||||
)
|
||||
|
||||
// Create user via the API endpoint.
|
||||
user, errWithCode := suite.user.Create(ctx, app, form)
|
||||
if errWithCode != nil {
|
||||
suite.FailNow(errWithCode.Error())
|
||||
}
|
||||
|
||||
// Load the app-level access token that was just used.
|
||||
appAccessToken, err := suite.oauthServer.LoadAccessToken(ctx, appToken.Access)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Create a user-level access token for the new user.
|
||||
userAccessToken, err := suite.user.TokenForNewUser(ctx, appAccessToken, app, user)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// Check returned user-level access token.
|
||||
suite.NotEmpty(userAccessToken.AccessToken)
|
||||
suite.Equal("Bearer", userAccessToken.TokenType)
|
||||
}
|
||||
|
||||
func TestCreateTestSuite(t *testing.T) {
|
||||
suite.Run(t, &CreateTestSuite{})
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ func New(
|
|||
return Processor{
|
||||
state: state,
|
||||
converter: converter,
|
||||
oauthServer: oauthServer,
|
||||
emailSender: emailSender,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/email"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing/user"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
|
|
@ -34,9 +35,11 @@ type UserStandardTestSuite struct {
|
|||
emailSender email.Sender
|
||||
db db.DB
|
||||
state state.State
|
||||
oauthServer oauth.Server
|
||||
|
||||
testUsers map[string]*gtsmodel.User
|
||||
|
||||
testApps map[string]*gtsmodel.Application
|
||||
testTokens map[string]*gtsmodel.Token
|
||||
testUsers map[string]*gtsmodel.User
|
||||
sentEmails map[string]string
|
||||
|
||||
user user.Processor
|
||||
|
|
@ -51,9 +54,12 @@ func (suite *UserStandardTestSuite) SetupTest() {
|
|||
suite.db = testrig.NewTestDB(&suite.state)
|
||||
suite.state.DB = suite.db
|
||||
suite.state.AdminActions = admin.New(suite.state.DB, &suite.state.Workers)
|
||||
suite.oauthServer = testrig.NewTestOauthServer(suite.state.DB)
|
||||
|
||||
suite.sentEmails = make(map[string]string)
|
||||
suite.emailSender = testrig.NewEmailSender("../../../web/template/", suite.sentEmails)
|
||||
suite.testApps = testrig.NewTestApplications()
|
||||
suite.testTokens = testrig.NewTestTokens()
|
||||
suite.testUsers = testrig.NewTestUsers()
|
||||
|
||||
suite.user = user.New(&suite.state, typeutils.NewConverter(&suite.state), testrig.NewTestOauthServer(suite.db), suite.emailSender)
|
||||
|
|
|
|||
|
|
@ -388,6 +388,7 @@ func (c *Converter) accountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
|||
EnableRSS: enableRSS,
|
||||
HideCollections: hideCollections,
|
||||
Roles: roles,
|
||||
Group: false,
|
||||
}
|
||||
|
||||
// Bodge default avatar + header in,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontend() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -178,8 +179,10 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendAliasedAndMoved()
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
}
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +233,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiStruct()
|
|||
}
|
||||
],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +283,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendWithEmojiIDs() {
|
|||
}
|
||||
],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +338,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendSensitive() {
|
|||
"color": "",
|
||||
"permissions": "0",
|
||||
"highlighted": false
|
||||
}
|
||||
},
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -370,7 +376,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode()
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +416,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPubl
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -448,7 +456,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc
|
|||
"statuses_count": 0,
|
||||
"last_status_at": null,
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}`, string(b))
|
||||
}
|
||||
|
||||
|
|
@ -516,7 +525,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -695,7 +705,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -879,7 +890,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -1014,7 +1026,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredBoostToFrontend() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -1301,7 +1314,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments
|
|||
"statuses_count": 1,
|
||||
"last_status_at": "2023-11-02",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -1466,7 +1480,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() {
|
|||
"statuses_count": 1,
|
||||
"last_status_at": "2023-11-02",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -1608,7 +1623,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage()
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -1748,7 +1764,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendPartialInteraction
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -1863,7 +1880,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIStatusPendingApproval()
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [
|
||||
|
|
@ -2075,7 +2093,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"max_toot_chars": 5000,
|
||||
"rules": [],
|
||||
|
|
@ -2227,7 +2246,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"rules": [],
|
||||
|
|
@ -2340,7 +2360,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
|
|
@ -2396,7 +2417,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
}
|
||||
}`, string(b))
|
||||
}
|
||||
|
|
@ -2461,7 +2483,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"target_account": {
|
||||
|
|
@ -2519,7 +2542,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -2574,7 +2598,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -2629,7 +2654,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -2711,7 +2737,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGY43H3N2C8EWPR2FPYEXG"
|
||||
},
|
||||
|
|
@ -2758,7 +2785,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"assigned_account": null,
|
||||
|
|
@ -2807,7 +2835,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() {
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [
|
||||
{
|
||||
|
|
@ -2966,7 +2995,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
|
|||
"statuses_count": 4,
|
||||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
"fields": [],
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"target_account": {
|
||||
|
|
@ -3014,7 +3044,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
|
|||
"emojis": [],
|
||||
"fields": [],
|
||||
"suspended": true,
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
}
|
||||
},
|
||||
"assigned_account": {
|
||||
|
|
@ -3068,7 +3099,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -3123,7 +3155,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"created_by_application_id": "01F8MGXQRHYF5QPMTMXP78QC2F"
|
||||
},
|
||||
|
|
@ -3270,7 +3303,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"status": {
|
||||
"id": "01F8MHC8VWDRBQR0N1BATDDEM5",
|
||||
|
|
@ -3331,7 +3365,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -3421,7 +3456,8 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
|
|||
"name": "admin",
|
||||
"color": ""
|
||||
}
|
||||
]
|
||||
],
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [
|
||||
|
|
@ -3531,7 +3567,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
}
|
||||
],
|
||||
"last_status": {
|
||||
|
|
@ -3585,7 +3622,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -3698,7 +3736,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
|
|||
"verified_at": null
|
||||
}
|
||||
],
|
||||
"hide_collections": true
|
||||
"hide_collections": true,
|
||||
"group": false
|
||||
}
|
||||
],
|
||||
"last_status": {
|
||||
|
|
@ -3752,7 +3791,8 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"media_attachments": [],
|
||||
"mentions": [],
|
||||
|
|
@ -3837,7 +3877,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"poll": null,
|
||||
"media_attachments": [],
|
||||
|
|
@ -3873,7 +3914,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"poll": null,
|
||||
"media_attachments": [],
|
||||
|
|
@ -3909,7 +3951,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() {
|
|||
"last_status_at": "2024-11-01",
|
||||
"emojis": [],
|
||||
"fields": [],
|
||||
"enable_rss": true
|
||||
"enable_rss": true,
|
||||
"group": false
|
||||
},
|
||||
"poll": null,
|
||||
"media_attachments": [],
|
||||
|
|
|
|||
|
|
@ -192,6 +192,11 @@ func (r *realSender) sendToSubscription(
|
|||
// while waiting for the client to retrieve them.
|
||||
TTL = 48 * time.Hour
|
||||
|
||||
// recordSize limits how big our notifications can be once padding is applied.
|
||||
// To be polite to applications that need to relay them over services like APNS,
|
||||
// which has a max message size of 4 kB, we set this comfortably smaller.
|
||||
recordSize = 2048
|
||||
|
||||
// responseBodyMaxLen limits how much of the Web Push server response we read for error messages.
|
||||
responseBodyMaxLen = 1024
|
||||
)
|
||||
|
|
@ -232,6 +237,7 @@ func (r *realSender) sendToSubscription(
|
|||
},
|
||||
&webpushgo.Options{
|
||||
HTTPClient: r.httpClient,
|
||||
RecordSize: recordSize,
|
||||
Subscriber: "https://" + config.GetHost(),
|
||||
VAPIDPublicKey: vapidKeyPair.Public,
|
||||
VAPIDPrivateKey: vapidKeyPair.Private,
|
||||
|
|
@ -346,8 +352,9 @@ func formatNotificationTitle(
|
|||
// or the beginning of the bio text of the related account.
|
||||
func formatNotificationBody(apiNotification *apimodel.Notification) string {
|
||||
// bodyMaxLen is a polite maximum length for a Web Push notification's body text, in bytes. Note that this isn't
|
||||
// limited per se, but Web Push servers may reject anything with a total request body size over 4k.
|
||||
const bodyMaxLen = 3000
|
||||
// limited per se, but Web Push servers may reject anything with a total request body size over 4k,
|
||||
// and we set a lower max size above for compatibility with mobile push systems.
|
||||
const bodyMaxLen = 1500
|
||||
|
||||
var body string
|
||||
if apiNotification.Status != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue