1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-11-09 11:50:11 +00:00

Compare commits

..

10 Commits

Author SHA1 Message Date
dependabot[bot]
610ca635f3
Merge 97506c0bcd into 6b576f2ffe 2024-07-24 22:11:51 +02:00
6b576f2ffe
announce: URL encode/decode template labels
Fixes #340, allowing slashes (/) in label names which would break the
URL otherwise.
2024-07-21 17:45:36 +01:00
7c989fda08
tls: don't "crash" on server close
TLS server section called Fatalf, while the normal section called Printf
on server close. Fatalf is now only called if the server wasn't shutdown
manually, e.g. when certificates are wrong. Same change was applied to
non-tls section, so crashes will actually occur when things like ports are occupied.

Fixes #343.
2024-07-21 17:27:41 +01:00
a4d436b16b
build: increase goreleaser build timeout
CI server is quite slow, so the 30m timeout of goreleaser was being
exceeded. Bumped to 60m, as defined by "TIMEOUT" in version.sh.
2024-07-21 14:29:35 +01:00
9339992693
Merge branch 'main' of github.com:hrfee/jfa-go 2024-07-14 00:32:25 +01:00
214d16cf0e
goreleaser: increment version
no actual changes.
2024-07-14 00:30:01 +01:00
a085e91cc6
Merge pull request #347 from jeppevinkel/patch-1
Fix referral url when subdomain contains `account`
2024-07-13 23:33:46 +01:00
272c38e0c5
user: url split on pathname only 2024-07-13 14:22:05 +01:00
jeppevinkel
6052329c0b
Fix deprecated georeleaser flag
Updated the `--skip-publish` flag to the new `--skip=publish` format.
2024-07-10 09:07:21 +02:00
jeppevinkel
acfdcdbc63
Fix referral url when subdomain contains account
This fix should work to grab the base url more consistently when the sub domain includes `account` in the name.
2024-07-10 01:22:12 +02:00
8 changed files with 42 additions and 15 deletions

View File

@ -85,7 +85,7 @@ steps:
commands: commands:
- curl -sL https://git.io/goreleaser > goreleaser - curl -sL https://git.io/goreleaser > goreleaser
- chmod +x goreleaser - chmod +x goreleaser
- ./scripts/version.sh ./goreleaser --snapshot --skip-publish --clean - ./scripts/version.sh ./goreleaser --snapshot --skip=publish --clean
- wget https://builds.hrfee.pw/upload.py - wget https://builds.hrfee.pw/upload.py
- pip3 install requests - pip3 install requests
- bash -c 'sftp -i /id_rsa2 -o StrictHostKeyChecking=no root@161.97.102.153:/mnt/redoc <<< $"put docs/swagger.json jfa-go.json"' - bash -c 'sftp -i /id_rsa2 -o StrictHostKeyChecking=no root@161.97.102.153:/mnt/redoc <<< $"put docs/swagger.json jfa-go.json"'
@ -164,7 +164,7 @@ steps:
commands: commands:
- curl -sL https://git.io/goreleaser > goreleaser - curl -sL https://git.io/goreleaser > goreleaser
- chmod +x goreleaser - chmod +x goreleaser
- ./scripts/version.sh ./goreleaser --snapshot --skip-publish --clean - ./scripts/version.sh ./goreleaser --snapshot --skip=publish --clean
trigger: trigger:
event: event:

View File

@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
project_name: jfa-go project_name: jfa-go
release: release:
github: github:

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"net/url"
"os" "os"
"strings" "strings"
"time" "time"
@ -927,12 +928,17 @@ func (app *appContext) GetAnnounceTemplates(gc *gin.Context) {
// @Produce json // @Produce json
// @Success 200 {object} announcementTemplate // @Success 200 {object} announcementTemplate
// @Failure 400 {object} boolResponse // @Failure 400 {object} boolResponse
// @Param name path string true "name of template" // @Param name path string true "name of template (url encoded if necessary)"
// @Router /users/announce/template/{name} [get] // @Router /users/announce/template/{name} [get]
// @Security Bearer // @Security Bearer
// @tags Users // @tags Users
func (app *appContext) GetAnnounceTemplate(gc *gin.Context) { func (app *appContext) GetAnnounceTemplate(gc *gin.Context) {
name := gc.Param("name") escapedName := gc.Param("name")
name, err := url.QueryUnescape(escapedName)
if err != nil {
respondBool(400, false, gc)
return
}
if announcement, ok := app.storage.GetAnnouncementsKey(name); ok { if announcement, ok := app.storage.GetAnnouncementsKey(name); ok {
gc.JSON(200, announcement) gc.JSON(200, announcement)
return return

View File

@ -566,11 +566,19 @@ func start(asDaemon, firstCall bool) {
} }
} }
if err == http.ErrServerClosed {
app.err.Printf("Failure serving with SSL/TLS: %s", err)
} else {
app.err.Fatalf("Failure serving with SSL/TLS: %s", err) app.err.Fatalf("Failure serving with SSL/TLS: %s", err)
} }
}
} else { } else {
if err := SRV.ListenAndServe(); err != nil { if err := SRV.ListenAndServe(); err != nil {
if err == http.ErrServerClosed {
app.err.Printf("Failure serving: %s", err) app.err.Printf("Failure serving: %s", err)
} else {
app.err.Fatalf("Failure serving: %s", err)
}
} }
} }
}() }()

1
package-lock.json generated
View File

@ -1653,6 +1653,7 @@
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz",
"integrity": "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==", "integrity": "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT",
"optional": true, "optional": true,
"bin": { "bin": {
"esbuild": "bin/esbuild" "esbuild": "bin/esbuild"

View File

@ -16,4 +16,6 @@ else
fi fi
JFA_GO_VERSION=$(git describe --exact-match HEAD 2> /dev/null || echo 'vgit') JFA_GO_VERSION=$(git describe --exact-match HEAD 2> /dev/null || echo 'vgit')
JFA_GO_CSS_VERSION="v3" JFA_GO_NFPM_EPOCH=$(git rev-list --all --count) JFA_GO_BUILD_TIME=$(date +%s) JFA_GO_BUILT_BY=${JFA_GO_BUILT_BY:-"???"} JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@ TIMEOUT=60m
JFA_GO_CSS_VERSION="v3" JFA_GO_NFPM_EPOCH=$(git rev-list --all --count) JFA_GO_BUILD_TIME=$(date +%s) JFA_GO_BUILT_BY=${JFA_GO_BUILT_BY:-"???"} JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@ --timeout $TIMEOUT

View File

@ -1275,8 +1275,9 @@ export class accountsList {
el.innerHTML = ` el.innerHTML = `
<span class="button ~neutral sm full-width accounts-announce-template-button">${name}</span><span class="button ~critical fr ml-4 accounts-announce-template-delete">&times;</span> <span class="button ~neutral sm full-width accounts-announce-template-button">${name}</span><span class="button ~critical fr ml-4 accounts-announce-template-delete">&times;</span>
`; `;
let urlSafeName = encodeURIComponent(encodeURIComponent(name));
(el.querySelector("span.accounts-announce-template-button") as HTMLSpanElement).onclick = () => { (el.querySelector("span.accounts-announce-template-button") as HTMLSpanElement).onclick = () => {
_get("/users/announce/" + name, null, (req: XMLHttpRequest) => { _get("/users/announce/" + urlSafeName, null, (req: XMLHttpRequest) => {
if (req.readyState == 4) { if (req.readyState == 4) {
let template: announcementTemplate; let template: announcementTemplate;
if (req.status != 200) { if (req.status != 200) {
@ -1289,7 +1290,7 @@ export class accountsList {
}); });
}; };
(el.querySelector("span.accounts-announce-template-delete") as HTMLSpanElement).onclick = () => { (el.querySelector("span.accounts-announce-template-delete") as HTMLSpanElement).onclick = () => {
_delete("/users/announce/" + name, null, (req: XMLHttpRequest) => { _delete("/users/announce/" + urlSafeName, null, (req: XMLHttpRequest) => {
if (req.readyState == 4) { if (req.readyState == 4) {
if (req.status != 200) { if (req.status != 200) {
window.notifications.customError("deleteTemplateError", window.lang.notif("errorFailureCheckLogs")); window.notifications.customError("deleteTemplateError", window.lang.notif("errorFailureCheckLogs"));

View File

@ -266,13 +266,20 @@ class ReferralCard {
get code(): string { return this._code; } get code(): string { return this._code; }
set code(c: string) { set code(c: string) {
this._code = c; this._code = c;
let url = window.location.href;
for (let split of ["#", "?", "account", "my"]) { let u = new URL(window.location.href);
url = url.split(split)[0]; let path = u.pathname;
for (let split of ["account", "my"]) {
path = path.split(split)[0];
} }
if (url.slice(-1) != "/") { url += "/"; } if (path.slice(-1) != "/") { path += "/"; }
url = url + "invite/" + this._code; path = path + "invite/" + this._code;
this._url = url;
u.pathname = path;
u.hash = "";
u.search = "";
this._url = u.toString();
} }
get remaining_uses(): number { return this._remainingUses; } get remaining_uses(): number { return this._remainingUses; }