13 Commits

Author SHA1 Message Date
ngn
07e3fdbe87 Merge pull request 'fix(deps): update rust crate actix-http to v3.11.0' (#26) from renovate/actix-http-3.x-lockfile into main
All checks were successful
docker / docker (push) Successful in 5m0s
ups / ups (push) Successful in 42s
Reviewed-on: #26
2025-05-13 15:51:38 +03:00
ngn
f17b08a586 Merge pull request 'fix(deps): update rust crate chrono to v0.4.41' (#25) from renovate/chrono-0.x-lockfile into main
Some checks failed
docker / docker (push) Has been cancelled
Reviewed-on: #25
2025-05-13 15:51:19 +03:00
ngn
0377feebca Merge pull request 'fix(deps): update rust crate sha256 to v1.6.0' (#27) from renovate/sha256-1.x-lockfile into main
Some checks failed
docker / docker (push) Has been cancelled
Reviewed-on: #27
2025-05-13 15:50:59 +03:00
43538ba58f fix(deps): update rust crate sha256 to v1.6.0 2025-05-13 02:01:38 +00:00
a62a71fc6f fix(deps): update rust crate actix-http to v3.11.0 2025-05-13 02:01:32 +00:00
660ed02870 fix(deps): update rust crate chrono to v0.4.41 2025-05-13 02:01:26 +00:00
ngn
d7b258c8e7 ups: update to c715480 2025-05-12 23:00:56 +03:00
ngn
06035326e3 add the ups configuration
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-12 22:42:29 +03:00
33c29ea1af update get_post_light to return none when no data is found, so not found error can happen 2025-05-12 22:37:58 +03:00
ngn
beda276909 add the ups workflow
Signed-off-by: ngn <ngn@ngn.tf>
2025-05-12 22:07:12 +03:00
ngn
660f95b8a5 Merge pull request 'fix(deps): update rust crate actix-rt to v2.10.0' (#9) from renovate/actix-rt-2.x-lockfile into custom
All checks were successful
Build and publish the docker image / build (push) Successful in 4m35s
Reviewed-on: #9
2025-02-12 19:50:28 +03:00
ngn
22068e46d5 Merge branch 'custom' into renovate/actix-rt-2.x-lockfile 2025-02-12 19:50:18 +03:00
98f1461706 fix(deps): update rust crate actix-rt to v2.10.0 2025-01-20 03:02:07 +00:00
7 changed files with 210 additions and 77 deletions

View File

@ -1,28 +1,34 @@
name: Build and publish the docker image name: docker
on: on:
push: push:
branches: ["custom"] branches:
- "main"
paths-ignore:
- "README.md"
- "LICENSE.txt"
- "docker-compose.example.yml"
- "ups.json"
env: env:
REGISTRY: git.ngn.tf REGISTRY: git.ngn.tf
IMAGE: ${{gitea.repository}} IMAGE: ${{gitea.repository}}
jobs: jobs:
build: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: "https://github.com/actions/checkout@v4" uses: actions/checkout@v4
- name: Login to container repo - name: Login to container repo
uses: "https://github.com/docker/login-action@v1" uses: docker/login-action@v1
with: with:
registry: ${{env.REGISTRY}} registry: ${{env.REGISTRY}}
username: ${{gitea.actor}} username: ${{gitea.actor}}
password: ${{secrets.PACKAGES_TOKEN}} password: ${{secrets.PACKAGES_TOKEN}}
- name: Build image - name: Build docker image
run: | run: |
docker build . --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest docker build . --tag ${{env.REGISTRY}}/${{env.IMAGE}}:latest
docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest docker push ${{env.REGISTRY}}/${{env.IMAGE}}:latest

25
.gitea/workflows/ups.yml Normal file
View File

@ -0,0 +1,25 @@
name: ups
on:
schedule:
- cron: "@weekly"
jobs:
ups:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update -y
sudo apt install -y python3 python3-build python3-requests make
- name: Install ups
run: |
git clone https://git.ngn.tf/ngn/ups && cd ups
make && make install
- name: Run ups
run: PATH=~/.local/bin:$PATH ups-check

173
Cargo.lock generated
View File

@ -31,7 +31,7 @@ dependencies = [
"actix-web", "actix-web",
"bitflags 2.5.0", "bitflags 2.5.0",
"bytes", "bytes",
"derive_more", "derive_more 0.99.18",
"futures-core", "futures-core",
"http-range", "http-range",
"log", "log",
@ -44,23 +44,23 @@ dependencies = [
[[package]] [[package]]
name = "actix-http" name = "actix-http"
version = "3.9.0" version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d48f96fc3003717aeb9856ca3d02a8c7de502667ad76eeacd830b48d2e91fac4" checksum = "44dfe5c9e0004c623edc65391dfd51daa201e7e30ebd9c9bedf873048ec32bc2"
dependencies = [ dependencies = [
"actix-codec", "actix-codec",
"actix-rt", "actix-rt",
"actix-service", "actix-service",
"actix-utils", "actix-utils",
"ahash 0.8.11",
"base64 0.22.1", "base64 0.22.1",
"bitflags 2.5.0", "bitflags 2.5.0",
"brotli", "brotli",
"bytes", "bytes",
"bytestring", "bytestring",
"derive_more", "derive_more 2.0.1",
"encoding_rs", "encoding_rs",
"flate2", "flate2",
"foldhash",
"futures-core", "futures-core",
"h2", "h2",
"http", "http",
@ -108,9 +108,9 @@ dependencies = [
[[package]] [[package]]
name = "actix-rt" name = "actix-rt"
version = "2.9.0" version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208"
dependencies = [ dependencies = [
"actix-macros", "actix-macros",
"futures-core", "futures-core",
@ -128,7 +128,7 @@ dependencies = [
"actix-utils", "actix-utils",
"futures-core", "futures-core",
"futures-util", "futures-util",
"mio", "mio 0.8.11",
"socket2", "socket2",
"tokio", "tokio",
"tracing", "tracing",
@ -175,7 +175,7 @@ dependencies = [
"bytestring", "bytestring",
"cfg-if", "cfg-if",
"cookie", "cookie",
"derive_more", "derive_more 0.99.18",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
@ -241,7 +241,7 @@ version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.2.15",
"once_cell", "once_cell",
"version_check", "version_check",
] ]
@ -253,7 +253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"getrandom", "getrandom 0.2.15",
"once_cell", "once_cell",
"version_check", "version_check",
"zerocopy", "zerocopy",
@ -386,9 +386,9 @@ dependencies = [
[[package]] [[package]]
name = "brotli" name = "brotli"
version = "6.0.0" version = "8.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" checksum = "9991eea70ea4f293524138648e41ee89b0b2b12ddef3b255effa43c8056e0e0d"
dependencies = [ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
"alloc-stdlib", "alloc-stdlib",
@ -397,9 +397,9 @@ dependencies = [
[[package]] [[package]]
name = "brotli-decompressor" name = "brotli-decompressor"
version = "4.0.1" version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03"
dependencies = [ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
"alloc-stdlib", "alloc-stdlib",
@ -451,16 +451,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.39" version = "0.4.41"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
dependencies = [ dependencies = [
"android-tzdata", "android-tzdata",
"iana-time-zone", "iana-time-zone",
"js-sys", "js-sys",
"num-traits", "num-traits",
"wasm-bindgen", "wasm-bindgen",
"windows-targets 0.52.5", "windows-link",
] ]
[[package]] [[package]]
@ -593,6 +593,27 @@ dependencies = [
"syn 2.0.96", "syn 2.0.96",
] ]
[[package]]
name = "derive_more"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.96",
"unicode-xid",
]
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.10.7" version = "0.10.7"
@ -698,6 +719,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]] [[package]]
name = "foreign-types" name = "foreign-types"
version = "0.3.2" version = "0.3.2"
@ -848,7 +875,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasi 0.14.2+wasi-0.2.4",
] ]
[[package]] [[package]]
@ -1313,9 +1352,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.155" version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]] [[package]]
name = "libmedium" name = "libmedium"
@ -1329,7 +1368,7 @@ dependencies = [
"bincode", "bincode",
"chrono", "chrono",
"config", "config",
"derive_more", "derive_more 0.99.18",
"futures", "futures",
"graphql_client", "graphql_client",
"lazy_static", "lazy_static",
@ -1448,10 +1487,21 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "mio"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.12" version = "0.2.12"
@ -1788,21 +1838,26 @@ dependencies = [
] ]
[[package]] [[package]]
name = "rand" name = "r-efi"
version = "0.8.5" version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "rand"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
dependencies = [ dependencies = [
"libc",
"rand_chacha", "rand_chacha",
"rand_core", "rand_core",
] ]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.3.1" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [ dependencies = [
"ppv-lite86", "ppv-lite86",
"rand_core", "rand_core",
@ -1810,11 +1865,11 @@ dependencies = [
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.6.4" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [ dependencies = [
"getrandom", "getrandom 0.3.3",
] ]
[[package]] [[package]]
@ -1985,9 +2040,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]] [[package]]
name = "sailfish" name = "sailfish"
version = "0.9.0" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4d5cd6d4f24f3ab107e949ab424738cf55b03deddce3b184c46985d7b1394ef" checksum = "acd5f4680149b62b3478f6af08a8f1c37794bc1bc577e28874a4d0c70084d600"
dependencies = [ dependencies = [
"itoap", "itoap",
"ryu", "ryu",
@ -1997,9 +2052,9 @@ dependencies = [
[[package]] [[package]]
name = "sailfish-compiler" name = "sailfish-compiler"
version = "0.9.0" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7254ec7b3651f7f723a9073153f5dcddc1f2bf1bf8d1b23ac71c236ef6360d2b" checksum = "67087aca4a3886686a88cee6835089c53e6143a0b8c5be01e63e4fe2f6dfe7cb"
dependencies = [ dependencies = [
"filetime", "filetime",
"home", "home",
@ -2013,9 +2068,9 @@ dependencies = [
[[package]] [[package]]
name = "sailfish-macros" name = "sailfish-macros"
version = "0.9.0" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00812289fe1891c191cc2d9db461352fc410619e07ec2bb748faaa06412619d0" checksum = "e47e31910c5f9230e99992568d05a5968fe4f42a635c3f912c993e9f66a619a5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"sailfish-compiler", "sailfish-compiler",
@ -2151,9 +2206,9 @@ dependencies = [
[[package]] [[package]]
name = "sha256" name = "sha256"
version = "1.5.0" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" checksum = "f880fc8562bdeb709793f00eb42a2ad0e672c4f883bbe59122b926eca935c8f6"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
@ -2384,19 +2439,19 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.38.0" version = "1.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
"libc", "libc",
"mio", "mio 1.0.3",
"parking_lot 0.12.3", "parking_lot 0.12.3",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2", "socket2",
"windows-sys 0.48.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -2521,6 +2576,12 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]] [[package]]
name = "unreachable" name = "unreachable"
version = "1.0.0" version = "1.0.0"
@ -2602,6 +2663,15 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
dependencies = [
"wit-bindgen-rt",
]
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.92" version = "0.2.92"
@ -2718,6 +2788,12 @@ dependencies = [
"windows-targets 0.52.5", "windows-targets 0.52.5",
] ]
[[package]]
name = "windows-link"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"
@ -2876,6 +2952,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags 2.5.0",
]
[[package]] [[package]]
name = "write16" name = "write16"
version = "1.0.0" version = "1.0.0"

View File

@ -1,5 +1,7 @@
# [ngn.tf] | libmedium # libmedium - proxy for medium.com
![](https://git.ngn.tf/ngn/libmedium/actions/workflows/build.yml/badge.svg) ![](https://git.ngn.tf/ngn/libmedium/actions/workflows/docker.yml/badge.svg)
![](https://git.ngn.tf/ngn/libmedium/actions/workflows/ups.yml/badge.svg)
A fork of the [libmedium](https://github.com/realaravinth/libmedium) project, with my personal changes. A fork of the [libmedium](https://github.com/realaravinth/libmedium) project,
with my personal changes.

View File

@ -164,14 +164,14 @@ impl Data {
} }
} }
pub async fn get_post_light(&self, id: &str) -> PostUrl { pub async fn get_post_light(&self, id: &str) -> Option<PostUrl> {
match self.posts.get(id) { match self.posts.get(id) {
Ok(Some(v)) => { Ok(Some(v)) => {
let cached: PostResp = bincode::deserialize(&v[..]).unwrap(); let cached: PostResp = bincode::deserialize(&v[..]).unwrap();
PostUrl { Some(PostUrl {
slug: cached.unique_slug, slug: cached.unique_slug,
username: cached.creator.username, username: cached.creator.username,
} })
} }
_ => { _ => {
let vars = get_post_light::Variables { id: id.to_owned() }; let vars = get_post_light::Variables { id: id.to_owned() };
@ -180,10 +180,16 @@ impl Data {
let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars) let res = post_graphql::<GetPostLight, _>(&self.client, URL, vars)
.await .await
.unwrap(); .unwrap();
let res = res.data.expect("missing response data").post.unwrap(); if res.data.is_none() {
PostUrl { None
} else {
match res.data.expect("missing response data").post {
None => None,
Some(res) => Some(PostUrl {
slug: res.unique_slug, slug: res.unique_slug,
username: res.creator.username, username: res.creator.username,
}),
}
} }
} }
} }

View File

@ -158,29 +158,33 @@ async fn assets(path: web::Path<String>, data: AppData) -> impl Responder {
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.by_post_id")] #[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.by_post_id")]
async fn by_post_id(path: web::Path<String>, data: AppData) -> impl Responder { async fn by_post_id(path: web::Path<String>, data: AppData) -> impl Responder {
let post_data = data.get_post_light(&path).await; match data.get_post_light(&path).await {
HttpResponse::Found() None => HttpResponse::NotFound().body("Post not found"),
Some(post_data) => HttpResponse::Found()
.append_header(( .append_header((
header::LOCATION, header::LOCATION,
crate::V1_API_ROUTES crate::V1_API_ROUTES
.proxy .proxy
.get_page(&post_data.username, &post_data.slug), .get_page(&post_data.username, &post_data.slug),
)) ))
.finish() .finish(),
}
} }
#[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.top_level_post")] #[actix_web_codegen_const_routes::get(path = "crate::V1_API_ROUTES.proxy.top_level_post")]
async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder { async fn by_top_level_post(path: web::Path<String>, data: AppData) -> impl Responder {
if let Some(post_id) = path.split('-').last() { if let Some(post_id) = path.split('-').last() {
let post_data = data.get_post_light(post_id).await; match data.get_post_light(post_id).await {
HttpResponse::Found() None => HttpResponse::NotFound().body("Post not found"),
Some(post_data) => HttpResponse::Found()
.append_header(( .append_header((
header::LOCATION, header::LOCATION,
crate::V1_API_ROUTES crate::V1_API_ROUTES
.proxy .proxy
.get_page(&post_data.username, &post_data.slug), .get_page(&post_data.username, &post_data.slug),
)) ))
.finish() .finish(),
}
} else { } else {
HttpResponse::NotFound().body("Post not found, please file bug report") HttpResponse::NotFound().body("Post not found, please file bug report")
} }

5
ups.json Normal file
View File

@ -0,0 +1,5 @@
{
"upstream": "https://git.batsense.net/realaravinth/libmedium",
"provider": "gitea",
"commit": "c7154807884e1bb8228a7682c5a3dee9becf5ac4"
}