mirror of
https://git.ptzo.gdn/feditools/relay.git
synced 2024-09-21 11:27:11 +00:00
parent
f463125ff9
commit
b0ac39a01e
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
||||
github.com/allegro/bigcache/v3 v3.0.2
|
||||
github.com/contribsys/faktory v1.6.1
|
||||
github.com/contribsys/faktory_worker_go v1.6.0
|
||||
github.com/feditools/go-lib v0.16.3
|
||||
github.com/feditools/go-lib v0.16.4
|
||||
github.com/go-fed/activity v1.0.0
|
||||
github.com/go-fed/httpsig v1.1.0
|
||||
github.com/go-playground/validator/v10 v10.11.0
|
||||
|
4
go.sum
4
go.sum
@ -105,8 +105,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/feditools/go-lib v0.16.3 h1:mJE90OS0yJe66guUfyUQOemPU5hiYUiJg/fMijsqM+c=
|
||||
github.com/feditools/go-lib v0.16.3/go.mod h1:hCHLZDjPhTQxNkYTv/RXVVgN3NA8n2xGhiJlq4UXfdg=
|
||||
github.com/feditools/go-lib v0.16.4 h1:Vnfdr/kHPyprR/C8PJ4V0aikGq/DeLG5SM9czMtoG0w=
|
||||
github.com/feditools/go-lib v0.16.4/go.mod h1:hCHLZDjPhTQxNkYTv/RXVVgN3NA8n2xGhiJlq4UXfdg=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
||||
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
|
@ -109,10 +109,10 @@ var Defaults = Values{
|
||||
WebappBootstrapJSIntegrity: "sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2",
|
||||
WebappChartJSURI: "https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js",
|
||||
WebappChartJSIntegrity: "sha384-9MhbyIRcBVQiiC7FSd7T38oJNj2Zh+EfxS7/vjhBi4OOT78NlHSnzM31EZRWR1LZ",
|
||||
WebappFontAwesomeCSSURI: "https://cdn.fedi.tools/vendor/fontawesome-free-6.1.1/css/all.min.css",
|
||||
WebappFontAwesomeCSSURI: "https://assets.fedi.tools/vendor/fontawesome-free-6.1.1/css/all.min.css",
|
||||
WebappFontAwesomeCSSIntegrity: "sha384-/frq1SRXYH/bSyou/HUp/hib7RVN1TawQYja658FEOodR/FQBKVqT9Ol+Oz3Olq5",
|
||||
WebappLogoSrcDark: "https://cdn.fedi.tools/img/feditools-logo-dark.svg",
|
||||
WebappLogoSrcLight: "https://cdn.fedi.tools/img/feditools-logo-light.svg",
|
||||
WebappLogoSrcDark: "https://assets.fedi.tools/img/feditools-logo-dark.svg",
|
||||
WebappLogoSrcLight: "https://assets.fedi.tools/img/feditools-logo-light.svg",
|
||||
|
||||
// metrics
|
||||
MetricsStatsDAddress: "localhost:8125",
|
||||
|
@ -27,7 +27,7 @@ func (m *Module) displayAdminAccount(w http.ResponseWriter, r *http.Request, con
|
||||
// Init template variables
|
||||
tmplVars := &template.AdminAccount{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextAccount(2).String(),
|
||||
PageTitle: localizer.TextAccounts().String(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (m *Module) displayAdminBlockList(w http.ResponseWriter, r *http.Request, c
|
||||
// Init template variables
|
||||
tmplVars := &template.AdminBlock{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextBlock(2).String(),
|
||||
PageTitle: localizer.TextBlocks().String(),
|
||||
},
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ func (m *Module) displayAdminBlockList(w http.ResponseWriter, r *http.Request, c
|
||||
Name: FormDomain,
|
||||
Placeholder: "example.com",
|
||||
Label: &libtemplate.FormLabel{
|
||||
Text: localizer.TextDomain(1),
|
||||
Text: localizer.TextDomain(),
|
||||
Class: "form-label",
|
||||
},
|
||||
Value: config.FormAddDomainValue,
|
||||
@ -152,7 +152,7 @@ func (m *Module) displayAdminBlockList(w http.ResponseWriter, r *http.Request, c
|
||||
Name: FormDomain,
|
||||
Placeholder: "example.com",
|
||||
Label: &libtemplate.FormLabel{
|
||||
Text: localizer.TextDomain(2),
|
||||
Text: localizer.TextDomain(),
|
||||
Class: "form-label",
|
||||
},
|
||||
Value: config.FormAddDomainValue,
|
||||
|
@ -27,7 +27,7 @@ func (m *Module) displayAdminInstance(w http.ResponseWriter, r *http.Request, co
|
||||
// Init template variables
|
||||
tmplVars := &template.AdminInstance{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextInstance(2).String(),
|
||||
PageTitle: localizer.TextInstances().String(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -69,12 +69,12 @@ func (m *Module) displayAdminInstanceView(w http.ResponseWriter, r *http.Request
|
||||
// Init template variables
|
||||
tmplVars := &template.AdminInstanceView{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextInstance(1).String() + " " + config.Instance.UnicodeDomain(),
|
||||
PageTitle: localizer.TextInstance().String() + " " + config.Instance.UnicodeDomain(),
|
||||
},
|
||||
|
||||
Breadcrumbs: &[]template.Breadcrumb{
|
||||
{
|
||||
Text: localizer.TextInstance(2).String(),
|
||||
Text: localizer.TextInstances().String(),
|
||||
HRef: path.AppAdminInstance,
|
||||
},
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ func (m *Module) AdminStatisticsGetHandler(w http.ResponseWriter, r *http.Reques
|
||||
// Init template variables
|
||||
tmplVars := &template.AdminStatistics{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextRelay(1).String() + "-" + localizer.TextStatistics().String(),
|
||||
PageTitle: localizer.TextRelay().String() + "-" + localizer.TextStatistics().String(),
|
||||
},
|
||||
|
||||
Nav: makeAdminStatisticsNav(r.Context(), queryScale, queryDays),
|
||||
|
@ -16,7 +16,7 @@ func (m *Module) BlocksGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Init template variables
|
||||
tmplVars := &template.Blocks{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextRelay(1).String() + "-" + localizer.TextBlockedDomains().String(),
|
||||
PageTitle: localizer.TextRelay().String() + "-" + localizer.TextBlockedDomains().String(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ func (m *Module) HomeGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Init template variables
|
||||
tmplVars := &template.Home{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextRelay(1).String(),
|
||||
PageTitle: localizer.TextRelay().String(),
|
||||
},
|
||||
|
||||
HomeBody: defaultHomeBody,
|
||||
|
@ -19,7 +19,7 @@ func (m *Module) LogGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Init template variables
|
||||
tmplVars := &template.Logs{
|
||||
Common: template.Common{
|
||||
PageTitle: localizer.TextRelay(1).String() + "-" + localizer.TextActivityLog().String(),
|
||||
PageTitle: localizer.TextRelay().String() + "-" + localizer.TextActivityLog().String(),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,14 @@ func (m *Module) displaySettingsHome(w http.ResponseWriter, r *http.Request, con
|
||||
tmplVars := &template.Settings{
|
||||
Common: template.Common{
|
||||
Alerts: config.Alerts,
|
||||
PageTitle: localizer.TextRelay(1).String(),
|
||||
PageTitle: localizer.TextRelay().String(),
|
||||
},
|
||||
|
||||
FormGeneralAccount: libtemplate.FormInput{
|
||||
ID: "formGeneralAccount",
|
||||
Type: libtemplate.FormInputTypeText,
|
||||
Label: &libtemplate.FormLabel{
|
||||
Text: localizer.TextAccount(1),
|
||||
Text: localizer.TextAccount(),
|
||||
Class: "form-label",
|
||||
},
|
||||
Disabled: true,
|
||||
@ -173,7 +173,7 @@ func (m *Module) displaySettingsHome(w http.ResponseWriter, r *http.Request, con
|
||||
ID: "formGeneralIsMod",
|
||||
Type: libtemplate.FormInputTypeCheckbox,
|
||||
Label: &libtemplate.FormLabel{
|
||||
Text: localizer.TextModerator(1),
|
||||
Text: localizer.TextModerator(),
|
||||
Class: "form-check-label",
|
||||
},
|
||||
Disabled: true,
|
||||
|
@ -117,7 +117,7 @@ func (m *Module) makeNavbar(r *http.Request) (template.Navbar, error) {
|
||||
}
|
||||
if blockCount > 0 {
|
||||
newNode := template.NavbarNode{
|
||||
Text: l.TextBlock(2).String(),
|
||||
Text: l.TextBlocks().String(),
|
||||
MatchStr: path.ReAppBlocks,
|
||||
FAIcon: "user-slash",
|
||||
URL: path.AppBlocks,
|
||||
@ -155,19 +155,19 @@ func (m *Module) makeNavbar(r *http.Request) (template.Navbar, error) {
|
||||
Divider: true,
|
||||
},
|
||||
{
|
||||
Text: l.TextAccount(2).String(),
|
||||
Text: l.TextAccounts().String(),
|
||||
MatchStr: path.ReAppAdminAccountPre,
|
||||
FAIcon: "user",
|
||||
URL: path.AppAdminAccount,
|
||||
},
|
||||
{
|
||||
Text: l.TextBlock(2).String(),
|
||||
Text: l.TextBlocks().String(),
|
||||
MatchStr: path.ReAppAdminBlockPre,
|
||||
FAIcon: "user-slash",
|
||||
URL: path.AppAdminBlock,
|
||||
},
|
||||
{
|
||||
Text: l.TextInstance(2).String(),
|
||||
Text: l.TextInstances().String(),
|
||||
MatchStr: path.ReAppAdminInstancesPre,
|
||||
FAIcon: "server",
|
||||
URL: path.AppAdminInstance,
|
||||
|
@ -3,14 +3,12 @@ package language
|
||||
import "github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
|
||||
// TextAccount returns a translated phrase.
|
||||
func (l *Localizer) TextAccount(count int) *LocalizedString {
|
||||
func (l *Localizer) TextAccount() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Account",
|
||||
One: "Account",
|
||||
Other: "Accounts",
|
||||
Other: "Account",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextAccount").Warningf(missingTranslationWarning, err.Error())
|
||||
@ -22,6 +20,24 @@ func (l *Localizer) TextAccount(count int) *LocalizedString {
|
||||
}
|
||||
}
|
||||
|
||||
// TextAccounts returns a translated phrase.
|
||||
func (l *Localizer) TextAccounts() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Accounts",
|
||||
Other: "Accounts",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextAccounts").Warningf(missingTranslationWarning, err.Error())
|
||||
}
|
||||
|
||||
return &LocalizedString{
|
||||
language: tag,
|
||||
string: text,
|
||||
}
|
||||
}
|
||||
|
||||
// TextActivityLog returns a translated phrase.
|
||||
func (l *Localizer) TextActivityLog() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
|
@ -13,13 +13,38 @@ func TestLocalizer_TextAccount(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Account",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
for i, table := range tables {
|
||||
i := i
|
||||
table := table
|
||||
|
||||
name := fmt.Sprintf(testTranslatedTo, i, table.inputLang)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
localizer, err := langMod.NewLocalizer(table.inputLang.String())
|
||||
if err != nil {
|
||||
t.Errorf(testCantGetLocalizer, i, table.inputLang, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
testText(t, i, localizer.TextAccount, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizer_TextAccounts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Accounts",
|
||||
outputLang: language.English,
|
||||
},
|
||||
@ -41,7 +66,7 @@ func TestLocalizer_TextAccount(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextAccount, table)
|
||||
testText(t, i, localizer.TextAccounts, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,12 @@ package language
|
||||
import "github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
|
||||
// TextBlock returns a translated phrase.
|
||||
func (l *Localizer) TextBlock(count int) *LocalizedString {
|
||||
func (l *Localizer) TextBlock() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Block",
|
||||
One: "Block",
|
||||
Other: "Blocks",
|
||||
Other: "Block",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextBlock").Warningf(missingTranslationWarning, err.Error())
|
||||
@ -22,6 +20,24 @@ func (l *Localizer) TextBlock(count int) *LocalizedString {
|
||||
}
|
||||
}
|
||||
|
||||
// TextBlocks returns a translated phrase.
|
||||
func (l *Localizer) TextBlocks() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Blocks",
|
||||
Other: "Blocks",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextBlocks").Warningf(missingTranslationWarning, err.Error())
|
||||
}
|
||||
|
||||
return &LocalizedString{
|
||||
language: tag,
|
||||
string: text,
|
||||
}
|
||||
}
|
||||
|
||||
// TextBlockExistsDomain returns a translated phrase.
|
||||
func (l *Localizer) TextBlockExistsDomain(domain string) *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
|
@ -12,13 +12,38 @@ func TestLocalizer_TextBlock(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Block",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
for i, table := range tables {
|
||||
i := i
|
||||
table := table
|
||||
|
||||
name := fmt.Sprintf(testTranslatedTo, i, table.inputLang)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
localizer, err := langMod.NewLocalizer(table.inputLang.String())
|
||||
if err != nil {
|
||||
t.Errorf(testCantGetLocalizer, i, table.inputLang, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
testText(t, i, localizer.TextBlock, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizer_TextBlocks(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Blocks",
|
||||
outputLang: language.English,
|
||||
},
|
||||
@ -40,7 +65,7 @@ func TestLocalizer_TextBlock(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextBlock, table)
|
||||
testText(t, i, localizer.TextBlocks, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -122,14 +122,12 @@ func (l *Localizer) TextDescription() *LocalizedString {
|
||||
}
|
||||
|
||||
// TextDomain returns a translated phrase.
|
||||
func (l *Localizer) TextDomain(count int) *LocalizedString {
|
||||
func (l *Localizer) TextDomain() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Domain",
|
||||
One: "Domain",
|
||||
Other: "Domains",
|
||||
Other: "Domain",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextDomain").Warningf(missingTranslationWarning, err.Error())
|
||||
|
@ -232,16 +232,9 @@ func TestLocalizer_TextDomain(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Domain",
|
||||
outputLang: language.English,
|
||||
},
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Domains",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
@ -260,7 +253,7 @@ func TestLocalizer_TextDomain(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextDomain, table)
|
||||
testText(t, i, localizer.TextDomain, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -57,14 +57,12 @@ func (l *Localizer) TextInboxURI() *LocalizedString {
|
||||
}
|
||||
|
||||
// TextInstance returns a translated phrase.
|
||||
func (l *Localizer) TextInstance(count int) *LocalizedString {
|
||||
func (l *Localizer) TextInstance() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Instance",
|
||||
One: "Instance",
|
||||
Other: "Instances",
|
||||
Other: "Instance",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextInstance").Warningf(missingTranslationWarning, err.Error())
|
||||
@ -75,3 +73,21 @@ func (l *Localizer) TextInstance(count int) *LocalizedString {
|
||||
string: text,
|
||||
}
|
||||
}
|
||||
|
||||
// TextInstances returns a translated phrase.
|
||||
func (l *Localizer) TextInstances() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Instances",
|
||||
Other: "Instances",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextInstances").Warningf(missingTranslationWarning, err.Error())
|
||||
}
|
||||
|
||||
return &LocalizedString{
|
||||
language: tag,
|
||||
string: text,
|
||||
}
|
||||
}
|
||||
|
@ -109,13 +109,38 @@ func TestLocalizer_TextInstance(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Instance",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
for i, table := range tables {
|
||||
i := i
|
||||
table := table
|
||||
|
||||
name := fmt.Sprintf(testTranslatedTo, i, table.inputLang)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
localizer, err := langMod.NewLocalizer(table.inputLang.String())
|
||||
if err != nil {
|
||||
t.Errorf(testCantGetLocalizer, i, table.inputLang, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
testText(t, i, localizer.TextInstance, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizer_TextInstances(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Instances",
|
||||
outputLang: language.English,
|
||||
},
|
||||
@ -137,7 +162,7 @@ func TestLocalizer_TextInstance(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextInstance, table)
|
||||
testText(t, i, localizer.TextInstances, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,12 @@ func (l *Localizer) TextMetrics() *LocalizedString {
|
||||
}
|
||||
|
||||
// TextModerator returns a translated phrase.
|
||||
func (l *Localizer) TextModerator(count int) *LocalizedString {
|
||||
func (l *Localizer) TextModerator() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Moderator",
|
||||
One: "Moderator",
|
||||
Other: "Moderators",
|
||||
Other: "Moderator",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextModerator").Warningf(missingTranslationWarning, err.Error())
|
||||
|
@ -44,16 +44,9 @@ func TestLocalizer_TextModerator(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Moderator",
|
||||
outputLang: language.English,
|
||||
},
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Moderators",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
@ -72,7 +65,7 @@ func TestLocalizer_TextModerator(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextModerator, table)
|
||||
testText(t, i, localizer.TextModerator, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,16 @@ package language
|
||||
|
||||
import "github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
|
||||
// TextNotification returns a translated phrase.
|
||||
func (l *Localizer) TextNotification(count int) *LocalizedString {
|
||||
// TextNotifications returns a translated phrase.
|
||||
func (l *Localizer) TextNotifications() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Notification",
|
||||
One: "Notification",
|
||||
ID: "Notifications",
|
||||
Other: "Notifications",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextNotification").Warningf(missingTranslationWarning, err.Error())
|
||||
logger.WithField("func", "TextNotifications").Warningf(missingTranslationWarning, err.Error())
|
||||
}
|
||||
|
||||
return &LocalizedString{
|
||||
|
@ -6,19 +6,12 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLocalizer_TextNotification(t *testing.T) {
|
||||
func TestLocalizer_TextNotifications(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Notification",
|
||||
outputLang: language.English,
|
||||
},
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Notifications",
|
||||
outputLang: language.English,
|
||||
},
|
||||
@ -40,7 +33,7 @@ func TestLocalizer_TextNotification(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextNotification, table)
|
||||
testText(t, i, localizer.TextNotifications, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,12 @@ func (l *Localizer) TextReceivedActivities() *LocalizedString {
|
||||
}
|
||||
|
||||
// TextRelay returns a translated phrase.
|
||||
func (l *Localizer) TextRelay(count int) *LocalizedString {
|
||||
func (l *Localizer) TextRelay() *LocalizedString {
|
||||
text, tag, err := l.localizer.LocalizeWithTag(&i18n.LocalizeConfig{
|
||||
DefaultMessage: &i18n.Message{
|
||||
ID: "Relay",
|
||||
One: "Relay",
|
||||
Other: "Relays",
|
||||
Other: "Relay",
|
||||
},
|
||||
PluralCount: count,
|
||||
})
|
||||
if err != nil {
|
||||
logger.WithField("func", "TextRelay").Warningf(missingTranslationWarning, err.Error())
|
||||
|
@ -45,16 +45,9 @@ func TestLocalizer_TextRelay(t *testing.T) {
|
||||
tables := []testTextTable{
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 1,
|
||||
outputString: "Relay",
|
||||
outputLang: language.English,
|
||||
},
|
||||
{
|
||||
inputLang: language.English,
|
||||
inputCount: 2,
|
||||
outputString: "Relays",
|
||||
outputLang: language.English,
|
||||
},
|
||||
}
|
||||
|
||||
langMod, _ := New()
|
||||
@ -73,7 +66,7 @@ func TestLocalizer_TextRelay(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
testTextWithCount(t, i, localizer.TextRelay, table)
|
||||
testText(t, i, localizer.TextRelay, table)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
33
vendor/github.com/feditools/go-lib/fedihelper/login.go
generated
vendored
33
vendor/github.com/feditools/go-lib/fedihelper/login.go
generated
vendored
@ -12,11 +12,42 @@ func (f *FediHelper) GetLoginURL(ctx context.Context, redirectURI *url.URL, inst
|
||||
|
||||
l := logger.WithField("func", "loginURLForInstance")
|
||||
|
||||
instanceUpdated := false
|
||||
if instance.GetSoftware() == "" {
|
||||
// get nodeinfo endpoints from well-known location
|
||||
wkni, err := f.GetWellknownNodeInfo(tctx, instance.GetServerHostname())
|
||||
if err != nil {
|
||||
l.Errorf("get nodeinfo: %s", err.Error())
|
||||
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// check for nodeinfo 2.0 schema
|
||||
nodeinfoURI, err := findNodeInfo20URI(wkni)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if nodeinfoURI == nil {
|
||||
return nil, false, NewError("missing nodeinfo 2.0 uri")
|
||||
}
|
||||
|
||||
// get nodeinfo from
|
||||
nodeinfo, err := f.GetNodeInfo20(tctx, instance.GetServerHostname(), nodeinfoURI)
|
||||
if err != nil {
|
||||
fhErr := NewErrorf("get nodeinfo 2.0: %s", err.Error())
|
||||
l.Error(fhErr.Error())
|
||||
|
||||
return nil, false, fhErr
|
||||
}
|
||||
|
||||
instance.SetSoftware(nodeinfo.Software.Name)
|
||||
instanceUpdated = true
|
||||
}
|
||||
|
||||
if _, ok := f.helpers[SoftwareName(instance.GetSoftware())]; !ok {
|
||||
return nil, false, NewErrorf("no helper for '%s'", instance.GetSoftware())
|
||||
}
|
||||
|
||||
instanceUpdated := false
|
||||
if instance.GetOAuthClientID() == "" {
|
||||
newClientID, newClientSecret, err := f.helpers[SoftwareMastodon].RegisterApp(tctx, redirectURI, instance)
|
||||
if err != nil {
|
||||
|
16
vendor/github.com/feditools/go-lib/fedihelper/transport.go
generated
vendored
16
vendor/github.com/feditools/go-lib/fedihelper/transport.go
generated
vendored
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto"
|
||||
"fmt"
|
||||
libhttp "github.com/feditools/go-lib/http"
|
||||
"github.com/go-fed/activity/pub"
|
||||
"github.com/go-fed/httpsig"
|
||||
@ -94,10 +93,17 @@ func (t *Transport) InstanceGet(ctx context.Context, uri *url.URL, accepts ...li
|
||||
}
|
||||
span.SetAttributes(semconv.HTTPAttributesFromHTTPStatusCode(resp.StatusCode)...)
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("http get %s: %d", uri.String(), resp.StatusCode)
|
||||
respBody, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
|
||||
return nil, NewErrorf("can't read body: %s", err.Error())
|
||||
}
|
||||
return ioutil.ReadAll(resp.Body)
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return respBody, NewErrorf("get %s: %d", uri.String(), resp.StatusCode)
|
||||
}
|
||||
return respBody, nil
|
||||
}
|
||||
|
||||
func (t *Transport) InstancePost(ctx context.Context, uri *url.URL, body []byte, contentType libhttp.Mime, accepts ...libhttp.Mime) ([]byte, error) {
|
||||
@ -138,7 +144,7 @@ func (t *Transport) InstancePost(ctx context.Context, uri *url.URL, body []byte,
|
||||
}
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return nil, NewErrorf("http post %s: %s", uri.String(), resp.Status)
|
||||
return respBody, NewErrorf("post %s: %s", uri.String(), resp.Status)
|
||||
}
|
||||
return respBody, nil
|
||||
}
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -25,7 +25,7 @@ github.com/dgryski/go-rendezvous
|
||||
# github.com/fatih/color v1.13.0
|
||||
## explicit; go 1.13
|
||||
github.com/fatih/color
|
||||
# github.com/feditools/go-lib v0.16.3
|
||||
# github.com/feditools/go-lib v0.16.4
|
||||
## explicit; go 1.17
|
||||
github.com/feditools/go-lib
|
||||
github.com/feditools/go-lib/database
|
||||
|
@ -1,19 +1,17 @@
|
||||
en:
|
||||
Account:
|
||||
one: Account
|
||||
other: Accounts
|
||||
Account: Account
|
||||
Accounts: Accounts
|
||||
ActivityLog: Activity Log
|
||||
ActorURI: Actor URI
|
||||
AddBlock: Add Block
|
||||
Admin: Admin
|
||||
AllowSearchEngineIndexing: Allow Search Engine Indexing
|
||||
Block:
|
||||
one: Block
|
||||
other: Blocks
|
||||
Block: Block
|
||||
BlockExistsDomain: Block for domain {{.Domain}} already exists.
|
||||
BlockSubdomains: Block Subdomains
|
||||
Blocked: Blocked
|
||||
BlockedDomains: Blocked Domains
|
||||
Blocks: Blocks
|
||||
ChatID: Chat ID
|
||||
Close: Close
|
||||
Configuration: Configuration
|
||||
@ -26,9 +24,7 @@ en:
|
||||
DeleteBlockDomain: Delete Block {{.Domain}}
|
||||
DeliveredActivities: Delivered Activities
|
||||
Description: Description
|
||||
Domain:
|
||||
one: Domain
|
||||
other: Domains
|
||||
Domain: Domain
|
||||
EditBlockDomain: Edit Block {{.Domain}}
|
||||
Enabled: Enabled
|
||||
ErrorDatabase: database error
|
||||
@ -43,27 +39,20 @@ en:
|
||||
Import: Import
|
||||
ImportBlockList: Import Block List
|
||||
InboxURI: Inbox URI
|
||||
Instance:
|
||||
one: Instance
|
||||
other: Instances
|
||||
Instance: Instance
|
||||
Instances: Instances
|
||||
Linear: Linear
|
||||
Logarithmic: Logarithmic
|
||||
Login: Login
|
||||
Logout: Logout
|
||||
LooksGood: Looks Good!
|
||||
Metrics: Metrics
|
||||
Moderator:
|
||||
one: Moderator
|
||||
other: Moderators
|
||||
Notification:
|
||||
one: Notification
|
||||
other: Notifications
|
||||
Moderator: Moderator
|
||||
Notifications: Notifications
|
||||
OAuthConfigured: OAuth Configured
|
||||
ObfuscatedDomain: Obfuscated Domain
|
||||
ReceivedActivities: Received Activities
|
||||
Relay:
|
||||
one: Relay
|
||||
other: Relays
|
||||
Relay: Relay
|
||||
Repo: Repo
|
||||
Save: Save
|
||||
ServerHostname: Server Hostname
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{ define "admin_account" -}}
|
||||
{{- $textAdmin := .Localizer.TextAdmin -}}
|
||||
{{- $textAccounts := .Localizer.TextAccount 2 -}}
|
||||
{{- $textModerator := .Localizer.TextModerator 1 -}}
|
||||
{{- $textAccounts := .Localizer.TextAccounts -}}
|
||||
{{- $textModerator := .Localizer.TextModerator -}}
|
||||
{{- template "header" . }}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
@ -1,10 +1,10 @@
|
||||
{{ define "admin_block" -}}
|
||||
{{- $textAddBlock := .Localizer.TextAddBlock -}}
|
||||
{{- $textBlock := .Localizer.TextBlock 2 -}}
|
||||
{{- $textBlocks := .Localizer.TextBlocks -}}
|
||||
{{- $textBlockSubdomains := .Localizer.TextBlockSubdomains -}}
|
||||
{{- $textClose := .Localizer.TextClose -}}
|
||||
{{- $textCreate := .Localizer.TextCreate -}}
|
||||
{{- $textDomain := .Localizer.TextDomain 1 -}}
|
||||
{{- $textDomain := .Localizer.TextDomain -}}
|
||||
{{- $textDelete := .Localizer.TextDelete -}}
|
||||
{{- $textImport := .Localizer.TextImport -}}
|
||||
{{- $textImportBlockList := .Localizer.TextImportBlockList -}}
|
||||
@ -14,7 +14,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 lang="{{ $textBlock.Language }}"><i class="fa-solid fa-arrows-turn-to-dots"></i> {{ $textBlock }}</h1>
|
||||
<h1 lang="{{ $textBlocks.Language }}"><i class="fa-solid fa-arrows-turn-to-dots"></i> {{ $textBlocks }}</h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#addModal">
|
||||
|
@ -2,7 +2,7 @@
|
||||
{{- $textClose := .Localizer.TextClose -}}
|
||||
{{- $textConfiguration := .Localizer.TextConfiguration -}}
|
||||
{{- $textGeneral := .Localizer.TextGeneral -}}
|
||||
{{- $textNotifications := .Localizer.TextNotification 2 -}}
|
||||
{{- $textNotifications := .Localizer.TextNotifications -}}
|
||||
{{- $textSave := .Localizer.TextSave -}}
|
||||
{{- template "header" . }}
|
||||
<div class="container">
|
||||
|
@ -1,15 +1,15 @@
|
||||
{{ define "admin_instance" -}}
|
||||
{{- $textBlocked := .Localizer.TextBlocked -}}
|
||||
{{- $textClose := .Localizer.TextClose -}}
|
||||
{{- $textDomain := .Localizer.TextDomain 1 -}}
|
||||
{{- $textDomain := .Localizer.TextDomain -}}
|
||||
{{- $textImport := .Localizer.TextImport -}}
|
||||
{{- $textFollowing := .Localizer.TextFollowing -}}
|
||||
{{- $textInstance := .Localizer.TextInstance 2 -}}
|
||||
{{- $textInstances := .Localizer.TextInstances -}}
|
||||
{{- template "header" . }}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 lang="{{ $textInstance.Language }}"><i class="fa-solid fa-arrows-turn-to-dots"></i> {{ $textInstance }}</h1>
|
||||
<h1 lang="{{ $textInstances.Language }}"><i class="fa-solid fa-arrows-turn-to-dots"></i> {{ $textInstances }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
{{- if .Instances }}
|
||||
|
@ -1,13 +1,13 @@
|
||||
{{ define "admin_instance_view" -}}
|
||||
{{- $textActorURI := .Localizer.TextActorURI -}}
|
||||
{{- $textBlock := .Localizer.TextBlock 1 -}}
|
||||
{{- $textBlock := .Localizer.TextBlock -}}
|
||||
{{- $textDeliveredActivities := .Localizer.TextDeliveredActivities -}}
|
||||
{{- $textDomain := .Localizer.TextDomain 1 -}}
|
||||
{{- $textDomain := .Localizer.TextDomain -}}
|
||||
{{- $textFederation := .Localizer.TextFederation -}}
|
||||
{{- $textFollowing := .Localizer.TextFollowing -}}
|
||||
{{- $textGeneral := .Localizer.TextGeneral -}}
|
||||
{{- $textInboxURI := .Localizer.TextInboxURI -}}
|
||||
{{- $textInstance := .Localizer.TextInstance 1 -}}
|
||||
{{- $textInstance := .Localizer.TextInstance -}}
|
||||
{{- $textMetrics := .Localizer.TextMetrics -}}
|
||||
{{- $textOAuthConfigured := .Localizer.TextOAuthConfigured -}}
|
||||
{{- $textReceivedActivities := .Localizer.TextReceivedActivities -}}
|
||||
|
@ -2,9 +2,9 @@
|
||||
{{- $textHowToJoin := .Localizer.TextHowToJoin -}}
|
||||
{{- $textHowToJoinActor := .Localizer.TextHowToJoinActor -}}
|
||||
{{- $textHowToJoinInbox := .Localizer.TextHowToJoinInbox -}}
|
||||
{{- $textInstances := .Localizer.TextInstance 2 -}}
|
||||
{{- $textInstances := .Localizer.TextInstances -}}
|
||||
{{- $extReceivedActivities := .Localizer.TextReceivedActivities -}}
|
||||
{{- $textRelay := .Localizer.TextRelay 1 -}}
|
||||
{{- $textRelay := .Localizer.TextRelay -}}
|
||||
{{- template "header" . }}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
@ -21,7 +21,7 @@
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{{- end }}
|
||||
<input class="form-control" type="text" name="account" {{if .FormAccount}}value="{{.FormAccount}}" {{end}}placeholder="{{ .Localizer.TextAccount 1 }}" aria-label="account">
|
||||
<input class="form-control" type="text" name="account" {{if .FormAccount}}value="{{.FormAccount}}" {{end}}placeholder="{{ .Localizer.TextAccount }}" aria-label="account">
|
||||
<button type="submit" class="btn btn-lg btn-primary btn-block">{{ .Localizer.TextLogin }}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{ define "navbar" }}
|
||||
{{- $textAdmin := .Localizer.TextAdmin }}
|
||||
{{- $textRelay := .Localizer.TextRelay 1 }}
|
||||
{{- $textRelay := .Localizer.TextRelay }}
|
||||
{{- $textLogin := .Localizer.TextLogin }}
|
||||
{{- $textLogout := .Localizer.TextLogout }}
|
||||
<nav class="navbar navbar-expand-lg {{ if .NavBarDark }}navbar-dark bg-primary{{ else }}bg-light{{ end }}">
|
||||
|
@ -1,7 +1,7 @@
|
||||
{{ define "settings" -}}
|
||||
{{- $textClose := .Localizer.TextClose -}}
|
||||
{{- $textGeneral := .Localizer.TextGeneral -}}
|
||||
{{- $textNotifications := .Localizer.TextNotification 2 -}}
|
||||
{{- $textNotifications := .Localizer.TextNotifications -}}
|
||||
{{- $textSave := .Localizer.TextSave -}}
|
||||
{{- $textSettings := .Localizer.TextSettings -}}
|
||||
{{- template "header" . }}
|
||||
|
Loading…
Reference in New Issue
Block a user