Skip to content

Commit

Permalink
Update shared
Browse files Browse the repository at this point in the history
  • Loading branch information
thequailman committed Apr 1, 2024
1 parent 24c5ea2 commit 9d05e8f
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 28 deletions.
2 changes: 1 addition & 1 deletion go/controllers/auth_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ func TestAuthAccountsRead(t *testing.T) {
method: "GET",
responseType: &a,
session: tc.session,
uri: fmt.Sprintf("/auth/accounts?filter=%s", tc.filter),
uri: "/auth/accounts?filter=" + tc.filter,
}.do()

noError(t, msg)
Expand Down
2 changes: 1 addition & 1 deletion go/controllers/auth_household_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func TestAuthHouseholdsRead(t *testing.T) {
method: "GET",
responseType: &a,
session: tc.session,
uri: fmt.Sprintf("/auth/households?%s", tc.query),
uri: "/auth/households?" + tc.query,
}

res := r.do()
Expand Down
1 change: 1 addition & 0 deletions go/controllers/cloud_household_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestCloudHouseholdCreate(t *testing.T) {

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
logger.UseTestLogger(t)

ctx := chi.NewRouteContext()
ctx.URLParams.Add("self_hosted_id", id.String())
r = r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, ctx))
Expand Down
2 changes: 1 addition & 1 deletion go/controllers/controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (t request) do() *Response {
logger.Info(ctx, fmt.Sprintf(`"%s" method="%s" data="%s"`, t.uri, t.method, j))

client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
}
Expand Down
2 changes: 1 addition & 1 deletion go/controllers/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestImportCookRecipe(t *testing.T) {
logger.UseTestLogger(t)

h.Router.Get("/recipe", func(w http.ResponseWriter, r *http.Request) {
h.Router.Get("/recipe", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Add("Content-Type", "text/html")
//nolint:forbidigo
fmt.Fprint(w, `
Expand Down
5 changes: 5 additions & 0 deletions go/controllers/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (h *Handler) CheckSession(next http.Handler) http.Handler { //nolint:gocogn
ctx := r.Context()

var s models.AuthSession

var selfHostedID uuid.UUID

// Get session
Expand Down Expand Up @@ -316,6 +317,7 @@ func (*Handler) GetOffset(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := logger.Trace(r.Context())
offset := r.URL.Query().Get("offset")

o, err := strconv.Atoi(offset)
if offset != "" && err != nil {
WriteResponse(ctx, w, nil, nil, 0, "", logger.Error(ctx, errs.ErrSenderBadRequest))
Expand Down Expand Up @@ -386,6 +388,7 @@ func (h *Handler) SetCacheControl(next http.Handler) http.Handler {
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("CDN-Cache-Control", "no-store")
}

ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
next.ServeHTTP(ww, r)

Expand All @@ -400,13 +403,15 @@ func (h *Handler) SetCacheControl(next http.Handler) http.Handler {
func (*Handler) SetCORS(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")

if r.Method == http.MethodOptions {
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Allow-Headers", "content-type, x-homechart-debug, x-homechart-hash, x-homechart-id, x-homechart-key, x-homechart-updated, x-homechart-version")
w.Header().Set("Access-Control-Allow-Methods", "*")

return
}

next.ServeHTTP(w, r)
})
}
Expand Down
2 changes: 1 addition & 1 deletion go/controllers/payments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestPaymentsDelete(t *testing.T) {
ah.SubscriptionProcessor = models.AuthHouseholdSubscriptionProcessorPaddleMonthly
ah.UpdateSubscription(ctx)

h.Config.Paddle.Mock = func(ctx context.Context, dest any, method, path string, values url.Values) errs.Err {
h.Config.Paddle.Mock = func(_ context.Context, _ any, _, _ string, values url.Values) errs.Err {
assert.Equal(t, values.Get("subscription_id"), ah.SubscriptionID)

return nil
Expand Down
2 changes: 1 addition & 1 deletion go/controllers/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (h *Handler) Routes(ctx context.Context) {
r.Use(h.SetTracingContext)
r.Use(h.SessionMetrics)
r.Get("/", h.SystemInfoRead)
r.Get("/docs", func(w http.ResponseWriter, r *http.Request) {
r.Get("/docs", func(w http.ResponseWriter, _ *http.Request) {
//nolint:forbidigo
fmt.Fprint(w, `
<!DOCTYPE html>
Expand Down
1 change: 1 addition & 0 deletions go/controllers/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestTelemetryErrorCreate(t *testing.T) {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
logger.SetStd()

r := request{
data: telemetryError{
Error: want,
Expand Down
4 changes: 2 additions & 2 deletions go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func main() {
"generate-cloud": {
Run: generateCloud,
},
"generate-keys": {
Run: cryptolib.GenerateKeys[*config.Config]().Run,
"gen-keys": {
Run: cryptolib.GenKeys[*config.Config]().Run,
},
"generate-vapid": {
Run: generateVAPID,
Expand Down
2 changes: 1 addition & 1 deletion go/models/auth_household.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func (a *AuthHousehold) ReadJWT(ctx context.Context, force bool) errs.Err {
if t, _, err := jwt.Parse(string(b), cryptolib.Keys[cryptolib.KeyProviderPublic]{
c.App.CloudPublicKey,
}); err == nil {
if _, err := t.ParsePayload(&s, "", "", ""); err == nil {
if _, err := t.ParsePayload(&s, "", "", ""); err == nil { //nolint:revive
a.CloudJWT = string(b)
ah = s
}
Expand Down
2 changes: 2 additions & 0 deletions go/models/auth_household_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ func TestAuthHouseholdCreateReadJWT(t *testing.T) {

jwt, err := a.CreateJWT(ctx)
cloud = false

if err == nil {
w.Write([]byte(jwt))
} else {
Expand Down Expand Up @@ -559,6 +560,7 @@ func TestAuthHouseholdCreateReadJWT(t *testing.T) {
} else {
err = ah.Read(ctx)
}

assert.Equal(t, err, tc.err)
assert.Equal(t, usedJWT, tc.wantJWT)

Expand Down
4 changes: 1 addition & 3 deletions go/models/budget_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func BudgetTransactionsReadAccount(ctx context.Context, budgetAccountID uuid.UUI
limit = 50
}

//nolint:goconst
err := db.Query(ctx, true, &b, fmt.Sprintf(`
WITH account_filtered AS (
SELECT
Expand Down Expand Up @@ -635,7 +634,6 @@ func (b *BudgetTransaction) create(ctx context.Context, _ CreateOpts) errs.Err {
id := GenerateUUID()
b.ID = &id

//nolint:goconst
err := db.Query(ctx, false, b, budgetTransactionInsert+`
RETURNING *
`, b)
Expand Down Expand Up @@ -790,7 +788,7 @@ func (b BudgetTransaction) Validate() errs.Err {
return ErrBudgetTransactionBalanceAccounts
} else if !matchCategory {
return ErrBudgetTransactionBalanceAccountAmount
} else if categoryAmount != b.Amount {
} else if categoryAmount != b.Amount { //nolint:revive
return ErrBudgetTransactionBalanceCategoryAmount
}
}
Expand Down
6 changes: 3 additions & 3 deletions go/models/calendar_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (c *CalendarEvent) getStartTime(includeLeaveTime bool) string {
var startTime string

if c.Duration%24 != 0 || !includeLeaveTime {
startTime = fmt.Sprintf(" at %s", types.CivilTimeOf(start).String12())
startTime = " at " + types.CivilTimeOf(start).String12()
}

now := time.Now().In(tz)
Expand Down Expand Up @@ -229,7 +229,7 @@ func (c *CalendarEvent) ToICalendarEvents() types.ICalendarEvents {
n := b
n.Duration = c.Duration
n.ID = types.StringLimit(c.ID.String())
n.Name = types.StringLimit("Event: " + string(c.Name)) //nolint:goconst
n.Name = types.StringLimit("Event: " + string(c.Name))
n.TimestampStart = &c.TimestampStart

if end != nil {
Expand Down Expand Up @@ -474,7 +474,7 @@ RETURNING
ns[j].Actions.Types = []notify.WebPushActionType{
NotificationActionsTypesSnooze,
}
ns[j].BodyWebPush = body.String() + fmt.Sprintf("\n\n%s", yaml8n.PushEventReminderBody.Translate(ns[j].ISO639Code))
ns[j].BodyWebPush = body.String() + "\n\n" + yaml8n.PushEventReminderBody.Translate(ns[j].ISO639Code)
ns[j].BodySMTP = body.String() + fmt.Sprintf("\n\n[%s](%s%s)", yaml8n.EmailEventReminderBody.Translate(ns[j].ISO639Code), c.App.BaseURL, url)
ns[j].SubjectWebPush = yaml8n.EmailPushEventReminderSubject.Translate(ns[j].ISO639Code)
ns[j].SubjectSMTP = templates.EmailEventReminderSubject(ns[j].ISO639Code, string(e[i].Name))
Expand Down
2 changes: 1 addition & 1 deletion go/models/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (d *Data) Send(ctx context.Context, authHouseholdID uuid.UUID, backupEncryp
client := &http.Client{}

res, errr := client.Do(r)
if err != nil {
if errr != nil {
return logger.Error(ctx, errs.ErrReceiver.Wrap(errr))
}

Expand Down
1 change: 1 addition & 0 deletions go/models/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func TestDataSend(t *testing.T) {
output, _ := io.ReadAll(r.Body)
data, _ := DataFromByte(ctx, output, "secret")
got = data.ShopItems

w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}))
Expand Down
4 changes: 2 additions & 2 deletions go/models/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestMain(m *testing.M) {
func TestModel(t *testing.T) {
logger.UseTestLogger(t)

f := func(m Model) {}
f := func(_ Model) {}

f(&Bookmark{})
f(&BudgetAccount{})
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestModel(t *testing.T) {
func TestModels(t *testing.T) {
logger.UseTestLogger(t)

f := func(m Models) {}
f := func(_ Models) {}

f(&Bookmarks{})
f(&BudgetAccounts{})
Expand Down
2 changes: 1 addition & 1 deletion go/models/plan_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ ORDER BY plan_task.created
Details: p[i].Details,
Duration: p[i].Duration,
ID: types.StringLimit(p[i].ID.String()),
Name: types.StringLimit("Task: " + string(p[i].Name)), //nolint:goconst
Name: types.StringLimit("Task: " + string(p[i].Name)),
Recurrence: p[i].Recurrence,
RecurrenceEnd: p[i].DateEnd,
Updated: &p[i].Updated,
Expand Down
4 changes: 2 additions & 2 deletions go/parse/html_to_jsonldrecipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ func HTMLToJSONLDRecipe(ctx context.Context, input string) (jsonld *JSONLDRecipe
for j := range howTo[i].ItemListElement {
jsonld.RecipeInstructions += howTo[i].ItemListElement[j].Text + "\n"
}
} else if howTo[i].Text != "" {
} else if howTo[i].Text != "" { //nolint:revive
jsonld.RecipeInstructions += howTo[i].Text + "\n"
}
}
} else if err := json.Unmarshal(jsonld.RecipeInstructionsRaw, &text); err == nil && len(text) > 0 {
for i := range text {
jsonld.RecipeInstructions += text[i].Text

if i < len(text) && !strings.HasSuffix(text[i].Text, "\n") {
if i < len(text) && !strings.HasSuffix(text[i].Text, "\n") { //nolint:revive
jsonld.RecipeInstructions += "\n"
}
}
Expand Down
5 changes: 2 additions & 3 deletions go/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package tasks

import (
"context"
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -154,7 +153,7 @@ func (t *Tasks) Start() { //nolint:gocognit

// CheckUpdate checks if there is a new update available.
func (t *Tasks) CheckUpdate(ctx context.Context) {
r, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api?p=server", t.Config.App.CloudEndpoint), nil)
r, err := http.NewRequestWithContext(ctx, http.MethodGet, t.Config.App.CloudEndpoint+"/api?p=server", nil)
if err != nil {
logger.Error(t.Context, errs.ErrReceiver.Wrap(err)) //nolint:errcheck

Expand Down Expand Up @@ -182,6 +181,6 @@ func (t *Tasks) CheckUpdate(ctx context.Context) {
}

if infos[0].Version != cli.BuildVersion {
logger.Info(ctx, fmt.Sprintf("A new version of Homechart is available: %s", infos[0].Version))
logger.Info(ctx, "A new version of Homechart is available: "+infos[0].Version)
}
}
1 change: 0 additions & 1 deletion hugo/content/about/platform/home.png

This file was deleted.

2 changes: 1 addition & 1 deletion hugo/content/blog/whats-new-202310.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ We have deprecated YAML support for Homechart configurations in this release. P
{{% /alert %}}

{{% alert title="Deprecation Warning" color="warning" %}}
We are changing our environment variable format. The old format of uppercase snake case `HOMECHART_CLI_DEBUG` will no longer work in future versions. Please convert your environment variables to camel case snake case (`HOMECHART_cli_debug`). Visit [the config docs]({{< ref " /docs/references/config" >}}) for more information.
We are changing our environment variable format. The old format of uppercase snake case `HOMECHART_CLI_DEBUG` will no longer work in future versions. Please convert your environment variables to camel case snake case (`HOMECHART_cli_debug`). Visit [the config docs]({{< ref "/docs/references/config" >}}) for more information.
{{% /alert %}}

## Enhancements
Expand Down
15 changes: 15 additions & 0 deletions hugo/content/blog/whats-new-202404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
author: Mike
date: 2024-04-01
description: Release notes for Homechart v2024.04.
tags:
- release
title: "What's New in Homechart: v2024.04"
type: blog
---

{{< homechart-release version="2024.04" >}}

## Enhancements

- Updated Go to 1.22.1.
1 change: 0 additions & 1 deletion hugo/content/docs/references/jsonnet.md

This file was deleted.

8 changes: 8 additions & 0 deletions hugo/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ disableLanguages:
- hi
- nl
- zh
module:
mounts:
- source: content
target: content
- source: content/home.png
target: content/about/platform/home.png
- source: ../shared/hugo/pages/jsonnet.md
target: content/docs/references/jsonnet.md
menu:
main:
- name: Get Homechart
Expand Down
2 changes: 1 addition & 1 deletion shared
Submodule shared updated from e117fa to ed0b38

0 comments on commit 9d05e8f

Please sign in to comment.