Compare commits
No commits in common. "master" and "wip-gitea-webhook" have entirely different histories.
master
...
wip-gitea-
27 changed files with 995 additions and 1684 deletions
|
@ -1,24 +1,4 @@
|
||||||
steps:
|
pipeline:
|
||||||
librepages-conductor:
|
|
||||||
image: realaravinth/librepages-conductor
|
|
||||||
detach: true
|
|
||||||
environment:
|
|
||||||
- LPCONDUCTOR__SOURCE_CODE=https://git.batsense.net/LibrePages/conductor
|
|
||||||
- LPCONDUCTOR_SERVER__PROXY_HAS_TLS=false
|
|
||||||
- LPCONDUCTOR_DEBUG=false
|
|
||||||
- LPCONDUCTOR_CONDUCTOR=dummy
|
|
||||||
- LPCONDUCTOR_SERVER_DOMAIN=librepages.test
|
|
||||||
- LPCONDUCTOR_SERVER_IP=0.0.0.0
|
|
||||||
- LPCONDUCTOR_SERVER_PROXY_HAS_TLS=false
|
|
||||||
- LPCONDUCTOR_SERVER_PORT=7000
|
|
||||||
- LPCONDUCTOR_SOURCE_CODE=https://example.org
|
|
||||||
- LPCONDUCTOR_CREDS_USERNAME=librepages_api
|
|
||||||
- LPCONDUCTOR_CREDS_TOKEN=longrandomlygeneratedpassword
|
|
||||||
- PORT=5000
|
|
||||||
- LPCONDUCTOR_CREDS_PASSWORD=longrandomlygeneratedpassword
|
|
||||||
commands:
|
|
||||||
- conductor serve
|
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: rust
|
image: rust
|
||||||
environment:
|
environment:
|
||||||
|
@ -49,14 +29,12 @@ steps:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
when:
|
when:
|
||||||
event: [push, tag, deployment]
|
event: [push, tag, deployment]
|
||||||
branch: master
|
|
||||||
settings:
|
settings:
|
||||||
username: realaravinth
|
username: realaravinth
|
||||||
password:
|
password:
|
||||||
from_secret: DOCKER_TOKEN
|
from_secret: DOCKER_TOKEN
|
||||||
repo: realaravinth/librepages
|
repo: realaravinth/librepages
|
||||||
tags:
|
tags: latest
|
||||||
latest
|
|
||||||
|
|
||||||
# build_publisher_docker_img:
|
# build_publisher_docker_img:
|
||||||
# image: plugins/docker
|
# image: plugins/docker
|
||||||
|
@ -73,7 +51,6 @@ steps:
|
||||||
image: rust
|
image: rust
|
||||||
when:
|
when:
|
||||||
event: [push, tag, deployment]
|
event: [push, tag, deployment]
|
||||||
branch: master
|
|
||||||
commands:
|
commands:
|
||||||
- apt update
|
- apt update
|
||||||
- apt-get -y --no-install-recommends install gpg tar curl wget
|
- apt-get -y --no-install-recommends install gpg tar curl wget
|
||||||
|
@ -86,3 +63,20 @@ services:
|
||||||
image: postgres
|
image: postgres
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=password
|
- POSTGRES_PASSWORD=password
|
||||||
|
|
||||||
|
librepages-conductor:
|
||||||
|
image: realaravinth/librepages-conductor
|
||||||
|
command: conductor serve
|
||||||
|
environment:
|
||||||
|
- LPCONDUCTOR_SERVER__PROXY_HAS_TLS=false
|
||||||
|
- LPCONDUCTOR_DEBUG=false
|
||||||
|
- LPCONDUCTOR_CONDUCTOR=dummy
|
||||||
|
- LPCONDUCTOR_SERVER_URL_PREFIX=""
|
||||||
|
- LPCONDUCTOR_SERVER_DOMAIN="librepages.test"
|
||||||
|
- LPCONDUCTOR_SERVER_IP=0.0.0.0
|
||||||
|
- LPCONDUCTOR_SERVER_PROXY_HAS_TLS=false
|
||||||
|
- LPCONDUCTOR_SERVER_PORT=7000
|
||||||
|
- LPCONDUCTOR_SOURCE_CODE=https://example.org
|
||||||
|
- LPCONDUCTOR_CREDS_USERNAME="librepages_api"
|
||||||
|
- LPCONDUCTOR_CREDS_PASSWORD="longrandomlygeneratedpassword"
|
||||||
|
- PORT=5000
|
||||||
|
|
1492
Cargo.lock
generated
1492
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
20
Cargo.toml
20
Cargo.toml
|
@ -20,17 +20,17 @@ actix-rt = "2"
|
||||||
actix-web-codegen-const-routes = { version = "0.1.0", tag = "0.1.0", git = "https://github.com/realaravinth/actix-web-codegen-const-routes" }
|
actix-web-codegen-const-routes = { version = "0.1.0", tag = "0.1.0", git = "https://github.com/realaravinth/actix-web-codegen-const-routes" }
|
||||||
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||||
sqlx = { version = "0.6.2", features = ["runtime-actix-rustls", "postgres", "time", "offline", "json", "uuid"] }
|
sqlx = { version = "0.6.2", features = ["runtime-actix-rustls", "postgres", "time", "offline", "json", "uuid"] }
|
||||||
clap = { version = "4.0.0", features = ["derive"]}
|
clap = { version = "3.2.20", features = ["derive"]}
|
||||||
libconfig = { version = "0.1.0", git = "https://git.batsense.net/librepages/libconfig" }
|
libconfig = { version = "0.1.0", git = "https://git.batsense.net/librepages/libconfig" }
|
||||||
libconductor = { version = "0.1.0", git = "https://git.batsense.net/librepages/conductor/" }
|
libconductor = { version = "0.1.0", git = "https://git.batsense.net/librepages/conductor/" }
|
||||||
|
|
||||||
config = "0.14"
|
config = "0.13"
|
||||||
git2 = "0.19.0"
|
git2 = "0.14.2"
|
||||||
|
|
||||||
serde = { version = "1", features = ["derive", "rc"]}
|
serde = { version = "1", features = ["derive", "rc"]}
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
||||||
pretty_env_logger = "0.5"
|
pretty_env_logger = "0.4"
|
||||||
|
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
url = { version = "2.2", features = ["serde"] }
|
url = { version = "2.2", features = ["serde"] }
|
||||||
|
@ -41,18 +41,18 @@ derive_more = "0.99"
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.13"
|
||||||
|
|
||||||
tokio = { version = "1", features=["sync"]}
|
tokio = { version = "1", features=["sync"]}
|
||||||
num_enum = "0.7.0"
|
num_enum = "0.5.7"
|
||||||
|
|
||||||
mime_guess = "2.0.4"
|
mime_guess = "2.0.4"
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
rust-embed = "8.0.0"
|
rust-embed = "6.3.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
tracing = { version = "0.1.37", features = ["log"]}
|
tracing = { version = "0.1.37", features = ["log"]}
|
||||||
tracing-actix-web = "0.7.0"
|
tracing-actix-web = "0.6.2"
|
||||||
toml = "0.8.0"
|
toml = "0.5.9"
|
||||||
serde_yaml = "0.9.14"
|
serde_yaml = "0.9.14"
|
||||||
uuid = { version = "1.2.2", features = ["serde"] }
|
uuid = { version = "1.2.2", features = ["serde"] }
|
||||||
reqwest = { version = "0.12.0", features = ["json"] }
|
reqwest = { version = "0.11.13", features = ["json"] }
|
||||||
sha2 = "0.10.6"
|
sha2 = "0.10.6"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
hex= "0.4.3"
|
hex= "0.4.3"
|
||||||
|
@ -73,7 +73,7 @@ version = "0.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
futures = "0.3.24"
|
futures = "0.3.24"
|
||||||
mktemp = "0.5.0"
|
mktemp = "0.4.1"
|
||||||
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM node:20.17.0 as frontend
|
FROM node:16.9.1 as frontend
|
||||||
COPY package.json package-lock.json /src/
|
COPY package.json package-lock.json /src/
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS librepages_forgejo_webhooks (
|
|
||||||
forgejo_webhook_secret VARCHAR(40) NOT NULL UNIQUE,
|
|
||||||
forgejo_url VARCHAR(3000) NOT NULL,
|
|
||||||
auth_token VARCHAR(40) NOT NULL UNIQUE,
|
|
||||||
ID SERIAL PRIMARY KEY NOT NULL,
|
|
||||||
owned_by INTEGER NOT NULL references librepages_users(ID) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX librepages_forgejo_webhook_auth_token_index ON librepages_forgejo_webhooks(auth_token);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS librepages_forgejo_webhook_site_mapping (
|
|
||||||
site_id INTEGER NOT NULL references librepages_sites(ID) ON DELETE CASCADE,
|
|
||||||
forgejo_webhook_id INTEGER NOT NULL references librepages_forgejo_webhooks(ID) ON DELETE CASCADE,
|
|
||||||
UNIQUE(site_id, forgejo_webhook_id)
|
|
||||||
);
|
|
15
migrations/20221220010013_librepages_gitea_webhooks.sql
Normal file
15
migrations/20221220010013_librepages_gitea_webhooks.sql
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS librepages_gitea_webhooks (
|
||||||
|
gitea_webhook_secret VARCHAR(40) NOT NULL UNIQUE,
|
||||||
|
gitea_url VARCHAR(3000) NOT NULL,
|
||||||
|
auth_token VARCHAR(40) NOT NULL UNIQUE,
|
||||||
|
ID SERIAL PRIMARY KEY NOT NULL,
|
||||||
|
owned_by INTEGER NOT NULL references librepages_users(ID) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX librepages_gitea_webhook_auth_token_index ON librepages_gitea_webhooks(auth_token);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS librepages_gitea_webhook_site_mapping (
|
||||||
|
site_id INTEGER NOT NULL references librepages_sites(ID) ON DELETE CASCADE,
|
||||||
|
gitea_webhook_id INTEGER NOT NULL references librepages_gitea_webhooks(ID) ON DELETE CASCADE,
|
||||||
|
UNIQUE(site_id, gitea_webhook_id)
|
||||||
|
);
|
339
package-lock.json
generated
339
package-lock.json
generated
|
@ -12,20 +12,104 @@
|
||||||
"sass": "^1.54.9"
|
"sass": "^1.54.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/chokidar": {
|
"node_modules/anymatch": {
|
||||||
"version": "4.0.0",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-mxIojEAQcuEvT/lyXq+jf/3cO/KoA6z4CeNDGGevTybECPOMFCnQy3OPahluUkbqgPNGw5Bi78UC7Po6Lhy+NA==",
|
"integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"readdirp": "^4.0.1"
|
"normalize-path": "^3.0.0",
|
||||||
|
"picomatch": "^2.0.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.16.0"
|
"node": ">= 8"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"funding": {
|
"node_modules/binary-extensions": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/braces": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"fill-range": "^7.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/chokidar": {
|
||||||
|
"version": "3.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||||
|
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
|
||||||
|
"dev": true,
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
"url": "https://paulmillr.com/funding/"
|
"url": "https://paulmillr.com/funding/"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"anymatch": "~3.1.2",
|
||||||
|
"braces": "~3.0.2",
|
||||||
|
"glob-parent": "~5.1.2",
|
||||||
|
"is-binary-path": "~2.1.0",
|
||||||
|
"is-glob": "~4.0.1",
|
||||||
|
"normalize-path": "~3.0.0",
|
||||||
|
"readdirp": "~3.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.10.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "~2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fill-range": {
|
||||||
|
"version": "7.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"to-regex-range": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/glob-parent": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-glob": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/immutable": {
|
"node_modules/immutable": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
|
@ -33,26 +117,88 @@
|
||||||
"integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==",
|
"integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/readdirp": {
|
"node_modules/is-binary-path": {
|
||||||
"version": "4.0.1",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||||
"integrity": "sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==",
|
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"binary-extensions": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-extglob": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.16.0"
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-glob": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-extglob": "^2.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/is-number": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/normalize-path": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/picomatch": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "individual",
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
"url": "https://paulmillr.com/funding/"
|
}
|
||||||
|
},
|
||||||
|
"node_modules/readdirp": {
|
||||||
|
"version": "3.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||||
|
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"picomatch": "^2.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sass": {
|
"node_modules/sass": {
|
||||||
"version": "1.79.3",
|
"version": "1.54.9",
|
||||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.79.3.tgz",
|
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.9.tgz",
|
||||||
"integrity": "sha512-m7dZxh0W9EZ3cw50Me5GOuYm/tVAJAn91SUnohLRo9cXBixGUOdvmryN+dXpwR831bhoY3Zv7rEFt85PUwTmzA==",
|
"integrity": "sha512-xb1hjASzEH+0L0WI9oFjqhRi51t/gagWnxLiwUNMltA0Ab6jIDkAacgKiGYKM9Jhy109osM7woEEai6SXeJo5Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": "^4.0.0",
|
"chokidar": ">=3.0.0 <4.0.0",
|
||||||
"immutable": "^4.0.0",
|
"immutable": "^4.0.0",
|
||||||
"source-map-js": ">=0.6.2 <2.0.0"
|
"source-map-js": ">=0.6.2 <2.0.0"
|
||||||
},
|
},
|
||||||
|
@ -60,7 +206,7 @@
|
||||||
"sass": "sass.js"
|
"sass": "sass.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0.0"
|
"node": ">=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
|
@ -71,16 +217,85 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/to-regex-range": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-number": "^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chokidar": {
|
"anymatch": {
|
||||||
"version": "4.0.0",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-mxIojEAQcuEvT/lyXq+jf/3cO/KoA6z4CeNDGGevTybECPOMFCnQy3OPahluUkbqgPNGw5Bi78UC7Po6Lhy+NA==",
|
"integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"readdirp": "^4.0.1"
|
"normalize-path": "^3.0.0",
|
||||||
|
"picomatch": "^2.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"binary-extensions": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"braces": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"fill-range": "^7.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chokidar": {
|
||||||
|
"version": "3.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||||
|
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"anymatch": "~3.1.2",
|
||||||
|
"braces": "~3.0.2",
|
||||||
|
"fsevents": "~2.3.2",
|
||||||
|
"glob-parent": "~5.1.2",
|
||||||
|
"is-binary-path": "~2.1.0",
|
||||||
|
"is-glob": "~4.0.1",
|
||||||
|
"normalize-path": "~3.0.0",
|
||||||
|
"readdirp": "~3.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fill-range": {
|
||||||
|
"version": "7.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"to-regex-range": "^5.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"glob-parent": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-glob": "^4.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"immutable": {
|
"immutable": {
|
||||||
|
@ -89,19 +304,64 @@
|
||||||
"integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==",
|
"integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"readdirp": {
|
"is-binary-path": {
|
||||||
"version": "4.0.1",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||||
"integrity": "sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==",
|
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"sass": {
|
|
||||||
"version": "1.79.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.79.3.tgz",
|
|
||||||
"integrity": "sha512-m7dZxh0W9EZ3cw50Me5GOuYm/tVAJAn91SUnohLRo9cXBixGUOdvmryN+dXpwR831bhoY3Zv7rEFt85PUwTmzA==",
|
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"chokidar": "^4.0.0",
|
"binary-extensions": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-extglob": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"is-glob": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-extglob": "^2.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-number": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"normalize-path": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"picomatch": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"readdirp": {
|
||||||
|
"version": "3.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||||
|
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"picomatch": "^2.2.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sass": {
|
||||||
|
"version": "1.54.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/sass/-/sass-1.54.9.tgz",
|
||||||
|
"integrity": "sha512-xb1hjASzEH+0L0WI9oFjqhRi51t/gagWnxLiwUNMltA0Ab6jIDkAacgKiGYKM9Jhy109osM7woEEai6SXeJo5Q==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"chokidar": ">=3.0.0 <4.0.0",
|
||||||
"immutable": "^4.0.0",
|
"immutable": "^4.0.0",
|
||||||
"source-map-js": ">=0.6.2 <2.0.0"
|
"source-map-js": ">=0.6.2 <2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -111,6 +371,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
||||||
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
},
|
||||||
|
"to-regex-range": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"is-number": "^7.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"extends": [
|
|
||||||
"config:recommended",
|
|
||||||
":dependencyDashboard"
|
|
||||||
],
|
|
||||||
"labels": [
|
|
||||||
"renovate-bot"
|
|
||||||
],
|
|
||||||
"prHourlyLimit": 0,
|
|
||||||
"timezone": "Asia/kolkata",
|
|
||||||
"prCreation": "immediate",
|
|
||||||
"vulnerabilityAlerts": {
|
|
||||||
"enabled": true,
|
|
||||||
"labels": [
|
|
||||||
"renovate-bot",
|
|
||||||
"renovate-security",
|
|
||||||
"security"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
271
sqlx-data.json
271
sqlx-data.json
|
@ -98,6 +98,38 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT name, password FROM librepages_users WHERE name = ($1)"
|
"query": "SELECT name, password FROM librepages_users WHERE name = ($1)"
|
||||||
},
|
},
|
||||||
|
"278dafae8343ee7b15b7014707a769e6d8f5042478c001d3dbe6cdad919f4546": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "gitea_url",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "auth_token",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gitea_webhook_secret",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "SELECT\n gitea_url, auth_token, gitea_webhook_secret\n FROM\n librepages_gitea_webhooks\n WHERE\n owned_by = (SELECT ID FROM librepages_users WHERE name = $1);\n "
|
||||||
|
},
|
||||||
"279b5ae27935279b06d2799eef2da6a316324a05d23ba7a729c608c70168c496": {
|
"279b5ae27935279b06d2799eef2da6a316324a05d23ba7a729c608c70168c496": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [],
|
"columns": [],
|
||||||
|
@ -144,39 +176,6 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT\n librepages_deploy_event_type.name,\n librepages_site_deploy_events.time,\n librepages_site_deploy_events.pub_id\n FROM\n librepages_site_deploy_events\n INNER JOIN librepages_deploy_event_type ON\n librepages_deploy_event_type.ID = librepages_site_deploy_events.event_type\n WHERE\n librepages_site_deploy_events.site = (\n SELECT ID FROM librepages_sites WHERE hostname = $1\n )\n AND\n librepages_site_deploy_events.pub_id = $2\n "
|
"query": "SELECT\n librepages_deploy_event_type.name,\n librepages_site_deploy_events.time,\n librepages_site_deploy_events.pub_id\n FROM\n librepages_site_deploy_events\n INNER JOIN librepages_deploy_event_type ON\n librepages_deploy_event_type.ID = librepages_site_deploy_events.event_type\n WHERE\n librepages_site_deploy_events.site = (\n SELECT ID FROM librepages_sites WHERE hostname = $1\n )\n AND\n librepages_site_deploy_events.pub_id = $2\n "
|
||||||
},
|
},
|
||||||
"3ecc3a4c89b1289368ef9d9c97204330f74138a0da614ef2174c59a687119595": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "forgejo_url",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "auth_token",
|
|
||||||
"ordinal": 1,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "forgejo_webhook_secret",
|
|
||||||
"ordinal": 2,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text",
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "SELECT\n forgejo_url, auth_token, forgejo_webhook_secret\n FROM\n librepages_forgejo_webhooks\n WHERE\n auth_token = $1\n AND\n owned_by = (SELECT ID FROM librepages_users WHERE name = $2);\n "
|
|
||||||
},
|
|
||||||
"432fe829719ce8110f768b4a611724bb34191ac224d2143ff4c81548da75c103": {
|
"432fe829719ce8110f768b4a611724bb34191ac224d2143ff4c81548da75c103": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -272,26 +271,6 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT repo_url, site_secret, branch, hostname, owned_by, pub_id\n FROM librepages_sites\n WHERE repo_url = $1\n AND deleted = false;\n "
|
"query": "SELECT repo_url, site_secret, branch, hostname, owned_by, pub_id\n FROM librepages_sites\n WHERE repo_url = $1\n AND deleted = false;\n "
|
||||||
},
|
},
|
||||||
"4cddf1049783251bfc79090055724e894a2be9451302f7691ce2f4240f1ee3ad": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Int4"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
false
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "SELECT ID FROM librepages_sites WHERE repo_url = $1"
|
|
||||||
},
|
|
||||||
"53f3c21c06c8d1c218537dfa9183fd0604aaf28200d8aa12e97db4ac317df39e": {
|
"53f3c21c06c8d1c218537dfa9183fd0604aaf28200d8aa12e97db4ac317df39e": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -473,6 +452,71 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT\n time,\n pub_id\n FROM\n librepages_site_deploy_events\n WHERE\n site = (SELECT ID FROM librepages_sites WHERE hostname = $1)\n AND\n event_type = (SELECT ID FROM librepages_deploy_event_type WHERE name = $2)\n AND\n time = (\n SELECT MAX(time) \n FROM\n librepages_site_deploy_events\n WHERE\n site = (SELECT ID FROM librepages_sites WHERE hostname = $1)\n )\n "
|
"query": "SELECT\n time,\n pub_id\n FROM\n librepages_site_deploy_events\n WHERE\n site = (SELECT ID FROM librepages_sites WHERE hostname = $1)\n AND\n event_type = (SELECT ID FROM librepages_deploy_event_type WHERE name = $2)\n AND\n time = (\n SELECT MAX(time) \n FROM\n librepages_site_deploy_events\n WHERE\n site = (SELECT ID FROM librepages_sites WHERE hostname = $1)\n )\n "
|
||||||
},
|
},
|
||||||
|
"78d6aacc46441d72e42bc8d74f36f98056b442dd0e624757b1f25db29610cb08": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "gitea_url",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "auth_token",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gitea_webhook_secret",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "SELECT\n gitea_url, auth_token, gitea_webhook_secret\n FROM\n librepages_gitea_webhooks\n WHERE\n auth_token = $1\n AND\n owned_by = (SELECT ID FROM librepages_users WHERE name = $2);\n "
|
||||||
|
},
|
||||||
|
"7d2b7a4a57b9b031d15db57116807355e9e03b7bf9b0cff0958bfebe4bc1d1be": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "gitea_url",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "auth_token",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gitea_webhook_secret",
|
||||||
|
"ordinal": 2,
|
||||||
|
"type_info": "Varchar"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "SELECT gitea_url, auth_token, gitea_webhook_secret\n FROM librepages_gitea_webhooks\n WHERE auth_token = $1\n "
|
||||||
|
},
|
||||||
"8735b654bc261571e6a5908d55a8217474c76bdff7f3cbcc71500a0fe13249db": {
|
"8735b654bc261571e6a5908d55a8217474c76bdff7f3cbcc71500a0fe13249db": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -493,21 +537,6 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT EXISTS (SELECT 1 from librepages_users WHERE email = $1)"
|
"query": "SELECT EXISTS (SELECT 1 from librepages_users WHERE email = $1)"
|
||||||
},
|
},
|
||||||
"8bf4e01b8c38d035fe6bdbfbe8ad9cb35e3fc2fd11107bae92880d157ed11379": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"nullable": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Varchar",
|
|
||||||
"Varchar",
|
|
||||||
"Varchar",
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "INSERT INTO librepages_forgejo_webhooks\n (forgejo_url , auth_token, forgejo_webhook_secret, owned_by) VALUES ($1, $2, $3, \n (SELECT ID FROM librepages_users WHERE name = $4)\n )"
|
|
||||||
},
|
|
||||||
"90907d6cb4ca3b485f7b583584fb5821a950362679d061e490545c76634c211e": {
|
"90907d6cb4ca3b485f7b583584fb5821a950362679d061e490545c76634c211e": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -541,70 +570,6 @@
|
||||||
},
|
},
|
||||||
"query": "UPDATE librepages_users set password = $1\n WHERE name = $2"
|
"query": "UPDATE librepages_users set password = $1\n WHERE name = $2"
|
||||||
},
|
},
|
||||||
"9710a01bc4c5c5cda2db27d14baca3d7a6ceffa66c7d539da6fda7947c222e71": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "forgejo_url",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "auth_token",
|
|
||||||
"ordinal": 1,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "forgejo_webhook_secret",
|
|
||||||
"ordinal": 2,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "SELECT\n forgejo_url, auth_token, forgejo_webhook_secret\n FROM\n librepages_forgejo_webhooks\n WHERE\n owned_by = (SELECT ID FROM librepages_users WHERE name = $1);\n "
|
|
||||||
},
|
|
||||||
"a6284ede1dbf340942dd97afb75865ba0a41009a145254117b03002bd9afa588": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "forgejo_url",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "auth_token",
|
|
||||||
"ordinal": 1,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "forgejo_webhook_secret",
|
|
||||||
"ordinal": 2,
|
|
||||||
"type_info": "Varchar"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "SELECT forgejo_url, auth_token, forgejo_webhook_secret\n FROM librepages_forgejo_webhooks\n WHERE auth_token = $1\n "
|
|
||||||
},
|
|
||||||
"b48c77db6e663d97df44bf9ec2ee92fd3e02f2dcbcdbd1d491e09fab2da68494": {
|
"b48c77db6e663d97df44bf9ec2ee92fd3e02f2dcbcdbd1d491e09fab2da68494": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -631,20 +596,6 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT name, password FROM librepages_users WHERE email = ($1)"
|
"query": "SELECT name, password FROM librepages_users WHERE email = ($1)"
|
||||||
},
|
},
|
||||||
"b7e51e976a4a80a78df8dbfed1f195af212023d00faee88ab2d09326896bd653": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"nullable": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text",
|
|
||||||
"Int4",
|
|
||||||
"Text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "INSERT INTO librepages_forgejo_webhook_site_mapping\n (site_id, forgejo_webhook_id) VALUES (\n (SELECT ID FROM librepages_sites WHERE repo_url = $1 AND ID = $2),\n (SELECT ID FROM librepages_forgejo_webhooks WHERE auth_token = $3)\n ) ON CONFLICT (site_id, forgejo_webhook_id) DO NOTHING;"
|
|
||||||
},
|
|
||||||
"b8b1b3c5fa205b071f577b2ce9993ddfc7c99ada26aea48aa1c201c8c3c7fcf6": {
|
"b8b1b3c5fa205b071f577b2ce9993ddfc7c99ada26aea48aa1c201c8c3c7fcf6": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [],
|
"columns": [],
|
||||||
|
@ -682,6 +633,21 @@
|
||||||
},
|
},
|
||||||
"query": "SELECT EXISTS (SELECT 1 from librepages_users WHERE name = $1)"
|
"query": "SELECT EXISTS (SELECT 1 from librepages_users WHERE name = $1)"
|
||||||
},
|
},
|
||||||
|
"cd2347774ea740deae59e031a398adfc0b5c2942e556faa676fbd161297a81a6": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"nullable": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Varchar",
|
||||||
|
"Varchar",
|
||||||
|
"Varchar",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "INSERT INTO librepages_gitea_webhooks\n (gitea_url , auth_token, gitea_webhook_secret, owned_by) VALUES ($1, $2, $3, \n (SELECT ID FROM librepages_users WHERE name = $4)\n )"
|
||||||
|
},
|
||||||
"ced69a08729ffb906e8971dbdce6a8d4197bc9bb8ccd7c58b3a88eb7be73fc2e": {
|
"ced69a08729ffb906e8971dbdce6a8d4197bc9bb8ccd7c58b3a88eb7be73fc2e": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
|
@ -779,5 +745,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"query": "INSERT INTO librepages_users\n (name , password, email) VALUES ($1, $2, $3)"
|
"query": "INSERT INTO librepages_users\n (name , password, email) VALUES ($1, $2, $3)"
|
||||||
|
},
|
||||||
|
"fdcad0cd77ae37ed74cc7c92f20f9d95d851af5f9c9e6e4c34c39abf4a1d0f14": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"nullable": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Text",
|
||||||
|
"Text"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "INSERT INTO librepages_gitea_webhook_site_mapping\n (site_id, gitea_webhook_id) VALUES (\n (SELECT ID FROM librepages_sites WHERE repo_url = $1),\n (SELECT ID FROM librepages_gitea_webhooks WHERE auth_token = $2)\n ) ON CONFLICT (site_id, gitea_webhook_id) DO NOTHING;"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,20 +26,20 @@ use crate::{errors::*, AppCtx};
|
||||||
pub mod routes {
|
pub mod routes {
|
||||||
use crate::ctx::Ctx;
|
use crate::ctx::Ctx;
|
||||||
|
|
||||||
pub struct Forgejo {
|
pub struct Gitea {
|
||||||
pub add_webhook: &'static str,
|
pub add_webhook: &'static str,
|
||||||
pub view_webhook: &'static str,
|
pub view_webhook: &'static str,
|
||||||
pub list_webhooks: &'static str,
|
pub list_webhooks: &'static str,
|
||||||
pub webhook: &'static str,
|
pub webhook: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Forgejo {
|
impl Gitea {
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
add_webhook: "/api/v1/forgejo/webhook/add",
|
add_webhook: "/api/v1/gitea/webhook/add",
|
||||||
list_webhooks: "/api/v1/forgejo/webhook/add",
|
list_webhooks: "/api/v1/gitea/webhook/add",
|
||||||
view_webhook: "/api/v1/forgejo/webhook/view/{auth_token}",
|
view_webhook: "/api/v1/gitea/webhook/view/{auth_token}",
|
||||||
webhook: "/api/v1/forgejo/webhook/event/new",
|
webhook: "/api/v1/gitea/webhook/event/new",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ pub mod routes {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct AddWebhook {
|
pub struct AddWebhook {
|
||||||
pub forgejo_url: Url,
|
pub gitea_url: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "crate::V1_API_ROUTES.forgejo.add_webhook",
|
path = "crate::V1_API_ROUTES.gitea.add_webhook",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "Add webhook" skip(id, ctx, payload))]
|
#[tracing::instrument(name = "Add webhook" skip(id, ctx, payload))]
|
||||||
|
@ -72,17 +72,17 @@ async fn add_webhook(
|
||||||
payload: web::Json<AddWebhook>,
|
payload: web::Json<AddWebhook>,
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
info!(
|
info!(
|
||||||
"Adding webhook for Forgejo instance: {}",
|
"Adding webhook for Gitea instance: {}",
|
||||||
payload.forgejo_url.as_str()
|
payload.gitea_url.as_str()
|
||||||
);
|
);
|
||||||
let owner = id.identity().unwrap();
|
let owner = id.identity().unwrap();
|
||||||
let payload = payload.into_inner();
|
let payload = payload.into_inner();
|
||||||
let hook = ctx.db.new_webhook(payload.forgejo_url, &owner).await?;
|
let hook = ctx.db.new_webhook(payload.gitea_url, &owner).await?;
|
||||||
Ok(HttpResponse::Ok().json(hook))
|
Ok(HttpResponse::Ok().json(hook))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "crate::V1_API_ROUTES.forgejo.list_webhooks",
|
path = "crate::V1_API_ROUTES.gitea.list_webhooks",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "Delete webhook" skip(id, ctx))]
|
#[tracing::instrument(name = "Delete webhook" skip(id, ctx))]
|
||||||
|
@ -94,7 +94,7 @@ async fn list_webhooks(ctx: AppCtx, id: Identity) -> ServiceResult<impl Responde
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "crate::V1_API_ROUTES.forgejo.view_webhook",
|
path = "crate::V1_API_ROUTES.gitea.view_webhook",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "Delete webhook" skip(id, ctx, path))]
|
#[tracing::instrument(name = "Delete webhook" skip(id, ctx, path))]
|
||||||
|
@ -105,7 +105,7 @@ async fn view_webhook(
|
||||||
) -> ServiceResult<impl Responder> {
|
) -> ServiceResult<impl Responder> {
|
||||||
let path = path.into_inner();
|
let path = path.into_inner();
|
||||||
let owner = id.identity().unwrap();
|
let owner = id.identity().unwrap();
|
||||||
info!("Gitting webhook webhook for Forgejo instance: {}", path,);
|
info!("Gitting webhook webhook for Gitea instance: {}", path,);
|
||||||
let hook = ctx.db.get_webhook_with_owner(&path, &owner).await?;
|
let hook = ctx.db.get_webhook_with_owner(&path, &owner).await?;
|
||||||
Ok(HttpResponse::Ok().json(hook))
|
Ok(HttpResponse::Ok().json(hook))
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ struct Auth {
|
||||||
auth: String,
|
auth: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::post(path = "crate::V1_API_ROUTES.forgejo.webhook")]
|
#[actix_web_codegen_const_routes::post(path = "crate::V1_API_ROUTES.gitea.webhook")]
|
||||||
#[tracing::instrument(name = "Update ", skip(body, ctx, req, q))]
|
#[tracing::instrument(name = "Update ", skip(body, ctx, req, q))]
|
||||||
async fn webhook(
|
async fn webhook(
|
||||||
ctx: AppCtx,
|
ctx: AppCtx,
|
||||||
|
@ -139,18 +139,18 @@ mod tests {
|
||||||
use actix_web::{error::ResponseError, http::StatusCode, test};
|
use actix_web::{error::ResponseError, http::StatusCode, test};
|
||||||
use hmac::Mac;
|
use hmac::Mac;
|
||||||
|
|
||||||
use crate::ctx::api::v1::forgejo::{HmacSha256, WebhookPayload};
|
use crate::ctx::api::v1::gitea::{HmacSha256, WebhookPayload};
|
||||||
use crate::db::ForgejoWebhook;
|
use crate::db::GiteaWebhook;
|
||||||
use crate::tests;
|
use crate::tests;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_api_forgejo_webhook() {
|
async fn test_api_gitea_webhook() {
|
||||||
const NAME: &str = "apiforgejowebhookuser";
|
const NAME: &str = "apigiteawebhookuser";
|
||||||
const PASSWORD: &str = "longpasswordasdfa2";
|
const PASSWORD: &str = "longpasswordasdfa2";
|
||||||
const EMAIL: &str = "apiforgejowebhookuser@a.com";
|
const EMAIL: &str = "apigiteawebhookuser@a.com";
|
||||||
|
|
||||||
let (_dir, ctx) = tests::get_ctx().await;
|
let (_dir, ctx) = tests::get_ctx().await;
|
||||||
let _ = ctx.delete_user(NAME, PASSWORD).await;
|
let _ = ctx.delete_user(NAME, PASSWORD).await;
|
||||||
|
@ -160,37 +160,37 @@ mod tests {
|
||||||
let app = get_app!(ctx).await;
|
let app = get_app!(ctx).await;
|
||||||
|
|
||||||
let payload = AddWebhook {
|
let payload = AddWebhook {
|
||||||
forgejo_url: Url::parse("https://git.batnsense.net").unwrap(),
|
gitea_url: Url::parse("https://git.batnsense.net").unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let add_webhook_resp = test::call_service(
|
let add_webhook_resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
post_request!(&payload, V1_API_ROUTES.forgejo.add_webhook)
|
post_request!(&payload, V1_API_ROUTES.gitea.add_webhook)
|
||||||
.cookie(cookies.clone())
|
.cookie(cookies.clone())
|
||||||
.to_request(),
|
.to_request(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
check_status!(add_webhook_resp, StatusCode::OK);
|
check_status!(add_webhook_resp, StatusCode::OK);
|
||||||
let response: ForgejoWebhook = actix_web::test::read_body_json(add_webhook_resp).await;
|
let response: GiteaWebhook = actix_web::test::read_body_json(add_webhook_resp).await;
|
||||||
assert_eq!(response.forgejo_url, payload.forgejo_url);
|
assert_eq!(response.gitea_url, payload.gitea_url);
|
||||||
|
|
||||||
let view_webhook_resp = get_request!(
|
let view_webhook_resp = get_request!(
|
||||||
&app,
|
&app,
|
||||||
&V1_API_ROUTES.forgejo.get_view(&response.auth_token),
|
&V1_API_ROUTES.gitea.get_view(&response.auth_token),
|
||||||
cookies.clone()
|
cookies.clone()
|
||||||
);
|
);
|
||||||
check_status!(view_webhook_resp, StatusCode::OK);
|
check_status!(view_webhook_resp, StatusCode::OK);
|
||||||
let hook: ForgejoWebhook = actix_web::test::read_body_json(view_webhook_resp).await;
|
let hook: GiteaWebhook = actix_web::test::read_body_json(view_webhook_resp).await;
|
||||||
assert_eq!(hook, response);
|
assert_eq!(hook, response);
|
||||||
|
|
||||||
let list_all_webhooks_resp =
|
let list_all_webhooks_resp =
|
||||||
get_request!(&app, V1_API_ROUTES.forgejo.list_webhooks, cookies.clone());
|
get_request!(&app, &V1_API_ROUTES.gitea.list_webhooks, cookies.clone());
|
||||||
check_status!(list_all_webhooks_resp, StatusCode::OK);
|
check_status!(list_all_webhooks_resp, StatusCode::OK);
|
||||||
let hooks: Vec<ForgejoWebhook> =
|
let hooks: Vec<GiteaWebhook> =
|
||||||
actix_web::test::read_body_json(list_all_webhooks_resp).await;
|
actix_web::test::read_body_json(list_all_webhooks_resp).await;
|
||||||
assert_eq!(vec![hook.clone()], hooks);
|
assert_eq!(vec![hook.clone()], hooks);
|
||||||
|
|
||||||
let webhook_url = format!("{}?auth={}", V1_API_ROUTES.forgejo.webhook, hook.auth_token);
|
let webhook_url = format!("{}?auth={}", V1_API_ROUTES.gitea.webhook, hook.auth_token);
|
||||||
|
|
||||||
// test webhook
|
// test webhook
|
||||||
let mut webhook_payload = WebhookPayload::default();
|
let mut webhook_payload = WebhookPayload::default();
|
||||||
|
@ -199,9 +199,9 @@ mod tests {
|
||||||
|
|
||||||
let body = serde_json::to_string(&webhook_payload).unwrap();
|
let body = serde_json::to_string(&webhook_payload).unwrap();
|
||||||
let body = body.as_bytes();
|
let body = body.as_bytes();
|
||||||
let mut mac = HmacSha256::new_from_slice(hook.forgejo_webhook_secret.as_bytes())
|
let mut mac = HmacSha256::new_from_slice(hook.gitea_webhook_secret.as_bytes())
|
||||||
.expect("HMAC can take key of any size");
|
.expect("HMAC can take key of any size");
|
||||||
mac.update(body);
|
mac.update(&body);
|
||||||
let res = mac.finalize();
|
let res = mac.finalize();
|
||||||
let sig = res.into_bytes();
|
let sig = res.into_bytes();
|
||||||
let sig = hex::encode(&sig[..]);
|
let sig = hex::encode(&sig[..]);
|
||||||
|
@ -221,13 +221,13 @@ mod tests {
|
||||||
// no webhook
|
// no webhook
|
||||||
let fake_webhook_url = format!(
|
let fake_webhook_url = format!(
|
||||||
"{}?auth={}",
|
"{}?auth={}",
|
||||||
V1_API_ROUTES.forgejo.webhook, hook.forgejo_webhook_secret
|
V1_API_ROUTES.gitea.webhook, hook.gitea_webhook_secret
|
||||||
);
|
);
|
||||||
let body = serde_json::to_string(&webhook_payload).unwrap();
|
let body = serde_json::to_string(&webhook_payload).unwrap();
|
||||||
let body = body.as_bytes();
|
let body = body.as_bytes();
|
||||||
let mut mac =
|
let mut mac =
|
||||||
HmacSha256::new_from_slice(b"nosecret").expect("HMAC can take key of any size");
|
HmacSha256::new_from_slice(b"nosecret").expect("HMAC can take key of any size");
|
||||||
mac.update(body);
|
mac.update(&body);
|
||||||
let res = mac.finalize();
|
let res = mac.finalize();
|
||||||
let fake_sig = res.into_bytes();
|
let fake_sig = res.into_bytes();
|
||||||
let fake_sig = hex::encode(&fake_sig[..]);
|
let fake_sig = hex::encode(&fake_sig[..]);
|
||||||
|
@ -255,9 +255,9 @@ mod tests {
|
||||||
|
|
||||||
let body = serde_json::to_string(&webhook_payload).unwrap();
|
let body = serde_json::to_string(&webhook_payload).unwrap();
|
||||||
let body = body.as_bytes();
|
let body = body.as_bytes();
|
||||||
let mut mac = HmacSha256::new_from_slice(hook.forgejo_webhook_secret.as_bytes())
|
let mut mac = HmacSha256::new_from_slice(hook.gitea_webhook_secret.as_bytes())
|
||||||
.expect("HMAC can take key of any size");
|
.expect("HMAC can take key of any size");
|
||||||
mac.update(body);
|
mac.update(&body);
|
||||||
let res = mac.finalize();
|
let res = mac.finalize();
|
||||||
let sig = res.into_bytes();
|
let sig = res.into_bytes();
|
||||||
let sig = hex::encode(&sig[..]);
|
let sig = hex::encode(&sig[..]);
|
|
@ -20,7 +20,7 @@ use serde::Deserialize;
|
||||||
|
|
||||||
pub mod account;
|
pub mod account;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod forgejo;
|
pub mod gitea;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
pub mod pages;
|
pub mod pages;
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
|
@ -31,7 +31,7 @@ pub fn services(cfg: &mut ServiceConfig) {
|
||||||
auth::services(cfg);
|
auth::services(cfg);
|
||||||
account::services(cfg);
|
account::services(cfg);
|
||||||
meta::services(cfg);
|
meta::services(cfg);
|
||||||
forgejo::services(cfg);
|
gitea::services(cfg);
|
||||||
pages::services(cfg);
|
pages::services(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use actix_auth_middleware::GetLoginRoute;
|
||||||
|
|
||||||
use crate::serve::routes::Serve;
|
use crate::serve::routes::Serve;
|
||||||
|
|
||||||
use super::forgejo::routes::Forgejo;
|
use super::gitea::routes::Gitea;
|
||||||
use super::meta::routes::Meta;
|
use super::meta::routes::Meta;
|
||||||
use super::pages::routes::Deploy;
|
use super::pages::routes::Deploy;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ pub struct Routes {
|
||||||
pub account: Account,
|
pub account: Account,
|
||||||
/// Meta routes
|
/// Meta routes
|
||||||
pub meta: Meta,
|
pub meta: Meta,
|
||||||
pub forgejo: Forgejo,
|
pub gitea: Gitea,
|
||||||
pub deploy: Deploy,
|
pub deploy: Deploy,
|
||||||
pub serve: Serve,
|
pub serve: Serve,
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ impl Routes {
|
||||||
auth: Auth::new(),
|
auth: Auth::new(),
|
||||||
account: Account::new(),
|
account: Account::new(),
|
||||||
meta: Meta::new(),
|
meta: Meta::new(),
|
||||||
forgejo: Forgejo::new(),
|
gitea: Gitea::new(),
|
||||||
deploy: Deploy::new(),
|
deploy: Deploy::new(),
|
||||||
serve: Serve::new(),
|
serve: Serve::new(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl Ctx {
|
||||||
let sig = hex::decode(sig).unwrap();
|
let sig = hex::decode(sig).unwrap();
|
||||||
let event_type = headers.get("X-Gitea-Event").unwrap();
|
let event_type = headers.get("X-Gitea-Event").unwrap();
|
||||||
|
|
||||||
let payload: WebhookPayload = serde_json::from_slice(body).unwrap();
|
let payload: WebhookPayload = serde_json::from_slice(&body).unwrap();
|
||||||
|
|
||||||
let hook = self.db.get_webhook(auth_token).await?;
|
let hook = self.db.get_webhook(auth_token).await?;
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ impl Ctx {
|
||||||
&payload.repository.clone_url,
|
&payload.repository.clone_url,
|
||||||
] {
|
] {
|
||||||
if self.db.site_with_repository_exists(url).await? {
|
if self.db.site_with_repository_exists(url).await? {
|
||||||
let mut mac = HmacSha256::new_from_slice(hook.forgejo_webhook_secret.as_bytes())?;
|
let mut mac = HmacSha256::new_from_slice(hook.gitea_webhook_secret.as_bytes())?;
|
||||||
mac.update(body);
|
mac.update(&body);
|
||||||
mac.verify_slice(&sig[..])?;
|
mac.verify_slice(&sig[..])?;
|
||||||
|
|
||||||
let site = self.db.get_site_from_repo_url(url).await?;
|
let site = self.db.get_site_from_repo_url(url).await?;
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
pub mod account;
|
pub mod account;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod forgejo;
|
pub mod gitea;
|
||||||
pub mod pages;
|
pub mod pages;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
84
src/db.rs
84
src/db.rs
|
@ -691,20 +691,16 @@ impl Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// register a new webhook
|
/// register a new webhook
|
||||||
pub async fn new_webhook(
|
pub async fn new_webhook(&self, gitea_url: Url, owner: &str) -> ServiceResult<GiteaWebhook> {
|
||||||
&self,
|
let hook = GiteaWebhook::new(gitea_url);
|
||||||
forgejo_url: Url,
|
|
||||||
owner: &str,
|
|
||||||
) -> ServiceResult<ForgejoWebhook> {
|
|
||||||
let hook = ForgejoWebhook::new(forgejo_url);
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO librepages_forgejo_webhooks
|
"INSERT INTO librepages_gitea_webhooks
|
||||||
(forgejo_url , auth_token, forgejo_webhook_secret, owned_by) VALUES ($1, $2, $3,
|
(gitea_url , auth_token, gitea_webhook_secret, owned_by) VALUES ($1, $2, $3,
|
||||||
(SELECT ID FROM librepages_users WHERE name = $4)
|
(SELECT ID FROM librepages_users WHERE name = $4)
|
||||||
)",
|
)",
|
||||||
hook.forgejo_url.as_str(),
|
hook.gitea_url.as_str(),
|
||||||
&hook.auth_token,
|
&hook.auth_token,
|
||||||
&hook.forgejo_webhook_secret,
|
&hook.gitea_webhook_secret,
|
||||||
owner,
|
owner,
|
||||||
)
|
)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
|
@ -716,13 +712,13 @@ impl Database {
|
||||||
pub async fn list_all_webhooks_with_owner(
|
pub async fn list_all_webhooks_with_owner(
|
||||||
&self,
|
&self,
|
||||||
owner: &str,
|
owner: &str,
|
||||||
) -> ServiceResult<Vec<ForgejoWebhook>> {
|
) -> ServiceResult<Vec<GiteaWebhook>> {
|
||||||
let mut db_hooks = sqlx::query_as!(
|
let mut db_hooks = sqlx::query_as!(
|
||||||
InnerForgejoWebhook,
|
InnerGiteaWebhook,
|
||||||
"SELECT
|
"SELECT
|
||||||
forgejo_url, auth_token, forgejo_webhook_secret
|
gitea_url, auth_token, gitea_webhook_secret
|
||||||
FROM
|
FROM
|
||||||
librepages_forgejo_webhooks
|
librepages_gitea_webhooks
|
||||||
WHERE
|
WHERE
|
||||||
owned_by = (SELECT ID FROM librepages_users WHERE name = $1);
|
owned_by = (SELECT ID FROM librepages_users WHERE name = $1);
|
||||||
",
|
",
|
||||||
|
@ -745,13 +741,13 @@ impl Database {
|
||||||
&self,
|
&self,
|
||||||
auth_token: &str,
|
auth_token: &str,
|
||||||
owner: &str,
|
owner: &str,
|
||||||
) -> ServiceResult<ForgejoWebhook> {
|
) -> ServiceResult<GiteaWebhook> {
|
||||||
let h = sqlx::query_as!(
|
let h = sqlx::query_as!(
|
||||||
InnerForgejoWebhook,
|
InnerGiteaWebhook,
|
||||||
"SELECT
|
"SELECT
|
||||||
forgejo_url, auth_token, forgejo_webhook_secret
|
gitea_url, auth_token, gitea_webhook_secret
|
||||||
FROM
|
FROM
|
||||||
librepages_forgejo_webhooks
|
librepages_gitea_webhooks
|
||||||
WHERE
|
WHERE
|
||||||
auth_token = $1
|
auth_token = $1
|
||||||
AND
|
AND
|
||||||
|
@ -767,11 +763,11 @@ impl Database {
|
||||||
h.to_webhook()
|
h.to_webhook()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_webhook(&self, auth_token: &str) -> ServiceResult<ForgejoWebhook> {
|
pub async fn get_webhook(&self, auth_token: &str) -> ServiceResult<GiteaWebhook> {
|
||||||
let h = sqlx::query_as!(
|
let h = sqlx::query_as!(
|
||||||
InnerForgejoWebhook,
|
InnerGiteaWebhook,
|
||||||
"SELECT forgejo_url, auth_token, forgejo_webhook_secret
|
"SELECT gitea_url, auth_token, gitea_webhook_secret
|
||||||
FROM librepages_forgejo_webhooks
|
FROM librepages_gitea_webhooks
|
||||||
WHERE auth_token = $1
|
WHERE auth_token = $1
|
||||||
",
|
",
|
||||||
auth_token,
|
auth_token,
|
||||||
|
@ -799,11 +795,11 @@ impl Database {
|
||||||
|
|
||||||
for site in sites {
|
for site in sites {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO librepages_forgejo_webhook_site_mapping
|
"INSERT INTO librepages_gitea_webhook_site_mapping
|
||||||
(site_id, forgejo_webhook_id) VALUES (
|
(site_id, gitea_webhook_id) VALUES (
|
||||||
(SELECT ID FROM librepages_sites WHERE repo_url = $1 AND ID = $2),
|
(SELECT ID FROM librepages_sites WHERE repo_url = $1 AND ID = $2),
|
||||||
(SELECT ID FROM librepages_forgejo_webhooks WHERE auth_token = $3)
|
(SELECT ID FROM librepages_gitea_webhooks WHERE auth_token = $3)
|
||||||
) ON CONFLICT (site_id, forgejo_webhook_id) DO NOTHING;",
|
) ON CONFLICT (site_id, gitea_webhook_id) DO NOTHING;",
|
||||||
repo_url.as_str(),
|
repo_url.as_str(),
|
||||||
site.id,
|
site.id,
|
||||||
auth_token
|
auth_token
|
||||||
|
@ -927,34 +923,34 @@ pub struct LibrePagesEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct ForgejoWebhook {
|
pub struct GiteaWebhook {
|
||||||
pub forgejo_url: Url,
|
pub gitea_url: Url,
|
||||||
pub forgejo_webhook_secret: String,
|
pub gitea_webhook_secret: String,
|
||||||
pub auth_token: String,
|
pub auth_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ForgejoWebhook {
|
impl GiteaWebhook {
|
||||||
fn new(forgejo_url: Url) -> Self {
|
fn new(gitea_url: Url) -> Self {
|
||||||
Self {
|
Self {
|
||||||
forgejo_url,
|
gitea_url,
|
||||||
forgejo_webhook_secret: utils::get_random(40),
|
gitea_webhook_secret: utils::get_random(40),
|
||||||
auth_token: utils::get_random(40),
|
auth_token: utils::get_random(40),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InnerForgejoWebhook {
|
struct InnerGiteaWebhook {
|
||||||
forgejo_url: String,
|
gitea_url: String,
|
||||||
auth_token: String,
|
auth_token: String,
|
||||||
forgejo_webhook_secret: String,
|
gitea_webhook_secret: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InnerForgejoWebhook {
|
impl InnerGiteaWebhook {
|
||||||
fn to_webhook(self) -> ServiceResult<ForgejoWebhook> {
|
fn to_webhook(self) -> ServiceResult<GiteaWebhook> {
|
||||||
Ok(ForgejoWebhook {
|
Ok(GiteaWebhook {
|
||||||
forgejo_url: Url::parse(&self.forgejo_url)?,
|
gitea_url: Url::parse(&self.gitea_url)?,
|
||||||
auth_token: self.auth_token,
|
auth_token: self.auth_token,
|
||||||
forgejo_webhook_secret: self.forgejo_webhook_secret,
|
gitea_webhook_secret: self.gitea_webhook_secret,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1265,8 +1261,8 @@ mod tests {
|
||||||
assert_eq!(latest_update_event_id_from_db.id, latest_update_event_id);
|
assert_eq!(latest_update_event_id_from_db.id, latest_update_event_id);
|
||||||
|
|
||||||
// add webhook
|
// add webhook
|
||||||
let forgejo_url = Url::parse("https://example.org").unwrap();
|
let gitea_url = Url::parse("https://example.org").unwrap();
|
||||||
let hook = db.new_webhook(forgejo_url, NAME).await.unwrap();
|
let hook = db.new_webhook(gitea_url, NAME).await.unwrap();
|
||||||
assert_eq!(hook, db.get_webhook(&hook.auth_token).await.unwrap());
|
assert_eq!(hook, db.get_webhook(&hook.auth_token).await.unwrap());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec![hook.clone()],
|
vec![hook.clone()],
|
||||||
|
@ -1279,7 +1275,7 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
db.get_webhook(&hook.forgejo_webhook_secret).await.err(),
|
db.get_webhook(&hook.gitea_webhook_secret).await.err(),
|
||||||
Some(ServiceError::WebhookNotFound)
|
Some(ServiceError::WebhookNotFound)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,15 @@ use tera::Context;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use super::get_auth_middleware;
|
use super::get_auth_middleware;
|
||||||
use crate::api::v1::forgejo::AddWebhook;
|
use crate::api::v1::gitea::AddWebhook;
|
||||||
use crate::pages::errors::*;
|
use crate::pages::errors::*;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::AppCtx;
|
use crate::AppCtx;
|
||||||
|
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
|
|
||||||
pub const DASH_FORGEJO_WEBHOOK_ADD: TemplateFile =
|
pub const DASH_GITEA_WEBHOOK_ADD: TemplateFile =
|
||||||
TemplateFile::new("dash_forgejo_webhook_add", "pages/dash/forgejo/add.html");
|
TemplateFile::new("dash_gitea_webhook_add", "pages/dash/gitea/add.html");
|
||||||
|
|
||||||
pub struct Add {
|
pub struct Add {
|
||||||
ctx: RefCell<Context>,
|
ctx: RefCell<Context>,
|
||||||
|
@ -51,31 +51,31 @@ impl Add {
|
||||||
|
|
||||||
pub fn render(&self) -> String {
|
pub fn render(&self) -> String {
|
||||||
TEMPLATES
|
TEMPLATES
|
||||||
.render(DASH_FORGEJO_WEBHOOK_ADD.name, &self.ctx.borrow())
|
.render(DASH_GITEA_WEBHOOK_ADD.name, &self.ctx.borrow())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "PAGES.dash.forgejo_webhook.add",
|
path = "PAGES.dash.gitea_webhook.add",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "Dashboard add forgejo webhook webpage", skip(ctx))]
|
#[tracing::instrument(name = "Dashboard add gitea webhook webpage", skip(ctx))]
|
||||||
pub async fn get_add_forgejo_webhook(ctx: AppCtx) -> PageResult<impl Responder, Add> {
|
pub async fn get_add_gitea_webhook(ctx: AppCtx) -> PageResult<impl Responder, Add> {
|
||||||
let add = Add::new(&ctx.settings).render();
|
let add = Add::new(&ctx.settings).render();
|
||||||
let html = ContentType::html();
|
let html = ContentType::html();
|
||||||
Ok(HttpResponse::Ok().content_type(html).body(add))
|
Ok(HttpResponse::Ok().content_type(html).body(add))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::post(
|
#[actix_web_codegen_const_routes::post(
|
||||||
path = "PAGES.dash.forgejo_webhook.add",
|
path = "PAGES.dash.gitea_webhook.add",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
name = "Post Dashboard add Forgejo webhook webpage",
|
name = "Post Dashboard add Gitea webhook webpage",
|
||||||
skip(ctx, id, payload)
|
skip(ctx, id, payload)
|
||||||
)]
|
)]
|
||||||
pub async fn post_add_forgejo_webhook(
|
pub async fn post_add_gitea_webhook(
|
||||||
ctx: AppCtx,
|
ctx: AppCtx,
|
||||||
id: Identity,
|
id: Identity,
|
||||||
payload: web::Form<AddWebhook>,
|
payload: web::Form<AddWebhook>,
|
||||||
|
@ -84,26 +84,26 @@ pub async fn post_add_forgejo_webhook(
|
||||||
let payload = payload.into_inner();
|
let payload = payload.into_inner();
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"Adding webhook for Forgejo instance: {}",
|
"Adding webhook for Gitea instance: {}",
|
||||||
payload.forgejo_url.as_str()
|
payload.gitea_url.as_str()
|
||||||
);
|
);
|
||||||
let hook = ctx
|
let hook = ctx
|
||||||
.db
|
.db
|
||||||
.new_webhook(payload.forgejo_url, &owner)
|
.new_webhook(payload.gitea_url, &owner)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| PageError::new(Add::new(&ctx.settings), e))?;
|
.map_err(|e| PageError::new(Add::new(&ctx.settings), e))?;
|
||||||
|
|
||||||
Ok(HttpResponse::Found()
|
Ok(HttpResponse::Found()
|
||||||
.append_header((
|
.append_header((
|
||||||
http::header::LOCATION,
|
http::header::LOCATION,
|
||||||
PAGES.dash.forgejo_webhook.get_view(&hook.auth_token),
|
PAGES.dash.gitea_webhook.get_view(&hook.auth_token),
|
||||||
))
|
))
|
||||||
.finish())
|
.finish())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
cfg.service(get_add_forgejo_webhook);
|
cfg.service(get_add_gitea_webhook);
|
||||||
cfg.service(post_add_forgejo_webhook);
|
cfg.service(post_add_gitea_webhook);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -112,7 +112,7 @@ mod tests {
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::api::v1::forgejo::AddWebhook;
|
use crate::api::v1::gitea::AddWebhook;
|
||||||
use crate::ctx::ArcCtx;
|
use crate::ctx::ArcCtx;
|
||||||
use crate::tests;
|
use crate::tests;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
@ -120,14 +120,14 @@ mod tests {
|
||||||
use super::PAGES;
|
use super::PAGES;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn postgres_dashboadr_add_forgejo_webhook_works() {
|
async fn postgres_dashboadr_add_gitea_webhook_works() {
|
||||||
let (_, ctx) = tests::get_ctx().await;
|
let (_, ctx) = tests::get_ctx().await;
|
||||||
dashboadr_add_forgejo_webhook_works(ctx.clone()).await;
|
dashboadr_add_gitea_webhook_works(ctx.clone()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dashboadr_add_forgejo_webhook_works(ctx: ArcCtx) {
|
async fn dashboadr_add_gitea_webhook_works(ctx: ArcCtx) {
|
||||||
const NAME: &str = "testdashwebhookforgejoadduser";
|
const NAME: &str = "testdashwebhookgiteaadduser";
|
||||||
const EMAIL: &str = "testdashwebhookforgejoadduser@foo.com";
|
const EMAIL: &str = "testdashwebhookgiteaadduser@foo.com";
|
||||||
const PASSWORD: &str = "longpassword";
|
const PASSWORD: &str = "longpassword";
|
||||||
|
|
||||||
let _ = ctx.delete_user(NAME, PASSWORD).await;
|
let _ = ctx.delete_user(NAME, PASSWORD).await;
|
||||||
|
@ -135,18 +135,18 @@ mod tests {
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(ctx.clone()).await;
|
let app = get_app!(ctx.clone()).await;
|
||||||
|
|
||||||
let resp = get_request!(&app, PAGES.dash.forgejo_webhook.add, cookies.clone());
|
let resp = get_request!(&app, PAGES.dash.gitea_webhook.add, cookies.clone());
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
||||||
assert!(res.contains("Add Forgejo Webhook"));
|
assert!(res.contains("Add Gitea Webhook"));
|
||||||
|
|
||||||
let payload = AddWebhook {
|
let payload = AddWebhook {
|
||||||
forgejo_url: Url::parse("https://git.batsense.net").unwrap(),
|
gitea_url: Url::parse("https://git.batsense.net").unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let add_webhook = test::call_service(
|
let add_webhook = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
post_request!(&payload, PAGES.dash.forgejo_webhook.add, FORM)
|
post_request!(&payload, PAGES.dash.gitea_webhook.add, FORM)
|
||||||
.cookie(cookies.clone())
|
.cookie(cookies.clone())
|
||||||
.to_request(),
|
.to_request(),
|
||||||
)
|
)
|
||||||
|
@ -160,17 +160,17 @@ mod tests {
|
||||||
// let event = event.pop().unwrap();
|
// let event = event.pop().unwrap();
|
||||||
|
|
||||||
let headers = add_webhook.headers();
|
let headers = add_webhook.headers();
|
||||||
let view_webhook_url = PAGES.dash.forgejo_webhook.get_view(&hook.auth_token);
|
let view_webhook_url = PAGES.dash.gitea_webhook.get_view(&hook.auth_token);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
headers.get(actix_web::http::header::LOCATION).unwrap(),
|
headers.get(actix_web::http::header::LOCATION).unwrap(),
|
||||||
&view_webhook_url
|
&view_webhook_url
|
||||||
);
|
);
|
||||||
|
|
||||||
// list webhooks
|
// list webhooks
|
||||||
let resp = get_request!(&app, PAGES.dash.forgejo_webhook.list, cookies.clone());
|
let resp = get_request!(&app, PAGES.dash.gitea_webhook.list, cookies.clone());
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
||||||
assert!(res.contains(hook.forgejo_url.as_str()));
|
assert!(res.contains(&hook.gitea_url.as_str()));
|
||||||
|
|
||||||
// view webhook
|
// view webhook
|
||||||
let resp = get_request!(&app, &view_webhook_url, cookies.clone());
|
let resp = get_request!(&app, &view_webhook_url, cookies.clone());
|
||||||
|
@ -179,15 +179,15 @@ mod tests {
|
||||||
assert!(res.contains("****"));
|
assert!(res.contains("****"));
|
||||||
assert!(res.contains(
|
assert!(res.contains(
|
||||||
&crate::V1_API_ROUTES
|
&crate::V1_API_ROUTES
|
||||||
.forgejo
|
.gitea
|
||||||
.get_webhook_url(&ctx, &hook.auth_token)
|
.get_webhook_url(&ctx, &hook.auth_token)
|
||||||
));
|
));
|
||||||
|
|
||||||
let show_forgejo_webhook_secret =
|
let show_gitea_webhook_secret =
|
||||||
format!("{view_webhook_url}?show_forgejo_webhook_secret=true");
|
format!("{view_webhook_url}?show_gitea_webhook_secret=true");
|
||||||
let resp = get_request!(&app, &show_forgejo_webhook_secret, cookies.clone());
|
let resp = get_request!(&app, &show_gitea_webhook_secret, cookies.clone());
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
let res = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
|
||||||
assert!(res.contains(&hook.forgejo_webhook_secret));
|
assert!(res.contains(&hook.gitea_webhook_secret));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@ use std::cell::RefCell;
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
|
||||||
use super::get_auth_middleware;
|
use super::get_auth_middleware;
|
||||||
|
@ -29,8 +29,8 @@ use crate::AppCtx;
|
||||||
|
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
|
|
||||||
pub const DASH_FORGEJO_WEBHOOK_LIST: TemplateFile =
|
pub const DASH_GITEA_WEBHOOK_LIST: TemplateFile =
|
||||||
TemplateFile::new("dash_forgejo_webhook_list", "pages/dash/forgejo/list.html");
|
TemplateFile::new("dash_gitea_webhook_list", "pages/dash/gitea/list.html");
|
||||||
|
|
||||||
pub struct List {
|
pub struct List {
|
||||||
ctx: RefCell<Context>,
|
ctx: RefCell<Context>,
|
||||||
|
@ -44,7 +44,7 @@ impl CtxError for List {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl List {
|
impl List {
|
||||||
pub fn new(settings: &Settings, hooks: Option<&[TemplateForgejoWebhook]>) -> Self {
|
pub fn new(settings: &Settings, hooks: Option<&[TemplateGiteaWebhook]>) -> Self {
|
||||||
let ctx = RefCell::new(context(settings));
|
let ctx = RefCell::new(context(settings));
|
||||||
if let Some(hooks) = hooks {
|
if let Some(hooks) = hooks {
|
||||||
ctx.borrow_mut().insert(PAYLOAD_KEY, hooks);
|
ctx.borrow_mut().insert(PAYLOAD_KEY, hooks);
|
||||||
|
@ -54,31 +54,28 @@ impl List {
|
||||||
|
|
||||||
pub fn render(&self) -> String {
|
pub fn render(&self) -> String {
|
||||||
TEMPLATES
|
TEMPLATES
|
||||||
.render(DASH_FORGEJO_WEBHOOK_LIST.name, &self.ctx.borrow())
|
.render(DASH_GITEA_WEBHOOK_LIST.name, &self.ctx.borrow())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_webhook_data(
|
async fn get_webhook_data(ctx: &AppCtx, id: &Identity) -> ServiceResult<Vec<TemplateGiteaWebhook>> {
|
||||||
ctx: &AppCtx,
|
|
||||||
id: &Identity,
|
|
||||||
) -> ServiceResult<Vec<TemplateForgejoWebhook>> {
|
|
||||||
let db_hooks = ctx
|
let db_hooks = ctx
|
||||||
.db
|
.db
|
||||||
.list_all_webhooks_with_owner(&id.identity().unwrap())
|
.list_all_webhooks_with_owner(&id.identity().unwrap())
|
||||||
.await?;
|
.await?;
|
||||||
let mut hooks = Vec::with_capacity(db_hooks.len());
|
let mut hooks = Vec::with_capacity(db_hooks.len());
|
||||||
for hook in db_hooks {
|
for hook in db_hooks {
|
||||||
hooks.push(TemplateForgejoWebhook::new(ctx, hook));
|
hooks.push(TemplateGiteaWebhook::new(ctx, hook));
|
||||||
}
|
}
|
||||||
Ok(hooks)
|
Ok(hooks)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "PAGES.dash.forgejo_webhook.list",
|
path = "PAGES.dash.gitea_webhook.list",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "List all Forgejo webhooks", skip(ctx, id))]
|
#[tracing::instrument(name = "List all Gitea webhooks", skip(ctx, id))]
|
||||||
pub async fn list_hooks(ctx: AppCtx, id: Identity) -> PageResult<impl Responder, List> {
|
pub async fn list_hooks(ctx: AppCtx, id: Identity) -> PageResult<impl Responder, List> {
|
||||||
let sites = get_webhook_data(&ctx, &id)
|
let sites = get_webhook_data(&ctx, &id)
|
||||||
.await
|
.await
|
|
@ -22,23 +22,23 @@ pub use super::home::TemplateSite;
|
||||||
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
||||||
|
|
||||||
use crate::ctx::Ctx;
|
use crate::ctx::Ctx;
|
||||||
use crate::db::ForgejoWebhook;
|
use crate::db::GiteaWebhook;
|
||||||
|
|
||||||
pub mod add;
|
pub mod add;
|
||||||
pub mod list;
|
pub mod list;
|
||||||
pub mod view;
|
pub mod view;
|
||||||
|
|
||||||
pub fn register_templates(t: &mut tera::Tera) {
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
add::DASH_FORGEJO_WEBHOOK_ADD
|
add::DASH_GITEA_WEBHOOK_ADD
|
||||||
.register(t)
|
.register(t)
|
||||||
.expect(add::DASH_FORGEJO_WEBHOOK_ADD.name);
|
.expect(add::DASH_GITEA_WEBHOOK_ADD.name);
|
||||||
list::DASH_FORGEJO_WEBHOOK_LIST
|
list::DASH_GITEA_WEBHOOK_LIST
|
||||||
.register(t)
|
.register(t)
|
||||||
.expect(list::DASH_FORGEJO_WEBHOOK_LIST.name);
|
.expect(list::DASH_GITEA_WEBHOOK_LIST.name);
|
||||||
|
|
||||||
view::DASH_FORGEJO_WEBHOOK_VIEW
|
view::DASH_GITEA_WEBHOOK_VIEW
|
||||||
.register(t)
|
.register(t)
|
||||||
.expect(view::DASH_FORGEJO_WEBHOOK_VIEW.name);
|
.expect(view::DASH_GITEA_WEBHOOK_VIEW.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
@ -48,17 +48,17 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||||
pub struct TemplateForgejoWebhook {
|
pub struct TemplateGiteaWebhook {
|
||||||
pub webhook: ForgejoWebhook,
|
pub webhook: GiteaWebhook,
|
||||||
pub view: String,
|
pub view: String,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TemplateForgejoWebhook {
|
impl TemplateGiteaWebhook {
|
||||||
pub fn new(ctx: &Ctx, hook: ForgejoWebhook) -> Self {
|
pub fn new(ctx: &Ctx, hook: GiteaWebhook) -> Self {
|
||||||
let view = PAGES.dash.forgejo_webhook.get_view(&hook.auth_token);
|
let view = PAGES.dash.gitea_webhook.get_view(&hook.auth_token);
|
||||||
let url = crate::V1_API_ROUTES
|
let url = crate::V1_API_ROUTES
|
||||||
.forgejo
|
.gitea
|
||||||
.get_webhook_url(ctx, &hook.auth_token);
|
.get_webhook_url(ctx, &hook.auth_token);
|
||||||
Self {
|
Self {
|
||||||
webhook: hook,
|
webhook: hook,
|
|
@ -20,19 +20,22 @@ use actix_identity::Identity;
|
||||||
use actix_web::http::header::ContentType;
|
use actix_web::http::header::ContentType;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::get_auth_middleware;
|
use super::get_auth_middleware;
|
||||||
|
|
||||||
|
use crate::db::Site;
|
||||||
|
use crate::pages::dash::TemplateSiteEvent;
|
||||||
use crate::pages::errors::*;
|
use crate::pages::errors::*;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::AppCtx;
|
use crate::AppCtx;
|
||||||
|
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
|
|
||||||
pub const DASH_FORGEJO_WEBHOOK_VIEW: TemplateFile =
|
pub const DASH_GITEA_WEBHOOK_VIEW: TemplateFile =
|
||||||
TemplateFile::new("dash_forgejo_webhook_view", "pages/dash/forgejo/view.html");
|
TemplateFile::new("dash_gitea_webhook_view", "pages/dash/gitea/view.html");
|
||||||
|
|
||||||
const SHOW_FORGEJO_WEBHOOK_SECRET_KEY: &str = "show_forgejo_webhook_secret";
|
const SHOW_GITEA_WEBHOOK_SECRET_KEY: &str = "show_gitea_webhook_secret";
|
||||||
|
|
||||||
pub struct View {
|
pub struct View {
|
||||||
ctx: RefCell<Context>,
|
ctx: RefCell<Context>,
|
||||||
|
@ -46,7 +49,7 @@ impl CtxError for View {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl View {
|
impl View {
|
||||||
pub fn new(settings: &Settings, payload: Option<TemplateForgejoWebhook>) -> Self {
|
pub fn new(settings: &Settings, payload: Option<TemplateGiteaWebhook>) -> Self {
|
||||||
let ctx = RefCell::new(context(settings));
|
let ctx = RefCell::new(context(settings));
|
||||||
if let Some(payload) = payload {
|
if let Some(payload) = payload {
|
||||||
ctx.borrow_mut().insert(PAYLOAD_KEY, &payload);
|
ctx.borrow_mut().insert(PAYLOAD_KEY, &payload);
|
||||||
|
@ -55,29 +58,29 @@ impl View {
|
||||||
Self { ctx }
|
Self { ctx }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_forgejo_webhook_secret(&mut self) {
|
pub fn show_gitea_webhook_secret(&mut self) {
|
||||||
self.ctx
|
self.ctx
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.insert(SHOW_FORGEJO_WEBHOOK_SECRET_KEY, &true);
|
.insert(SHOW_GITEA_WEBHOOK_SECRET_KEY, &true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&self) -> String {
|
pub fn render(&self) -> String {
|
||||||
TEMPLATES
|
TEMPLATES
|
||||||
.render(DASH_FORGEJO_WEBHOOK_VIEW.name, &self.ctx.borrow())
|
.render(DASH_GITEA_WEBHOOK_VIEW.name, &self.ctx.borrow())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct ViewOptions {
|
pub struct ViewOptions {
|
||||||
show_forgejo_webhook_secret: Option<bool>,
|
show_gitea_webhook_secret: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web_codegen_const_routes::get(
|
#[actix_web_codegen_const_routes::get(
|
||||||
path = "PAGES.dash.forgejo_webhook.view",
|
path = "PAGES.dash.gitea_webhook.view",
|
||||||
wrap = "get_auth_middleware()"
|
wrap = "get_auth_middleware()"
|
||||||
)]
|
)]
|
||||||
#[tracing::instrument(name = "Dashboard Forgejo webhook webpage", skip(ctx, id))]
|
#[tracing::instrument(name = "Dashboard Gitea webhook webpage", skip(ctx, id))]
|
||||||
pub async fn get_view_site(
|
pub async fn get_view_site(
|
||||||
ctx: AppCtx,
|
ctx: AppCtx,
|
||||||
id: Identity,
|
id: Identity,
|
||||||
|
@ -93,10 +96,10 @@ pub async fn get_view_site(
|
||||||
.await
|
.await
|
||||||
.map_err(|e| PageError::new(View::new(&ctx.settings, None), e))?;
|
.map_err(|e| PageError::new(View::new(&ctx.settings, None), e))?;
|
||||||
|
|
||||||
let payload = TemplateForgejoWebhook::new(&ctx, hook);
|
let payload = TemplateGiteaWebhook::new(&ctx, hook);
|
||||||
let mut page = View::new(&ctx.settings, Some(payload));
|
let mut page = View::new(&ctx.settings, Some(payload));
|
||||||
if let Some(true) = query.show_forgejo_webhook_secret {
|
if let Some(true) = query.show_gitea_webhook_secret {
|
||||||
page.show_forgejo_webhook_secret();
|
page.show_gitea_webhook_secret();
|
||||||
}
|
}
|
||||||
let add = page.render();
|
let add = page.render();
|
||||||
let html = ContentType::html();
|
let html = ContentType::html();
|
|
@ -24,7 +24,7 @@ pub use super::{context, Footer, TemplateFile, PAGES, PAYLOAD_KEY, TEMPLATES};
|
||||||
use crate::db::Event;
|
use crate::db::Event;
|
||||||
use crate::db::LibrePagesEvent;
|
use crate::db::LibrePagesEvent;
|
||||||
|
|
||||||
pub mod forgejo;
|
pub mod gitea;
|
||||||
pub mod home;
|
pub mod home;
|
||||||
pub mod sites;
|
pub mod sites;
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ impl From<LibrePagesEvent> for TemplateSiteEvent {
|
||||||
pub fn register_templates(t: &mut tera::Tera) {
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
home::DASH_HOME.register(t).expect(home::DASH_HOME.name);
|
home::DASH_HOME.register(t).expect(home::DASH_HOME.name);
|
||||||
sites::register_templates(t);
|
sites::register_templates(t);
|
||||||
forgejo::register_templates(t);
|
gitea::register_templates(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
home::services(cfg);
|
home::services(cfg);
|
||||||
sites::services(cfg);
|
sites::services(cfg);
|
||||||
forgejo::services(cfg);
|
gitea::services(cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub struct Dash {
|
||||||
/// home route
|
/// home route
|
||||||
pub home: &'static str,
|
pub home: &'static str,
|
||||||
pub site: DashSite,
|
pub site: DashSite,
|
||||||
pub forgejo_webhook: ForgejoWebhook,
|
pub gitea_webhook: GiteaWebhook,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dash {
|
impl Dash {
|
||||||
|
@ -80,33 +80,33 @@ impl Dash {
|
||||||
pub const fn new() -> Dash {
|
pub const fn new() -> Dash {
|
||||||
let home = "/dash";
|
let home = "/dash";
|
||||||
let site = DashSite::new();
|
let site = DashSite::new();
|
||||||
let forgejo_webhook = ForgejoWebhook::new();
|
let gitea_webhook = GiteaWebhook::new();
|
||||||
Dash {
|
Dash {
|
||||||
home,
|
home,
|
||||||
site,
|
site,
|
||||||
forgejo_webhook,
|
gitea_webhook,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
/// Dashboard ForgejoWebhook routes
|
/// Dashboard GiteaWebhook routes
|
||||||
pub struct ForgejoWebhook {
|
pub struct GiteaWebhook {
|
||||||
/// add forgejo webhook route
|
/// add gitea webhook route
|
||||||
pub add: &'static str,
|
pub add: &'static str,
|
||||||
/// view forgejo webhook route
|
/// view gitea webhook route
|
||||||
pub view: &'static str,
|
pub view: &'static str,
|
||||||
/// list forgejo webhooks route
|
/// list gitea webhooks route
|
||||||
pub list: &'static str,
|
pub list: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ForgejoWebhook {
|
impl GiteaWebhook {
|
||||||
/// create new instance of ForgejoWebhook route
|
/// create new instance of GiteaWebhook route
|
||||||
pub const fn new() -> ForgejoWebhook {
|
pub const fn new() -> GiteaWebhook {
|
||||||
let add = "/dash/forgejo/webhook/add";
|
let add = "/dash/gitea/webhook/add";
|
||||||
let list = "/dash/forgejo/webhook/list";
|
let list = "/dash/gitea/webhook/list";
|
||||||
let view = "/dash/forgejo/webhook/view/{auth_token}";
|
let view = "/dash/gitea/webhook/view/{auth_token}";
|
||||||
ForgejoWebhook { add, view, list }
|
GiteaWebhook { add, view, list }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_view(&self, auth_token: &str) -> String {
|
pub fn get_view(&self, auth_token: &str) -> String {
|
||||||
|
|
14
src/tests.rs
14
src/tests.rs
|
@ -24,7 +24,6 @@ use actix_web::{
|
||||||
};
|
};
|
||||||
use mktemp::Temp;
|
use mktemp::Temp;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use crate::ctx::api::v1::auth::{Login, Register};
|
use crate::ctx::api::v1::auth::{Login, Register};
|
||||||
use crate::ctx::api::v1::pages::AddSite;
|
use crate::ctx::api::v1::pages::AddSite;
|
||||||
|
@ -41,15 +40,6 @@ pub async fn get_ctx() -> (Temp, Arc<Ctx>) {
|
||||||
// mktemp::Temp is returned because the temp directory created
|
// mktemp::Temp is returned because the temp directory created
|
||||||
// is removed once the variable goes out of scope
|
// is removed once the variable goes out of scope
|
||||||
let mut settings = Settings::new().unwrap();
|
let mut settings = Settings::new().unwrap();
|
||||||
let mut db_url = Url::parse(&settings.database.url).unwrap();
|
|
||||||
db_url.set_path(&crate::utils::get_random(8));
|
|
||||||
settings.database.url = db_url.to_string();
|
|
||||||
|
|
||||||
use sqlx::migrate::MigrateDatabase;
|
|
||||||
// sqlx::Postgres::create_database(&settings.database.url).await.unwrap();
|
|
||||||
sqlx::postgres::Postgres::create_database(&settings.database.url)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let tmp_dir = Temp::new_dir().unwrap();
|
let tmp_dir = Temp::new_dir().unwrap();
|
||||||
println!("[log] Test temp directory: {}", tmp_dir.to_str().unwrap());
|
println!("[log] Test temp directory: {}", tmp_dir.to_str().unwrap());
|
||||||
|
@ -58,10 +48,8 @@ pub async fn get_ctx() -> (Temp, Arc<Ctx>) {
|
||||||
settings.init();
|
settings.init();
|
||||||
println!("[log] Initialzing settings again with test config");
|
println!("[log] Initialzing settings again with test config");
|
||||||
settings.init();
|
settings.init();
|
||||||
let ctx = Ctx::new(settings).await;
|
|
||||||
ctx.db.migrate().await.unwrap();
|
|
||||||
|
|
||||||
(tmp_dir, ctx)
|
(tmp_dir, Ctx::new(settings).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code, clippy::upper_case_acronyms)]
|
#[allow(dead_code, clippy::upper_case_acronyms)]
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__link-container">
|
<div class="nav__link-container">
|
||||||
<a class="nav__link" rel="noreferrer" href="{{ page.dash.forgejo_webhook.list }}">Webhooks</a>
|
<a class="nav__link" rel="noreferrer" href="{{ page.dash.gitea_webhook.list }}">Webhooks</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav__link-container">
|
<div class="nav__link-container">
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
{% extends 'base' %}{% block title %} Add Forgejo Webhook{% endblock title %} {% block nav
|
{% extends 'base' %}{% block title %} Add Gitea Webhook{% endblock title %} {% block nav
|
||||||
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
||||||
|
|
||||||
<main class="sites__main">
|
<main class="sites__main">
|
||||||
<div class="add-site__container">
|
<div class="add-site__container">
|
||||||
<form class="auth-form" action="{{ page.dash.forgejo_webhook.add }}" method="POST">
|
<form class="auth-form" action="{{ page.dash.gitea_webhook.add }}" method="POST">
|
||||||
<label class="auth-form__label" for="forgejo_url">
|
<label class="auth-form__label" for="gitea_url">
|
||||||
Forgejo instance URL
|
Gitea instance URL
|
||||||
<input
|
<input
|
||||||
type="url"
|
type="url"
|
||||||
name="forgejo_url"
|
name="gitea_url"
|
||||||
id="forgejo_url"
|
id="gitea_url"
|
||||||
class="auth-form__input"
|
class="auth-form__input"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
|
@ -1,11 +1,11 @@
|
||||||
{% extends 'base' %}{% block title %} Forgejo Webhooks{% endblock title %} {% block nav
|
{% extends 'base' %}{% block title %} Gitea Webhooks{% endblock title %} {% block nav
|
||||||
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
||||||
|
|
||||||
<main class="sites__main">
|
<main class="sites__main">
|
||||||
<div class="sites__collection">
|
<div class="sites__collection">
|
||||||
<div class="sites__actions">
|
<div class="sites__actions">
|
||||||
<a class="sites__actions__new-site" href="{{ page.dash.forgejo_webhook.add }}">
|
<a class="sites__actions__new-site" href="{{ page.dash.gitea_webhook.add }}">
|
||||||
<button>Add New Forgejo Webhook</button>
|
<button>Add New Gitea Webhook</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% if payload|length > 0 %}
|
{% if payload|length > 0 %}
|
||||||
|
@ -14,18 +14,18 @@
|
||||||
<div class="site__info--head">
|
<div class="site__info--head">
|
||||||
<img
|
<img
|
||||||
class="site__container--preview"
|
class="site__container--preview"
|
||||||
src="{{ hook.webhook.forgejo_url }}/favicon.ico"
|
src="{{ hook.webhook.gitea_url }}/favicon.ico"
|
||||||
alt="Webhook icon"
|
alt="Webhook icon"
|
||||||
/>
|
/>
|
||||||
<div class="site__info--column">
|
<div class="site__info--column">
|
||||||
<p><b>{{ hook.webhook.forgejo_url }}</b></p>
|
<p><b>{{ hook.webhook.gitea_url }}</b></p>
|
||||||
<p>Forgejo instance {{ hook.webhook.forgejo_url }}</p>
|
<p>Gitea instance {{ hook.webhook.gitea_url }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="sites__banner">Nothing to show, click <a href="{{page.dash.forgejo_webhook.add}}">here</a> to add new Forgejo webhook!</p>
|
<p class="sites__banner">Nothing to show, click <a href="{{page.dash.gitea_webhook.add}}">here</a> to add new Gitea webhook!</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends 'base' %}{% block title %} {{ payload.webhook.forgejo_url }}{% endblock title %} {% block nav
|
{% extends 'base' %}{% block title %} {{ payload.webhook.gitea_url }}{% endblock title %} {% block nav
|
||||||
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
%} {% include "auth_nav" %} {% endblock nav %} {% block main %}
|
||||||
|
|
||||||
<main class="sites__main">
|
<main class="sites__main">
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Secret</th>
|
<th>Secret</th>
|
||||||
<td>
|
<td>
|
||||||
{% if show_forgejo_webhook_secret %}
|
{% if show_gitea_webhook_secret %}
|
||||||
{{ payload.webhook.forgejo_webhook_secret }} <a href="{{ payload.view }}">Hide</a>
|
{{ payload.webhook.gitea_webhook_secret }} <a href="{{ payload.view }}">Hide</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
****
|
****
|
||||||
<a href="{{ payload.view }}?show_forgejo_webhook_secret=true">
|
<a href="{{ payload.view }}?show_gitea_webhook_secret=true">
|
||||||
Show
|
Show
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
56
utils/cache-bust/Cargo.lock
generated
56
utils/cache-bust/Cargo.lock
generated
|
@ -72,7 +72,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"strsim",
|
"strsim",
|
||||||
"syn 1.0.94",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -83,7 +83,7 @@ checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.94",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -110,7 +110,7 @@ dependencies = [
|
||||||
"darling",
|
"darling",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.94",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -120,7 +120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68"
|
checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_builder_core",
|
"derive_builder_core",
|
||||||
"syn 1.0.94",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -176,12 +176,6 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memchr"
|
|
||||||
version = "2.7.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.16"
|
version = "0.3.16"
|
||||||
|
@ -200,18 +194,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.85"
|
version = "1.0.38"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23"
|
checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.36"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
@ -233,32 +227,31 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.210"
|
version = "1.0.137"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.210"
|
version = "1.0.137"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.66",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.128"
|
version = "1.0.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
|
checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -291,17 +284,6 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "2.0.66"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.15.0"
|
version = "1.15.0"
|
||||||
|
@ -317,12 +299,6 @@ dependencies = [
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-ident"
|
|
||||||
version = "1.0.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
|
Loading…
Reference in a new issue