mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-26 21:56:39 +00:00
Compare commits
13 commits
d04a89e3af
...
46dae1d33c
Author | SHA1 | Date | |
---|---|---|---|
46dae1d33c | |||
c023bd30f3 | |||
18e2f69e85 | |||
f0376635ad | |||
5c055afa08 | |||
c33b1e89c1 | |||
36abd568b1 | |||
37a3d224a7 | |||
d3d6e3f920 | |||
8bd8c6fb45 | |||
f550f596fa | |||
23b6d2cc64 | |||
c8fb4c17f1 |
|
@ -177,6 +177,10 @@ It's also easy for admins to [add their own custom themes](https://docs.gotosoci
|
||||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-midnight-trip.png"/>
|
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-midnight-trip.png"/>
|
||||||
<figcaption>Midnight trip</figcaption>
|
<figcaption>Midnight trip</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
<figure>
|
||||||
|
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-moonlight-hunt.png"/>
|
||||||
|
<figcaption>Moonlight hunt</figcaption>
|
||||||
|
</figure>
|
||||||
<hr/>
|
<hr/>
|
||||||
<figure>
|
<figure>
|
||||||
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-rainforest.png"/>
|
<img src="https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/docs/assets/theme-rainforest.png"/>
|
||||||
|
|
|
@ -167,3 +167,11 @@ Links to the set contact account and/or email address will appear on the footer
|
||||||
The selected **contact user** must be an active (not suspended) admin and/or moderator on the instance.
|
The selected **contact user** must be an active (not suspended) admin and/or moderator on the instance.
|
||||||
|
|
||||||
If you're on a single-user instance and you give admin privileges to your main account, you can just fill in your own username here; you don't need to make a separate admin account just for this.
|
If you're on a single-user instance and you give admin privileges to your main account, you can just fill in your own username here; you don't need to make a separate admin account just for this.
|
||||||
|
|
||||||
|
### Instance Custom CSS
|
||||||
|
|
||||||
|
custom CSS allows you to further customize the way your instance looks when visited through a browser.
|
||||||
|
|
||||||
|
This custom CSS will be applied to all pages of your instance. Users themes and CSS still take precedence over this customization.
|
||||||
|
|
||||||
|
See the [Custom CSS](./custom_css.md) page for some tips on writing custom CSS for your instance.
|
||||||
|
|
|
@ -950,7 +950,12 @@ definitions:
|
||||||
with "direct message" visibility.
|
with "direct message" visibility.
|
||||||
properties:
|
properties:
|
||||||
accounts:
|
accounts:
|
||||||
description: Participants in the conversation.
|
description: |-
|
||||||
|
Participants in the conversation.
|
||||||
|
|
||||||
|
If this is a conversation between no accounts (ie., a self-directed DM),
|
||||||
|
this will include only the requesting account itself. Otherwise, it will
|
||||||
|
include every other account in the conversation *except* the requester.
|
||||||
items:
|
items:
|
||||||
$ref: '#/definitions/account'
|
$ref: '#/definitions/account'
|
||||||
type: array
|
type: array
|
||||||
|
@ -1545,6 +1550,10 @@ definitions:
|
||||||
$ref: '#/definitions/instanceV1Configuration'
|
$ref: '#/definitions/instanceV1Configuration'
|
||||||
contact_account:
|
contact_account:
|
||||||
$ref: '#/definitions/account'
|
$ref: '#/definitions/account'
|
||||||
|
custom_css:
|
||||||
|
description: Custom CSS for the instance.
|
||||||
|
type: string
|
||||||
|
x-go-name: CustomCSS
|
||||||
debug:
|
debug:
|
||||||
description: Whether or not instance is running in DEBUG mode. Omitted if false.
|
description: Whether or not instance is running in DEBUG mode. Omitted if false.
|
||||||
type: boolean
|
type: boolean
|
||||||
|
@ -1725,6 +1734,10 @@ definitions:
|
||||||
$ref: '#/definitions/instanceV2Configuration'
|
$ref: '#/definitions/instanceV2Configuration'
|
||||||
contact:
|
contact:
|
||||||
$ref: '#/definitions/instanceV2Contact'
|
$ref: '#/definitions/instanceV2Contact'
|
||||||
|
custom_css:
|
||||||
|
description: Instance Custom Css
|
||||||
|
type: string
|
||||||
|
x-go-name: CustomCSS
|
||||||
debug:
|
debug:
|
||||||
description: Whether or not instance is running in DEBUG mode. Omitted if false.
|
description: Whether or not instance is running in DEBUG mode. Omitted if false.
|
||||||
type: boolean
|
type: boolean
|
||||||
|
@ -8942,7 +8955,7 @@ paths:
|
||||||
Providing this parameter will cause ScheduledStatus to be returned instead of Status.
|
Providing this parameter will cause ScheduledStatus to be returned instead of Status.
|
||||||
Must be at least 5 minutes in the future.
|
Must be at least 5 minutes in the future.
|
||||||
|
|
||||||
This feature isn't implemented yet.
|
This feature isn't implemented yet; attemping to set it will return 501 Not Implemented.
|
||||||
in: formData
|
in: formData
|
||||||
name: scheduled_at
|
name: scheduled_at
|
||||||
type: string
|
type: string
|
||||||
|
@ -9003,6 +9016,8 @@ paths:
|
||||||
description: not acceptable
|
description: not acceptable
|
||||||
"500":
|
"500":
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
"501":
|
||||||
|
description: scheduled_at was set, but this feature is not yet implemented
|
||||||
security:
|
security:
|
||||||
- OAuth2 Bearer:
|
- OAuth2 Bearer:
|
||||||
- write:statuses
|
- write:statuses
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 229 KiB |
BIN
docs/assets/theme-moonlight-hunt.png
Normal file
BIN
docs/assets/theme-moonlight-hunt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 682 KiB |
|
@ -80,10 +80,18 @@ host: "localhost"
|
||||||
# Default: ""
|
# Default: ""
|
||||||
account-domain: ""
|
account-domain: ""
|
||||||
|
|
||||||
# String. Protocol to use for the server. Only change to http for local testing!
|
# String. Protocol over which the server is reachable from the outside world.
|
||||||
# This should be the protocol part of the URI that your server is actually reachable on. So even if you're
|
#
|
||||||
# running GoToSocial behind a reverse proxy that handles SSL certificates for you, instead of using built-in
|
# ONLY CHANGE THIS TO HTTP FOR LOCAL TESTING! IN 99.99% OF CASES YOU SHOULD NOT CHANGE THIS!
|
||||||
# letsencrypt, it should still be https.
|
#
|
||||||
|
# This should be the protocol part of the URI that your server is actually reachable on.
|
||||||
|
# So even if you're running GoToSocial behind a reverse proxy that handles SSL certificates
|
||||||
|
# for you, instead of using built-in letsencrypt, it should still be https, not http.
|
||||||
|
#
|
||||||
|
# Again, ONLY CHANGE THIS TO HTTP FOR LOCAL TESTING! If you set this to `http`, start your instance,
|
||||||
|
# and then later change it to `https`, you will have already broken URI generation for any created
|
||||||
|
# users on the instance. You should only touch this setting if you 100% know what you're doing.
|
||||||
|
#
|
||||||
# Options: ["http","https"]
|
# Options: ["http","https"]
|
||||||
# Default: "https"
|
# Default: "https"
|
||||||
protocol: "https"
|
protocol: "https"
|
||||||
|
|
|
@ -88,10 +88,18 @@ host: "localhost"
|
||||||
# Default: ""
|
# Default: ""
|
||||||
account-domain: ""
|
account-domain: ""
|
||||||
|
|
||||||
# String. Protocol to use for the server. Only change to http for local testing!
|
# String. Protocol over which the server is reachable from the outside world.
|
||||||
# This should be the protocol part of the URI that your server is actually reachable on. So even if you're
|
#
|
||||||
# running GoToSocial behind a reverse proxy that handles SSL certificates for you, instead of using built-in
|
# ONLY CHANGE THIS TO HTTP FOR LOCAL TESTING! IN 99.99% OF CASES YOU SHOULD NOT CHANGE THIS!
|
||||||
# letsencrypt, it should still be https.
|
#
|
||||||
|
# This should be the protocol part of the URI that your server is actually reachable on.
|
||||||
|
# So even if you're running GoToSocial behind a reverse proxy that handles SSL certificates
|
||||||
|
# for you, instead of using built-in letsencrypt, it should still be https, not http.
|
||||||
|
#
|
||||||
|
# Again, ONLY CHANGE THIS TO HTTP FOR LOCAL TESTING! If you set this to `http`, start your instance,
|
||||||
|
# and then later change it to `https`, you will have already broken URI generation for any created
|
||||||
|
# users on the instance. You should only touch this setting if you 100% know what you're doing.
|
||||||
|
#
|
||||||
# Options: ["http","https"]
|
# Options: ["http","https"]
|
||||||
# Default: "https"
|
# Default: "https"
|
||||||
protocol: "https"
|
protocol: "https"
|
||||||
|
|
|
@ -175,6 +175,7 @@ func validateInstanceUpdate(form *apimodel.InstanceSettingsUpdateRequest) error
|
||||||
form.ContactEmail == nil &&
|
form.ContactEmail == nil &&
|
||||||
form.ShortDescription == nil &&
|
form.ShortDescription == nil &&
|
||||||
form.Description == nil &&
|
form.Description == nil &&
|
||||||
|
form.CustomCSS == nil &&
|
||||||
form.Terms == nil &&
|
form.Terms == nil &&
|
||||||
form.Avatar == nil &&
|
form.Avatar == nil &&
|
||||||
form.AvatarDescription == nil &&
|
form.AvatarDescription == nil &&
|
||||||
|
|
|
@ -181,7 +181,7 @@
|
||||||
// Providing this parameter will cause ScheduledStatus to be returned instead of Status.
|
// Providing this parameter will cause ScheduledStatus to be returned instead of Status.
|
||||||
// Must be at least 5 minutes in the future.
|
// Must be at least 5 minutes in the future.
|
||||||
//
|
//
|
||||||
// This feature isn't implemented yet.
|
// This feature isn't implemented yet; attemping to set it will return 501 Not Implemented.
|
||||||
// type: string
|
// type: string
|
||||||
// in: formData
|
// in: formData
|
||||||
// -
|
// -
|
||||||
|
@ -254,6 +254,8 @@
|
||||||
// description: not acceptable
|
// description: not acceptable
|
||||||
// '500':
|
// '500':
|
||||||
// description: internal server error
|
// description: internal server error
|
||||||
|
// '501':
|
||||||
|
// description: scheduled_at was set, but this feature is not yet implemented
|
||||||
func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {
|
func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {
|
||||||
authed, err := oauth.Authed(c, true, true, true, true)
|
authed, err := oauth.Authed(c, true, true, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -286,8 +288,8 @@ func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {
|
||||||
// }
|
// }
|
||||||
// form.Status += "\n\nsent from " + user + "'s iphone\n"
|
// form.Status += "\n\nsent from " + user + "'s iphone\n"
|
||||||
|
|
||||||
if err := validateNormalizeCreateStatus(form); err != nil {
|
if errWithCode := validateStatusCreateForm(form); errWithCode != nil {
|
||||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,46 +376,61 @@ func parseStatusCreateForm(c *gin.Context) (*apimodel.StatusCreateRequest, error
|
||||||
return form, nil
|
return form, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateNormalizeCreateStatus checks the form
|
// validateStatusCreateForm checks the form for disallowed
|
||||||
// for disallowed combinations of attachments and
|
// combinations of attachments, overlength inputs, etc.
|
||||||
// overlength inputs.
|
|
||||||
//
|
//
|
||||||
// Side effect: normalizes the post's language tag.
|
// Side effect: normalizes the post's language tag.
|
||||||
func validateNormalizeCreateStatus(form *apimodel.StatusCreateRequest) error {
|
func validateStatusCreateForm(form *apimodel.StatusCreateRequest) gtserror.WithCode {
|
||||||
hasStatus := form.Status != ""
|
var (
|
||||||
hasMedia := len(form.MediaIDs) != 0
|
chars = len([]rune(form.Status)) + len([]rune(form.SpoilerText))
|
||||||
hasPoll := form.Poll != nil
|
maxChars = config.GetStatusesMaxChars()
|
||||||
|
mediaFiles = len(form.MediaIDs)
|
||||||
|
maxMediaFiles = config.GetStatusesMediaMaxFiles()
|
||||||
|
hasMedia = mediaFiles != 0
|
||||||
|
hasPoll = form.Poll != nil
|
||||||
|
)
|
||||||
|
|
||||||
if !hasStatus && !hasMedia && !hasPoll {
|
if chars == 0 && !hasMedia && !hasPoll {
|
||||||
return errors.New("no status, media, or poll provided")
|
// Status must contain *some* kind of content.
|
||||||
|
const text = "no status content, content warning, media, or poll provided"
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasMedia && hasPoll {
|
if chars > maxChars {
|
||||||
return errors.New("can't post media + poll in same status")
|
text := fmt.Sprintf(
|
||||||
|
"status too long, %d characters provided (including content warning) but limit is %d",
|
||||||
|
chars, maxChars,
|
||||||
|
)
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
maxChars := config.GetStatusesMaxChars()
|
if mediaFiles > maxMediaFiles {
|
||||||
if length := len([]rune(form.Status)) + len([]rune(form.SpoilerText)); length > maxChars {
|
text := fmt.Sprintf(
|
||||||
return fmt.Errorf("status too long, %d characters provided (including spoiler/content warning) but limit is %d", length, maxChars)
|
"too many media files attached to status, %d attached but limit is %d",
|
||||||
}
|
mediaFiles, maxMediaFiles,
|
||||||
|
)
|
||||||
maxMediaFiles := config.GetStatusesMediaMaxFiles()
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
if len(form.MediaIDs) > maxMediaFiles {
|
|
||||||
return fmt.Errorf("too many media files attached to status, %d attached but limit is %d", len(form.MediaIDs), maxMediaFiles)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Poll != nil {
|
if form.Poll != nil {
|
||||||
if err := validateNormalizeCreatePoll(form); err != nil {
|
if errWithCode := validateStatusPoll(form); errWithCode != nil {
|
||||||
return err
|
return errWithCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Language != "" {
|
if form.ScheduledAt != "" {
|
||||||
language, err := validate.Language(form.Language)
|
const text = "scheduled_at is not yet implemented"
|
||||||
if err != nil {
|
return gtserror.NewErrorNotImplemented(errors.New(text), text)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
form.Language = language
|
|
||||||
|
// Validate + normalize
|
||||||
|
// language tag if provided.
|
||||||
|
if form.Language != "" {
|
||||||
|
lang, err := validate.Language(form.Language)
|
||||||
|
if err != nil {
|
||||||
|
return gtserror.NewErrorBadRequest(err, err.Error())
|
||||||
|
}
|
||||||
|
form.Language = lang
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the deprecated "federated" field was
|
// Check if the deprecated "federated" field was
|
||||||
|
@ -425,9 +442,36 @@ func validateNormalizeCreateStatus(form *apimodel.StatusCreateRequest) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateNormalizeCreatePoll(form *apimodel.StatusCreateRequest) error {
|
func validateStatusPoll(form *apimodel.StatusCreateRequest) gtserror.WithCode {
|
||||||
maxPollOptions := config.GetStatusesPollMaxOptions()
|
var (
|
||||||
maxPollChars := config.GetStatusesPollOptionMaxChars()
|
maxPollOptions = config.GetStatusesPollMaxOptions()
|
||||||
|
pollOptions = len(form.Poll.Options)
|
||||||
|
maxPollOptionChars = config.GetStatusesPollOptionMaxChars()
|
||||||
|
)
|
||||||
|
|
||||||
|
if pollOptions == 0 {
|
||||||
|
const text = "poll with no options"
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pollOptions > maxPollOptions {
|
||||||
|
text := fmt.Sprintf(
|
||||||
|
"too many poll options provided, %d provided but limit is %d",
|
||||||
|
pollOptions, maxPollOptions,
|
||||||
|
)
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, option := range form.Poll.Options {
|
||||||
|
optionChars := len([]rune(option))
|
||||||
|
if optionChars > maxPollOptionChars {
|
||||||
|
text := fmt.Sprintf(
|
||||||
|
"poll option too long, %d characters provided but limit is %d",
|
||||||
|
optionChars, maxPollOptionChars,
|
||||||
|
)
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize poll expiry if necessary.
|
// Normalize poll expiry if necessary.
|
||||||
// If we parsed this as JSON, expires_in
|
// If we parsed this as JSON, expires_in
|
||||||
|
@ -440,27 +484,15 @@ func validateNormalizeCreatePoll(form *apimodel.StatusCreateRequest) error {
|
||||||
case string:
|
case string:
|
||||||
expiresIn, err := strconv.Atoi(e)
|
expiresIn, err := strconv.Atoi(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not parse expires_in value %s as integer: %w", e, err)
|
text := fmt.Sprintf("could not parse expires_in value %s as integer: %v", e, err)
|
||||||
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
form.Poll.ExpiresIn = expiresIn
|
form.Poll.ExpiresIn = expiresIn
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("could not parse expires_in type %T as integer", ei)
|
text := fmt.Sprintf("could not parse expires_in type %T as integer", ei)
|
||||||
}
|
return gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
}
|
|
||||||
|
|
||||||
if len(form.Poll.Options) == 0 {
|
|
||||||
return errors.New("poll with no options")
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(form.Poll.Options) > maxPollOptions {
|
|
||||||
return fmt.Errorf("too many poll options provided, %d provided but limit is %d", len(form.Poll.Options), maxPollOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, p := range form.Poll.Options {
|
|
||||||
if length := len([]rune(p)); length > maxPollChars {
|
|
||||||
return fmt.Errorf("poll option too long, %d characters provided but limit is %d", length, maxPollChars)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,25 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusMessedUpIntPolicy() {
|
||||||
}`, out)
|
}`, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *StatusCreateTestSuite) TestPostNewScheduledStatus() {
|
||||||
|
out, recorder := suite.postStatus(map[string][]string{
|
||||||
|
"status": {"this is a brand new status! #helloworld"},
|
||||||
|
"spoiler_text": {"hello hello"},
|
||||||
|
"sensitive": {"true"},
|
||||||
|
"visibility": {string(apimodel.VisibilityMutualsOnly)},
|
||||||
|
"scheduled_at": {"2080-10-04T15:32:02.018Z"},
|
||||||
|
}, "")
|
||||||
|
|
||||||
|
// We should have 501 from
|
||||||
|
// our call to the function.
|
||||||
|
suite.Equal(http.StatusNotImplemented, recorder.Code)
|
||||||
|
|
||||||
|
// We should have a helpful error message.
|
||||||
|
suite.Equal(`{
|
||||||
|
"error": "Not Implemented: scheduled_at is not yet implemented"
|
||||||
|
}`, out)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() {
|
func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() {
|
||||||
out, recorder := suite.postStatus(map[string][]string{
|
out, recorder := suite.postStatus(map[string][]string{
|
||||||
"status": {statusMarkdown},
|
"status": {statusMarkdown},
|
||||||
|
|
|
@ -27,6 +27,10 @@ type Conversation struct {
|
||||||
// Is the conversation currently marked as unread?
|
// Is the conversation currently marked as unread?
|
||||||
Unread bool `json:"unread"`
|
Unread bool `json:"unread"`
|
||||||
// Participants in the conversation.
|
// Participants in the conversation.
|
||||||
|
//
|
||||||
|
// If this is a conversation between no accounts (ie., a self-directed DM),
|
||||||
|
// this will include only the requesting account itself. Otherwise, it will
|
||||||
|
// include every other account in the conversation *except* the requester.
|
||||||
Accounts []Account `json:"accounts"`
|
Accounts []Account `json:"accounts"`
|
||||||
// The last status in the conversation. May be `null`.
|
// The last status in the conversation. May be `null`.
|
||||||
LastStatus *Status `json:"last_status"`
|
LastStatus *Status `json:"last_status"`
|
||||||
|
|
|
@ -33,6 +33,8 @@ type InstanceSettingsUpdateRequest struct {
|
||||||
ShortDescription *string `form:"short_description" json:"short_description" xml:"short_description"`
|
ShortDescription *string `form:"short_description" json:"short_description" xml:"short_description"`
|
||||||
// Longer description of the instance, max 5,000 chars. HTML formatting accepted.
|
// Longer description of the instance, max 5,000 chars. HTML formatting accepted.
|
||||||
Description *string `form:"description" json:"description" xml:"description"`
|
Description *string `form:"description" json:"description" xml:"description"`
|
||||||
|
// Custom CSS for the instance.
|
||||||
|
CustomCSS *string `form:"custom_css" json:"custom_css,omitempty" xml:"custom_css"`
|
||||||
// Terms and conditions of the instance, max 5,000 chars. HTML formatting accepted.
|
// Terms and conditions of the instance, max 5,000 chars. HTML formatting accepted.
|
||||||
Terms *string `form:"terms" json:"terms" xml:"terms"`
|
Terms *string `form:"terms" json:"terms" xml:"terms"`
|
||||||
// Image to use as the instance thumbnail.
|
// Image to use as the instance thumbnail.
|
||||||
|
|
|
@ -38,6 +38,8 @@ type InstanceV1 struct {
|
||||||
//
|
//
|
||||||
// This should be displayed on the 'about' page for an instance.
|
// This should be displayed on the 'about' page for an instance.
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
// Custom CSS for the instance.
|
||||||
|
CustomCSS string `json:"custom_css,omitempty"`
|
||||||
// Raw (unparsed) version of description.
|
// Raw (unparsed) version of description.
|
||||||
DescriptionText string `json:"description_text,omitempty"`
|
DescriptionText string `json:"description_text,omitempty"`
|
||||||
// A shorter description of the instance.
|
// A shorter description of the instance.
|
||||||
|
|
|
@ -53,6 +53,8 @@ type InstanceV2 struct {
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
// Raw (unparsed) version of description.
|
// Raw (unparsed) version of description.
|
||||||
DescriptionText string `json:"description_text,omitempty"`
|
DescriptionText string `json:"description_text,omitempty"`
|
||||||
|
// Instance Custom Css
|
||||||
|
CustomCSS string `json:"custom_css,omitempty"`
|
||||||
// Basic anonymous usage data for this instance.
|
// Basic anonymous usage data for this instance.
|
||||||
Usage InstanceV2Usage `json:"usage"`
|
Usage InstanceV2Usage `json:"usage"`
|
||||||
// An image used to represent this instance.
|
// An image used to represent this instance.
|
||||||
|
|
|
@ -302,9 +302,9 @@ func (i *interactionDB) GetInteractionsRequestsForAcct(
|
||||||
bun.Ident("interaction_request"),
|
bun.Ident("interaction_request"),
|
||||||
).
|
).
|
||||||
// Select only interaction requests that
|
// Select only interaction requests that
|
||||||
// are neither accepted or rejected yet,
|
// are neither accepted or rejected yet.
|
||||||
// ie., without an Accept or Reject URI.
|
Where("? IS NULL", bun.Ident("accepted_at")).
|
||||||
Where("? IS NULL", bun.Ident("uri"))
|
Where("? IS NULL", bun.Ident("rejected_at"))
|
||||||
|
|
||||||
// Select interactions targeting status.
|
// Select interactions targeting status.
|
||||||
if statusID != "" {
|
if statusID != "" {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
// 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 migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
up := func(ctx context.Context, db *bun.DB) error {
|
||||||
|
_, err := db.ExecContext(ctx, "ALTER TABLE ? ADD COLUMN ? TEXT", bun.Ident("instances"), bun.Ident("custom_css"))
|
||||||
|
if err != nil && !(strings.Contains(err.Error(), "already exists") || strings.Contains(err.Error(), "duplicate column name") || strings.Contains(err.Error(), "SQLSTATE 42701")) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
down := func(ctx context.Context, db *bun.DB) error {
|
||||||
|
_, err := db.ExecContext(ctx, "ALTER TABLE ? DROP COLUMN ?", bun.Ident("instances"), bun.Ident("custom_css"))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := Migrations.Register(up, down); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
// 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 migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/uptrace/bun"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
up := func(ctx context.Context, db *bun.DB) error {
|
||||||
|
return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||||
|
for idx, col := range map[string]string{
|
||||||
|
"interaction_requests_accepted_at_idx": "accepted_at",
|
||||||
|
"interaction_requests_rejected_at_idx": "rejected_at",
|
||||||
|
} {
|
||||||
|
if _, err := tx.
|
||||||
|
NewCreateIndex().
|
||||||
|
Table("interaction_requests").
|
||||||
|
Index(idx).
|
||||||
|
Column(col).
|
||||||
|
IfNotExists().
|
||||||
|
Exec(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
down := func(ctx context.Context, db *bun.DB) error {
|
||||||
|
return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := Migrations.Register(up, down); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,7 +112,7 @@ func (c *sqliteConn) Close() (err error) {
|
||||||
raw := c.connIface.(sqlite3driver.Conn).Raw()
|
raw := c.connIface.(sqlite3driver.Conn).Raw()
|
||||||
|
|
||||||
// see: https://www.sqlite.org/pragma.html#pragma_optimize
|
// see: https://www.sqlite.org/pragma.html#pragma_optimize
|
||||||
const onClose = "PRAGMA analysis_limit=1000; PRAGMA optimize;"
|
const onClose = "PRAGMA optimize;"
|
||||||
_ = raw.Exec(onClose)
|
_ = raw.Exec(onClose)
|
||||||
|
|
||||||
// Finally, close.
|
// Finally, close.
|
||||||
|
|
|
@ -170,12 +170,6 @@ func (f *federatingActor) PostInboxScheme(ctx context.Context, w http.ResponseWr
|
||||||
//
|
//
|
||||||
// Post the activity to the Actor's inbox and trigger side effects.
|
// Post the activity to the Actor's inbox and trigger side effects.
|
||||||
if err := f.sideEffectActor.PostInbox(ctx, inboxID, activity); err != nil {
|
if err := f.sideEffectActor.PostInbox(ctx, inboxID, activity); err != nil {
|
||||||
// Check if a function in the federatingDB
|
|
||||||
// has returned an explicit errWithCode for us.
|
|
||||||
if errWithCode, ok := err.(gtserror.WithCode); ok {
|
|
||||||
return false, errWithCode
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if it's a bad request because the
|
// Check if it's a bad request because the
|
||||||
// object or target props weren't populated,
|
// object or target props weren't populated,
|
||||||
// or we failed parsing activity details.
|
// or we failed parsing activity details.
|
||||||
|
@ -193,6 +187,12 @@ func (f *federatingActor) PostInboxScheme(ctx context.Context, w http.ResponseWr
|
||||||
return false, gtserror.NewErrorBadRequest(errors.New(text), text)
|
return false, gtserror.NewErrorBadRequest(errors.New(text), text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a function in the federatingDB
|
||||||
|
// has returned an explicit errWithCode for us.
|
||||||
|
if errWithCode, ok := err.(gtserror.WithCode); ok {
|
||||||
|
return false, errWithCode
|
||||||
|
}
|
||||||
|
|
||||||
// Default: there's been some real error.
|
// Default: there's been some real error.
|
||||||
err := gtserror.Newf("error calling sideEffectActor.PostInbox: %w", err)
|
err := gtserror.Newf("error calling sideEffectActor.PostInbox: %w", err)
|
||||||
return false, gtserror.NewErrorInternalError(err)
|
return false, gtserror.NewErrorInternalError(err)
|
||||||
|
|
|
@ -306,7 +306,7 @@ func (f *Filter) StatusBoostable(
|
||||||
status.InteractionPolicy.CanAnnounce,
|
status.InteractionPolicy.CanAnnounce,
|
||||||
)
|
)
|
||||||
|
|
||||||
// If status is local and has no policy set,
|
// If status has no policy set but it's local,
|
||||||
// check against the default policy for this
|
// check against the default policy for this
|
||||||
// visibility, as we're interaction-policy aware.
|
// visibility, as we're interaction-policy aware.
|
||||||
case *status.Local:
|
case *status.Local:
|
||||||
|
@ -318,13 +318,21 @@ func (f *Filter) StatusBoostable(
|
||||||
policy.CanAnnounce,
|
policy.CanAnnounce,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Otherwise, assume the status is from an
|
// Status is from an instance that does not use
|
||||||
// instance that does not use / does not care
|
// or does not care about interaction policies.
|
||||||
// about interaction policies, and just return OK.
|
// We can boost it if it's unlisted or public.
|
||||||
default:
|
case status.Visibility == gtsmodel.VisibilityPublic ||
|
||||||
|
status.Visibility == gtsmodel.VisibilityUnlocked:
|
||||||
return >smodel.PolicyCheckResult{
|
return >smodel.PolicyCheckResult{
|
||||||
Permission: gtsmodel.PolicyPermissionPermitted,
|
Permission: gtsmodel.PolicyPermissionPermitted,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
|
// Not permitted by any of the
|
||||||
|
// above checks, so it's forbidden.
|
||||||
|
default:
|
||||||
|
return >smodel.PolicyCheckResult{
|
||||||
|
Permission: gtsmodel.PolicyPermissionForbidden,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,19 @@ func NewErrorGone(original error, helpText ...string) WithCode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewErrorNotImplemented returns an ErrorWithCode 501 with the given original error and optional help text.
|
||||||
|
func NewErrorNotImplemented(original error, helpText ...string) WithCode {
|
||||||
|
safe := http.StatusText(http.StatusNotImplemented)
|
||||||
|
if helpText != nil {
|
||||||
|
safe = safe + ": " + strings.Join(helpText, ": ")
|
||||||
|
}
|
||||||
|
return withCode{
|
||||||
|
original: original,
|
||||||
|
safe: errors.New(safe),
|
||||||
|
code: http.StatusNotImplemented,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewErrorClientClosedRequest returns an ErrorWithCode 499 with the given original error.
|
// NewErrorClientClosedRequest returns an ErrorWithCode 499 with the given original error.
|
||||||
// This error type should only be used when an http caller has already hung up their request.
|
// This error type should only be used when an http caller has already hung up their request.
|
||||||
// See: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#nginx
|
// See: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#nginx
|
||||||
|
|
|
@ -34,6 +34,7 @@ type Instance struct {
|
||||||
ShortDescriptionText string `bun:""` // Raw text version of short description (before parsing).
|
ShortDescriptionText string `bun:""` // Raw text version of short description (before parsing).
|
||||||
Description string `bun:""` // Longer description of this instance.
|
Description string `bun:""` // Longer description of this instance.
|
||||||
DescriptionText string `bun:""` // Raw text version of long description (before parsing).
|
DescriptionText string `bun:""` // Raw text version of long description (before parsing).
|
||||||
|
CustomCSS string `bun:",nullzero"` // Custom CSS for the instance.
|
||||||
Terms string `bun:""` // Terms and conditions of this instance.
|
Terms string `bun:""` // Terms and conditions of this instance.
|
||||||
TermsText string `bun:""` // Raw text version of terms (before parsing).
|
TermsText string `bun:""` // Raw text version of terms (before parsing).
|
||||||
ContactEmail string `bun:""` // Contact email address for this instance
|
ContactEmail string `bun:""` // Contact email address for this instance
|
||||||
|
|
|
@ -247,6 +247,12 @@ func (p *Processor) GetVisibleAPIStatuses(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if apiStatus == nil {
|
||||||
|
// Status was
|
||||||
|
// filtered out.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Append converted status to return slice.
|
// Append converted status to return slice.
|
||||||
apiStatuses = append(apiStatuses, *apiStatus)
|
apiStatuses = append(apiStatuses, *apiStatus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,17 @@ func (p *Processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSe
|
||||||
columns = append(columns, []string{"description", "description_text"}...)
|
columns = append(columns, []string{"description", "description_text"}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate & update site custom css if it's set on the form
|
||||||
|
if form.CustomCSS != nil {
|
||||||
|
customCSS := *form.CustomCSS
|
||||||
|
if err := validate.InstanceCustomCSS(customCSS); err != nil {
|
||||||
|
return nil, gtserror.NewErrorBadRequest(err, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.CustomCSS = text.SanitizeToPlaintext(customCSS)
|
||||||
|
columns = append(columns, []string{"custom_css"}...)
|
||||||
|
}
|
||||||
|
|
||||||
// Validate & update site
|
// Validate & update site
|
||||||
// terms if set on the form.
|
// terms if set on the form.
|
||||||
if form.Terms != nil {
|
if form.Terms != nil {
|
||||||
|
|
|
@ -1523,6 +1523,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
|
||||||
Title: i.Title,
|
Title: i.Title,
|
||||||
Description: i.Description,
|
Description: i.Description,
|
||||||
DescriptionText: i.DescriptionText,
|
DescriptionText: i.DescriptionText,
|
||||||
|
CustomCSS: i.CustomCSS,
|
||||||
ShortDescription: i.ShortDescription,
|
ShortDescription: i.ShortDescription,
|
||||||
ShortDescriptionText: i.ShortDescriptionText,
|
ShortDescriptionText: i.ShortDescriptionText,
|
||||||
Email: i.ContactEmail,
|
Email: i.ContactEmail,
|
||||||
|
@ -1644,6 +1645,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
|
||||||
SourceURL: instanceSourceURL,
|
SourceURL: instanceSourceURL,
|
||||||
Description: i.Description,
|
Description: i.Description,
|
||||||
DescriptionText: i.DescriptionText,
|
DescriptionText: i.DescriptionText,
|
||||||
|
CustomCSS: i.CustomCSS,
|
||||||
Usage: apimodel.InstanceV2Usage{}, // todo: not implemented
|
Usage: apimodel.InstanceV2Usage{}, // todo: not implemented
|
||||||
Languages: config.GetInstanceLanguages().TagStrs(),
|
Languages: config.GetInstanceLanguages().TagStrs(),
|
||||||
Rules: c.InstanceRulesToAPIRules(i.Rules),
|
Rules: c.InstanceRulesToAPIRules(i.Rules),
|
||||||
|
@ -1832,46 +1834,23 @@ func (c *Converter) NotificationToAPINotification(
|
||||||
func (c *Converter) ConversationToAPIConversation(
|
func (c *Converter) ConversationToAPIConversation(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conversation *gtsmodel.Conversation,
|
conversation *gtsmodel.Conversation,
|
||||||
requestingAccount *gtsmodel.Account,
|
requester *gtsmodel.Account,
|
||||||
filters []*gtsmodel.Filter,
|
filters []*gtsmodel.Filter,
|
||||||
mutes *usermute.CompiledUserMuteList,
|
mutes *usermute.CompiledUserMuteList,
|
||||||
) (*apimodel.Conversation, error) {
|
) (*apimodel.Conversation, error) {
|
||||||
apiConversation := &apimodel.Conversation{
|
apiConversation := &apimodel.Conversation{
|
||||||
ID: conversation.ID,
|
ID: conversation.ID,
|
||||||
Unread: !*conversation.Read,
|
Unread: !*conversation.Read,
|
||||||
Accounts: []apimodel.Account{},
|
|
||||||
}
|
|
||||||
for _, account := range conversation.OtherAccounts {
|
|
||||||
var apiAccount *apimodel.Account
|
|
||||||
blocked, err := c.state.DB.IsEitherBlocked(ctx, requestingAccount.ID, account.ID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf(
|
|
||||||
"DB error checking blocks between accounts %s and %s: %w",
|
|
||||||
requestingAccount.ID,
|
|
||||||
account.ID,
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if blocked || account.IsSuspended() {
|
|
||||||
apiAccount, err = c.AccountToAPIAccountBlocked(ctx, account)
|
|
||||||
} else {
|
|
||||||
apiAccount, err = c.AccountToAPIAccountPublic(ctx, account)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, gtserror.Newf(
|
|
||||||
"error converting account %s to API representation: %w",
|
|
||||||
account.ID,
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
apiConversation.Accounts = append(apiConversation.Accounts, *apiAccount)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Populate most recent status in convo;
|
||||||
|
// can be nil if this status is filtered.
|
||||||
if conversation.LastStatus != nil {
|
if conversation.LastStatus != nil {
|
||||||
var err error
|
var err error
|
||||||
apiConversation.LastStatus, err = c.StatusToAPIStatus(
|
apiConversation.LastStatus, err = c.StatusToAPIStatus(
|
||||||
ctx,
|
ctx,
|
||||||
conversation.LastStatus,
|
conversation.LastStatus,
|
||||||
requestingAccount,
|
requester,
|
||||||
statusfilter.FilterContextNotifications,
|
statusfilter.FilterContextNotifications,
|
||||||
filters,
|
filters,
|
||||||
mutes,
|
mutes,
|
||||||
|
@ -1885,6 +1864,60 @@ func (c *Converter) ConversationToAPIConversation(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no other accounts are involved in this convo,
|
||||||
|
// just include the requesting account and return.
|
||||||
|
//
|
||||||
|
// See: https://github.com/superseriousbusiness/gotosocial/issues/3385#issuecomment-2394033477
|
||||||
|
otherAcctsLen := len(conversation.OtherAccounts)
|
||||||
|
if otherAcctsLen == 0 {
|
||||||
|
apiAcct, err := c.AccountToAPIAccountPublic(ctx, requester)
|
||||||
|
if err != nil {
|
||||||
|
err := gtserror.Newf(
|
||||||
|
"error converting account %s to API representation: %w",
|
||||||
|
requester.ID, err,
|
||||||
|
)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
apiConversation.Accounts = []apimodel.Account{*apiAcct}
|
||||||
|
return apiConversation, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other accounts are involved in the
|
||||||
|
// convo. Convert each to API model.
|
||||||
|
apiConversation.Accounts = make([]apimodel.Account, otherAcctsLen)
|
||||||
|
for i, account := range conversation.OtherAccounts {
|
||||||
|
blocked, err := c.state.DB.IsEitherBlocked(ctx,
|
||||||
|
requester.ID, account.ID,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
err := gtserror.Newf(
|
||||||
|
"db error checking blocks between accounts %s and %s: %w",
|
||||||
|
requester.ID, account.ID, err,
|
||||||
|
)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// API account model varies depending
|
||||||
|
// on status of conversation participant.
|
||||||
|
var apiAcct *apimodel.Account
|
||||||
|
if blocked || account.IsSuspended() {
|
||||||
|
apiAcct, err = c.AccountToAPIAccountBlocked(ctx, account)
|
||||||
|
} else {
|
||||||
|
apiAcct, err = c.AccountToAPIAccountPublic(ctx, account)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
err := gtserror.Newf(
|
||||||
|
"error converting account %s to API representation: %w",
|
||||||
|
account.ID, err,
|
||||||
|
)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
apiConversation.Accounts[i] = *apiAcct
|
||||||
|
}
|
||||||
|
|
||||||
return apiConversation, nil
|
return apiConversation, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2680,7 +2713,7 @@ func (c *Converter) InteractionReqToAPIInteractionReq(
|
||||||
}
|
}
|
||||||
|
|
||||||
var reply *apimodel.Status
|
var reply *apimodel.Status
|
||||||
if req.InteractionType == gtsmodel.InteractionReply {
|
if req.InteractionType == gtsmodel.InteractionReply && req.Reply != nil {
|
||||||
reply, err = c.statusToAPIStatus(
|
reply, err = c.statusToAPIStatus(
|
||||||
ctx,
|
ctx,
|
||||||
req.Reply,
|
req.Reply,
|
||||||
|
|
|
@ -3358,6 +3358,321 @@ func (suite *InternalToFrontendTestSuite) TestIntReqToAPI() {
|
||||||
}`, string(b))
|
}`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *InternalToFrontendTestSuite) TestConversationToAPISelfConvo() {
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
requester = suite.testAccounts["local_account_1"]
|
||||||
|
lastStatus = suite.testStatuses["local_account_1_status_1"]
|
||||||
|
filters []*gtsmodel.Filter = nil
|
||||||
|
mutes *usermute.CompiledUserMuteList = nil
|
||||||
|
)
|
||||||
|
|
||||||
|
convo := >smodel.Conversation{
|
||||||
|
ID: "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||||
|
CreatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||||
|
UpdatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||||
|
AccountID: requester.ID,
|
||||||
|
Account: requester,
|
||||||
|
OtherAccounts: nil,
|
||||||
|
LastStatus: lastStatus,
|
||||||
|
Read: util.Ptr(true),
|
||||||
|
}
|
||||||
|
|
||||||
|
apiConvo, err := suite.typeconverter.ConversationToAPIConversation(
|
||||||
|
ctx,
|
||||||
|
convo,
|
||||||
|
requester,
|
||||||
|
filters,
|
||||||
|
mutes,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := json.MarshalIndent(apiConvo, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// No other accounts involved, so we should only
|
||||||
|
// have our own account in the "accounts" field.
|
||||||
|
suite.Equal(`{
|
||||||
|
"id": "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||||
|
"unread": false,
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||||
|
"username": "the_mighty_zork",
|
||||||
|
"acct": "the_mighty_zork",
|
||||||
|
"display_name": "original zork (he/they)",
|
||||||
|
"locked": false,
|
||||||
|
"discoverable": true,
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2022-05-20T11:09:18.000Z",
|
||||||
|
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||||
|
"url": "http://localhost:8080/@the_mighty_zork",
|
||||||
|
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||||
|
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||||
|
"avatar_description": "a green goblin looking nasty",
|
||||||
|
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||||
|
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||||
|
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||||
|
"followers_count": 2,
|
||||||
|
"following_count": 2,
|
||||||
|
"statuses_count": 8,
|
||||||
|
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [],
|
||||||
|
"enable_rss": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"last_status": {
|
||||||
|
"id": "01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"created_at": "2021-10-20T10:40:37.000Z",
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"sensitive": true,
|
||||||
|
"spoiler_text": "introduction post",
|
||||||
|
"visibility": "public",
|
||||||
|
"language": "en",
|
||||||
|
"uri": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"url": "http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"replies_count": 2,
|
||||||
|
"reblogs_count": 1,
|
||||||
|
"favourites_count": 1,
|
||||||
|
"favourited": false,
|
||||||
|
"reblogged": false,
|
||||||
|
"muted": false,
|
||||||
|
"bookmarked": false,
|
||||||
|
"pinned": false,
|
||||||
|
"content": "hello everyone!",
|
||||||
|
"reblog": null,
|
||||||
|
"application": {
|
||||||
|
"name": "really cool gts application",
|
||||||
|
"website": "https://reallycool.app"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||||
|
"username": "the_mighty_zork",
|
||||||
|
"acct": "the_mighty_zork",
|
||||||
|
"display_name": "original zork (he/they)",
|
||||||
|
"locked": false,
|
||||||
|
"discoverable": true,
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2022-05-20T11:09:18.000Z",
|
||||||
|
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||||
|
"url": "http://localhost:8080/@the_mighty_zork",
|
||||||
|
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||||
|
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||||
|
"avatar_description": "a green goblin looking nasty",
|
||||||
|
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||||
|
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||||
|
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||||
|
"followers_count": 2,
|
||||||
|
"following_count": 2,
|
||||||
|
"statuses_count": 8,
|
||||||
|
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [],
|
||||||
|
"enable_rss": true
|
||||||
|
},
|
||||||
|
"media_attachments": [],
|
||||||
|
"mentions": [],
|
||||||
|
"tags": [],
|
||||||
|
"emojis": [],
|
||||||
|
"card": null,
|
||||||
|
"poll": null,
|
||||||
|
"text": "hello everyone!",
|
||||||
|
"interaction_policy": {
|
||||||
|
"can_favourite": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
},
|
||||||
|
"can_reply": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
},
|
||||||
|
"can_reblog": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`, string(b))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
|
||||||
|
var (
|
||||||
|
ctx = context.Background()
|
||||||
|
requester = suite.testAccounts["local_account_1"]
|
||||||
|
lastStatus = suite.testStatuses["local_account_1_status_1"]
|
||||||
|
filters []*gtsmodel.Filter = nil
|
||||||
|
mutes *usermute.CompiledUserMuteList = nil
|
||||||
|
)
|
||||||
|
|
||||||
|
convo := >smodel.Conversation{
|
||||||
|
ID: "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||||
|
CreatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||||
|
UpdatedAt: testrig.TimeMustParse("2022-06-10T15:22:08Z"),
|
||||||
|
AccountID: requester.ID,
|
||||||
|
Account: requester,
|
||||||
|
OtherAccounts: []*gtsmodel.Account{
|
||||||
|
suite.testAccounts["local_account_2"],
|
||||||
|
},
|
||||||
|
LastStatus: lastStatus,
|
||||||
|
Read: util.Ptr(false),
|
||||||
|
}
|
||||||
|
|
||||||
|
apiConvo, err := suite.typeconverter.ConversationToAPIConversation(
|
||||||
|
ctx,
|
||||||
|
convo,
|
||||||
|
requester,
|
||||||
|
filters,
|
||||||
|
mutes,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := json.MarshalIndent(apiConvo, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// One other account is involved, so they
|
||||||
|
// should in the "accounts" field and not us.
|
||||||
|
suite.Equal(`{
|
||||||
|
"id": "01J9C6K86PKZ5GY5WXV94DGH6R",
|
||||||
|
"unread": true,
|
||||||
|
"accounts": [
|
||||||
|
{
|
||||||
|
"id": "01F8MH5NBDF2MV7CTC4Q5128HF",
|
||||||
|
"username": "1happyturtle",
|
||||||
|
"acct": "1happyturtle",
|
||||||
|
"display_name": "happy little turtle :3",
|
||||||
|
"locked": true,
|
||||||
|
"discoverable": false,
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2022-06-04T13:12:00.000Z",
|
||||||
|
"note": "\u003cp\u003ei post about things that concern me\u003c/p\u003e",
|
||||||
|
"url": "http://localhost:8080/@1happyturtle",
|
||||||
|
"avatar": "",
|
||||||
|
"avatar_static": "",
|
||||||
|
"header": "http://localhost:8080/assets/default_header.webp",
|
||||||
|
"header_static": "http://localhost:8080/assets/default_header.webp",
|
||||||
|
"followers_count": 1,
|
||||||
|
"following_count": 1,
|
||||||
|
"statuses_count": 8,
|
||||||
|
"last_status_at": "2021-07-28T08:40:37.000Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "should you follow me?",
|
||||||
|
"value": "maybe!",
|
||||||
|
"verified_at": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "age",
|
||||||
|
"value": "120",
|
||||||
|
"verified_at": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hide_collections": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"last_status": {
|
||||||
|
"id": "01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"created_at": "2021-10-20T10:40:37.000Z",
|
||||||
|
"in_reply_to_id": null,
|
||||||
|
"in_reply_to_account_id": null,
|
||||||
|
"sensitive": true,
|
||||||
|
"spoiler_text": "introduction post",
|
||||||
|
"visibility": "public",
|
||||||
|
"language": "en",
|
||||||
|
"uri": "http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"url": "http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY",
|
||||||
|
"replies_count": 2,
|
||||||
|
"reblogs_count": 1,
|
||||||
|
"favourites_count": 1,
|
||||||
|
"favourited": false,
|
||||||
|
"reblogged": false,
|
||||||
|
"muted": false,
|
||||||
|
"bookmarked": false,
|
||||||
|
"pinned": false,
|
||||||
|
"content": "hello everyone!",
|
||||||
|
"reblog": null,
|
||||||
|
"application": {
|
||||||
|
"name": "really cool gts application",
|
||||||
|
"website": "https://reallycool.app"
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
"id": "01F8MH1H7YV1Z7D2C8K2730QBF",
|
||||||
|
"username": "the_mighty_zork",
|
||||||
|
"acct": "the_mighty_zork",
|
||||||
|
"display_name": "original zork (he/they)",
|
||||||
|
"locked": false,
|
||||||
|
"discoverable": true,
|
||||||
|
"bot": false,
|
||||||
|
"created_at": "2022-05-20T11:09:18.000Z",
|
||||||
|
"note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
|
||||||
|
"url": "http://localhost:8080/@the_mighty_zork",
|
||||||
|
"avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
|
||||||
|
"avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
|
||||||
|
"avatar_description": "a green goblin looking nasty",
|
||||||
|
"header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
|
||||||
|
"header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
|
||||||
|
"header_description": "A very old-school screenshot of the original team fortress mod for quake",
|
||||||
|
"followers_count": 2,
|
||||||
|
"following_count": 2,
|
||||||
|
"statuses_count": 8,
|
||||||
|
"last_status_at": "2024-01-10T09:24:00.000Z",
|
||||||
|
"emojis": [],
|
||||||
|
"fields": [],
|
||||||
|
"enable_rss": true
|
||||||
|
},
|
||||||
|
"media_attachments": [],
|
||||||
|
"mentions": [],
|
||||||
|
"tags": [],
|
||||||
|
"emojis": [],
|
||||||
|
"card": null,
|
||||||
|
"poll": null,
|
||||||
|
"text": "hello everyone!",
|
||||||
|
"interaction_policy": {
|
||||||
|
"can_favourite": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
},
|
||||||
|
"can_reply": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
},
|
||||||
|
"can_reblog": {
|
||||||
|
"always": [
|
||||||
|
"public",
|
||||||
|
"me"
|
||||||
|
],
|
||||||
|
"with_approval": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`, string(b))
|
||||||
|
}
|
||||||
|
|
||||||
func TestInternalToFrontendTestSuite(t *testing.T) {
|
func TestInternalToFrontendTestSuite(t *testing.T) {
|
||||||
suite.Run(t, new(InternalToFrontendTestSuite))
|
suite.Run(t, new(InternalToFrontendTestSuite))
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,16 @@ func CustomCSS(customCSS string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InstanceCustomCSS(customCSS string) error {
|
||||||
|
|
||||||
|
maximumCustomCSSLength := config.GetAccountsCustomCSSLength()
|
||||||
|
if length := len([]rune(customCSS)); length > maximumCustomCSSLength {
|
||||||
|
return fmt.Errorf("custom_css must be less than %d characters, but submitted custom_css was %d characters", maximumCustomCSSLength, length)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// EmojiShortcode just runs the given shortcode through the regular expression
|
// EmojiShortcode just runs the given shortcode through the regular expression
|
||||||
// for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 2-30 characters,
|
// for emoji shortcodes, to figure out whether it's a valid shortcode, ie., 2-30 characters,
|
||||||
// a-zA-Z, numbers, and underscores.
|
// a-zA-Z, numbers, and underscores.
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (m *Module) aboutGETHandler(c *gin.Context) {
|
||||||
Template: "about.tmpl",
|
Template: "about.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
OGMeta: apiutil.OGBase(instance),
|
OGMeta: apiutil.OGBase(instance),
|
||||||
Stylesheets: []string{cssAbout},
|
Stylesheets: []string{cssAbout, instanceCustomCSSPath},
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
"showStrap": true,
|
"showStrap": true,
|
||||||
"blocklistExposed": config.GetInstanceExposeSuspendedWeb(),
|
"blocklistExposed": config.GetInstanceExposeSuspendedWeb(),
|
||||||
|
|
|
@ -129,6 +129,7 @@ func (m *Module) confirmEmailPOSTHandler(c *gin.Context) {
|
||||||
page := apiutil.WebPage{
|
page := apiutil.WebPage{
|
||||||
Template: "confirmed_email.tmpl",
|
Template: "confirmed_email.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
|
Stylesheets: []string{instanceCustomCSSPath},
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
"email": user.Email,
|
"email": user.Email,
|
||||||
"username": user.Account.Username,
|
"username": user.Account.Username,
|
||||||
|
|
|
@ -55,3 +55,22 @@ func (m *Module) customCSSGETHandler(c *gin.Context) {
|
||||||
c.Header(cacheControlHeader, cacheControlNoCache)
|
c.Header(cacheControlHeader, cacheControlNoCache)
|
||||||
c.Data(http.StatusOK, textCSSUTF8, []byte(customCSS))
|
c.Data(http.StatusOK, textCSSUTF8, []byte(customCSS))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Module) instanceCustomCSSGETHandler(c *gin.Context) {
|
||||||
|
|
||||||
|
if _, err := apiutil.NegotiateAccept(c, apiutil.TextCSS); err != nil {
|
||||||
|
apiutil.WebErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
instanceV1, errWithCode := m.processor.InstanceGetV1(c.Request.Context())
|
||||||
|
if errWithCode != nil {
|
||||||
|
apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
instanceCustomCSS := instanceV1.CustomCSS
|
||||||
|
|
||||||
|
c.Header(cacheControlHeader, cacheControlNoCache)
|
||||||
|
c.Data(http.StatusOK, textCSSUTF8, []byte(instanceCustomCSS))
|
||||||
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ func (m *Module) domainBlockListGETHandler(c *gin.Context) {
|
||||||
Template: "domain-blocklist.tmpl",
|
Template: "domain-blocklist.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
OGMeta: apiutil.OGBase(instance),
|
OGMeta: apiutil.OGBase(instance),
|
||||||
Stylesheets: []string{cssFA},
|
Stylesheets: []string{cssFA, instanceCustomCSSPath},
|
||||||
Javascript: []string{jsFrontend},
|
Javascript: []string{jsFrontend},
|
||||||
Extra: map[string]any{"blocklist": domainBlocks},
|
Extra: map[string]any{"blocklist": domainBlocks},
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (m *Module) indexHandler(c *gin.Context) {
|
||||||
Template: "index.tmpl",
|
Template: "index.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
OGMeta: apiutil.OGBase(instance),
|
OGMeta: apiutil.OGBase(instance),
|
||||||
Stylesheets: []string{cssAbout, cssIndex},
|
Stylesheets: []string{cssAbout, cssIndex, instanceCustomCSSPath},
|
||||||
Extra: map[string]any{"showStrap": true},
|
Extra: map[string]any{"showStrap": true},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ func (m *Module) profileGETHandler(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare stylesheets for profile.
|
// Prepare stylesheets for profile.
|
||||||
stylesheets := make([]string, 0, 6)
|
stylesheets := make([]string, 0, 7)
|
||||||
|
|
||||||
// Basic profile stylesheets.
|
// Basic profile stylesheets.
|
||||||
stylesheets = append(
|
stylesheets = append(
|
||||||
|
@ -142,6 +142,7 @@ func (m *Module) profileGETHandler(c *gin.Context) {
|
||||||
cssStatus,
|
cssStatus,
|
||||||
cssThread,
|
cssThread,
|
||||||
cssProfile,
|
cssProfile,
|
||||||
|
instanceCustomCSSPath,
|
||||||
}...,
|
}...,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) {
|
||||||
cssProfile, // Used for rendering stub/fake profiles.
|
cssProfile, // Used for rendering stub/fake profiles.
|
||||||
cssStatus, // Used for rendering stub/fake statuses.
|
cssStatus, // Used for rendering stub/fake statuses.
|
||||||
cssSettings,
|
cssSettings,
|
||||||
|
instanceCustomCSSPath,
|
||||||
},
|
},
|
||||||
Javascript: []string{jsSettings},
|
Javascript: []string{jsSettings},
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ func (m *Module) signupPOSTHandler(c *gin.Context) {
|
||||||
page := apiutil.WebPage{
|
page := apiutil.WebPage{
|
||||||
Template: "signed-up.tmpl",
|
Template: "signed-up.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
|
Stylesheets: []string{instanceCustomCSSPath},
|
||||||
OGMeta: apiutil.OGBase(instance),
|
OGMeta: apiutil.OGBase(instance),
|
||||||
Extra: map[string]any{
|
Extra: map[string]any{
|
||||||
"email": user.UnconfirmedEmail,
|
"email": user.UnconfirmedEmail,
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (m *Module) tagGETHandler(c *gin.Context) {
|
||||||
Template: "tag.tmpl",
|
Template: "tag.tmpl",
|
||||||
Instance: instance,
|
Instance: instance,
|
||||||
OGMeta: apiutil.OGBase(instance),
|
OGMeta: apiutil.OGBase(instance),
|
||||||
Stylesheets: []string{cssFA, cssThread, cssTag},
|
Stylesheets: []string{cssFA, cssThread, cssTag, instanceCustomCSSPath},
|
||||||
Extra: map[string]any{"tagName": tagName},
|
Extra: map[string]any{"tagName": tagName},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (m *Module) threadGETHandler(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare stylesheets for thread.
|
// Prepare stylesheets for thread.
|
||||||
stylesheets := make([]string, 0, 5)
|
stylesheets := make([]string, 0, 6)
|
||||||
|
|
||||||
// Basic thread stylesheets.
|
// Basic thread stylesheets.
|
||||||
stylesheets = append(
|
stylesheets = append(
|
||||||
|
@ -131,6 +131,7 @@ func (m *Module) threadGETHandler(c *gin.Context) {
|
||||||
if theme := targetAccount.Theme; theme != "" {
|
if theme := targetAccount.Theme; theme != "" {
|
||||||
stylesheets = append(
|
stylesheets = append(
|
||||||
stylesheets,
|
stylesheets,
|
||||||
|
instanceCustomCSSPath,
|
||||||
themesPathPrefix+"/"+theme,
|
themesPathPrefix+"/"+theme,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
statusPath = "/statuses/:" + apiutil.WebStatusIDKey // leave out the '/@:username' prefix as this will be served within the profile group
|
statusPath = "/statuses/:" + apiutil.WebStatusIDKey // leave out the '/@:username' prefix as this will be served within the profile group
|
||||||
tagsPath = "/tags/:" + apiutil.TagNameKey
|
tagsPath = "/tags/:" + apiutil.TagNameKey
|
||||||
customCSSPath = profileGroupPath + "/custom.css"
|
customCSSPath = profileGroupPath + "/custom.css"
|
||||||
|
instanceCustomCSSPath = "/custom.css"
|
||||||
rssFeedPath = profileGroupPath + "/feed.rss"
|
rssFeedPath = profileGroupPath + "/feed.rss"
|
||||||
assetsPathPrefix = "/assets"
|
assetsPathPrefix = "/assets"
|
||||||
distPathPrefix = assetsPathPrefix + "/dist"
|
distPathPrefix = assetsPathPrefix + "/dist"
|
||||||
|
@ -114,6 +115,7 @@ func (m *Module) Route(r *router.Router, mi ...gin.HandlerFunc) {
|
||||||
r.AttachHandler(http.MethodGet, settingsPathPrefix, m.SettingsPanelHandler)
|
r.AttachHandler(http.MethodGet, settingsPathPrefix, m.SettingsPanelHandler)
|
||||||
r.AttachHandler(http.MethodGet, settingsPanelGlob, m.SettingsPanelHandler)
|
r.AttachHandler(http.MethodGet, settingsPanelGlob, m.SettingsPanelHandler)
|
||||||
r.AttachHandler(http.MethodGet, customCSSPath, m.customCSSGETHandler)
|
r.AttachHandler(http.MethodGet, customCSSPath, m.customCSSGETHandler)
|
||||||
|
r.AttachHandler(http.MethodGet, instanceCustomCSSPath, m.instanceCustomCSSGETHandler)
|
||||||
r.AttachHandler(http.MethodGet, rssFeedPath, m.rssFeedGETHandler)
|
r.AttachHandler(http.MethodGet, rssFeedPath, m.rssFeedGETHandler)
|
||||||
r.AttachHandler(http.MethodGet, confirmEmailPath, m.confirmEmailGETHandler)
|
r.AttachHandler(http.MethodGet, confirmEmailPath, m.confirmEmailGETHandler)
|
||||||
r.AttachHandler(http.MethodPost, confirmEmailPath, m.confirmEmailPOSTHandler)
|
r.AttachHandler(http.MethodPost, confirmEmailPath, m.confirmEmailPOSTHandler)
|
||||||
|
|
|
@ -618,7 +618,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff := len(accountsSorted) - len(preserializedKeys); diff > 0 {
|
if diff := len(accountsSorted) - len(preserializedKeys); diff > 0 {
|
||||||
keyStrings := make([]string, diff)
|
keyStrings := make([]string, 0, diff)
|
||||||
for i := 0; i < diff; i++ {
|
for i := 0; i < diff; i++ {
|
||||||
priv, _ := rsa.GenerateKey(rand.Reader, 2048)
|
priv, _ := rsa.GenerateKey(rand.Reader, 2048)
|
||||||
key, _ := x509.MarshalPKCS8PrivateKey(priv)
|
key, _ := x509.MarshalPKCS8PrivateKey(priv)
|
||||||
|
|
166
web/assets/themes/moonlight-hunt.css
Normal file
166
web/assets/themes/moonlight-hunt.css
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
/*
|
||||||
|
theme-title: Moonlight Hunt
|
||||||
|
theme-description: Ominous dark blue / black with a tinge of blood red. You may think it all a mere bad dream.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* Define our palette */
|
||||||
|
--bleached-bone: #f3e3d4;
|
||||||
|
--void-blue: #0e131f;
|
||||||
|
--outer-space: #06080e;
|
||||||
|
--ghastly-blue: #88bebe;
|
||||||
|
--blood-red: #6c1619;
|
||||||
|
--bright-red: #f61a1ae6;
|
||||||
|
--feral-orange: #f78d17;
|
||||||
|
|
||||||
|
/* Restyle basic colors */
|
||||||
|
--white1: var(--void-blue);
|
||||||
|
--white2: var(--void-blue);
|
||||||
|
--orange2: var(--bright-red);
|
||||||
|
--blue1: var(--ghastly-blue);
|
||||||
|
--blue2: var(--ghastly-blue);
|
||||||
|
--blue3: var(--ghastly-blue);
|
||||||
|
|
||||||
|
/* Basic page styling (background + foreground) */
|
||||||
|
--bg: var(--void-blue);
|
||||||
|
--bg-accent: var(--void-blue);
|
||||||
|
--fg: var(--bleached-bone);
|
||||||
|
--fg-reduced: var(--bleached-bone);
|
||||||
|
--profile-bg: var(--void-blue);
|
||||||
|
|
||||||
|
/* Buttons */
|
||||||
|
--bloodshot: linear-gradient(
|
||||||
|
var(--blood-red) 0%,
|
||||||
|
var(--feral-orange) 2%,
|
||||||
|
var(--bright-red) 5%,
|
||||||
|
var(--blood-red) 40%,
|
||||||
|
var(--blood-red) 60%,
|
||||||
|
var(--bright-red) 95%,
|
||||||
|
var(--feral-orange) 98%,
|
||||||
|
var(--blood-red) 100%
|
||||||
|
);
|
||||||
|
--button-bg: var(--bloodshot);
|
||||||
|
--button-fg: var(--bleached-bone);
|
||||||
|
|
||||||
|
/* Statuses */
|
||||||
|
--status-bg: var(--void-blue);
|
||||||
|
--status-focus-bg: var(--void-blue);
|
||||||
|
|
||||||
|
/* Used around statuses + other items */
|
||||||
|
--ghastly-border: 0.1rem solid var(--ghastly-blue);
|
||||||
|
--boxshadow-border: var(--ghastly-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main page background */
|
||||||
|
body {
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
var(--blood-red),
|
||||||
|
black 20%,
|
||||||
|
black 80%,
|
||||||
|
var(--blood-red)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scroll bar */
|
||||||
|
html, body {
|
||||||
|
scrollbar-color: var(--bright-red) var(--outer-space);
|
||||||
|
text-shadow: 1px 1px var(--blood-red);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Instance title color */
|
||||||
|
.page-header a h1 {
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile .profile-header {
|
||||||
|
border: var(--ghastly-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-header {
|
||||||
|
border: var(--ghastly-border);
|
||||||
|
background: var(--outer-space);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile .about-user .col-header {
|
||||||
|
background: var(--void-blue);
|
||||||
|
border-bottom: none;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fiddle around with borders on about sections */
|
||||||
|
.profile .about-user .fields,
|
||||||
|
.profile .about-user .bio,
|
||||||
|
.profile .about-user .accountstats {
|
||||||
|
border-left: var(--ghastly-border);
|
||||||
|
border-right: var(--ghastly-border);
|
||||||
|
}
|
||||||
|
.profile .about-user .accountstats {
|
||||||
|
border-bottom: var(--ghastly-border);
|
||||||
|
background: var(--outer-space);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Role and bot badge backgrounds */
|
||||||
|
.profile .profile-header .basic-info .namerole .role,
|
||||||
|
.profile .profile-header .basic-info .namerole .bot-username-wrapper .bot-legend-wrapper {
|
||||||
|
background: var(--outer-space);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status media */
|
||||||
|
.status .media .media-wrapper {
|
||||||
|
border: var(--ghastly-border);
|
||||||
|
}
|
||||||
|
.status .media .media-wrapper details .unknown-attachment .placeholder {
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
||||||
|
.status .media .media-wrapper details video.plyr-video {
|
||||||
|
background: var(--outer-space);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status polls */
|
||||||
|
.status .text .poll {
|
||||||
|
background-color: var(--outer-space);
|
||||||
|
border: var(--ghastly-border);
|
||||||
|
}
|
||||||
|
.status .text .poll .poll-info {
|
||||||
|
background-color: var(--void-blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Code snippets */
|
||||||
|
pre, pre[class*="language-"],
|
||||||
|
code, code[class*="language-"] {
|
||||||
|
background-color: var(--outer-space);
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Block quotes */
|
||||||
|
blockquote {
|
||||||
|
background-color: var(--outer-space);
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status info bars */
|
||||||
|
.status .status-info,
|
||||||
|
.status.expanded .status-info {
|
||||||
|
color: var(--ghastly-blue);
|
||||||
|
border-top: 0.1rem dotted var(--ghastly-blue);
|
||||||
|
background: var(--outer-space);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make show more/less buttons more legible */
|
||||||
|
.status .button {
|
||||||
|
border: 1px solid var(--feral-orange);
|
||||||
|
}
|
||||||
|
.status .button:hover {
|
||||||
|
border: 1px solid var(--bleached-bone);
|
||||||
|
background: var(--bloodshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Back + next links */
|
||||||
|
.profile .statuses .backnextlinks a {
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-footer nav ul li a {
|
||||||
|
color: var(--bleached-bone);
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ export interface InstanceV1 {
|
||||||
description_text?: string;
|
description_text?: string;
|
||||||
short_description: string;
|
short_description: string;
|
||||||
short_description_text?: string;
|
short_description_text?: string;
|
||||||
|
custom_css: string;
|
||||||
email: string;
|
email: string;
|
||||||
version: string;
|
version: string;
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
|
|
|
@ -66,6 +66,10 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
||||||
valueSelector: (s: InstanceV1) => s.description_text,
|
valueSelector: (s: InstanceV1) => s.description_text,
|
||||||
validator: (val: string) => val.length <= descLimit ? "" : `Instance description is ${val.length} characters; must be ${descLimit} characters or less`
|
validator: (val: string) => val.length <= descLimit ? "" : `Instance description is ${val.length} characters; must be ${descLimit} characters or less`
|
||||||
}),
|
}),
|
||||||
|
customCSS: useTextInput("custom_css", {
|
||||||
|
source: instance,
|
||||||
|
valueSelector: (s: InstanceV1) => s.custom_css
|
||||||
|
}),
|
||||||
terms: useTextInput("terms", {
|
terms: useTextInput("terms", {
|
||||||
source: instance,
|
source: instance,
|
||||||
// Select "raw" text version of parsed field for editing.
|
// Select "raw" text version of parsed field for editing.
|
||||||
|
@ -191,6 +195,15 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
||||||
type="email"
|
type="email"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextArea
|
||||||
|
field={form.customCSS}
|
||||||
|
label={"Custom CSS"}
|
||||||
|
className="monospace"
|
||||||
|
rows={8}
|
||||||
|
autoCapitalize="none"
|
||||||
|
spellCheck="false"
|
||||||
|
/>
|
||||||
|
|
||||||
<MutationButton label="Save" result={result} disabled={false} />
|
<MutationButton label="Save" result={result} disabled={false} />
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue