package patched redlib

This commit is contained in:
NullBite 2024-06-23 00:47:30 -04:00
parent a09fb0ba96
commit 2bea6bc1d9
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A
3 changed files with 96 additions and 0 deletions

View File

@ -12,4 +12,5 @@ in
wm-helpers = callPackage ./wm-helpers { };
atool = callPackage ./atool-wrapped { };
nixfiles-assets = callPackage ./nixfiles-assets { };
redlib = callPackage ./redlib { };
}

View File

@ -0,0 +1,30 @@
From bd47c206a1d94c8382570b69730d72562d777454 Mon Sep 17 00:00:00 2001
From: Matthew Esposito <matt@matthew.science>
Date: Thu, 30 May 2024 18:08:45 -0400
Subject: [PATCH] fix(oauth): Make Android user-agent patching unconditional
---
src/client.rs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/client.rs b/src/client.rs
index 5b8fe8f..5ea9d1c 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -181,11 +181,12 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
)
};
- // Check if multi sub requested, or if submitted was requested. If so, replace "Android" with a tricky word.
+ // Replace "Android" with a tricky word.
// Issues: #78/#115, #116
- if path.contains('+') || path.contains("/submitted") {
- user_agent = user_agent.replace("Android", "Andr\u{200B}oid");
- }
+ // If you include the word "Android", you will get a number of different errors
+ // I guess they don't expect mobile traffic on the endpoints we use
+ // Scrawled on wall for next poor soul: Run the test suite.
+ user_agent = user_agent.replace("Android", "Andr\u{200B}oid");
// Build request to Reddit. When making a GET, request gzip compression.
// (Reddit doesn't do brotli yet.)

65
pkgs/redlib/default.nix Normal file
View File

@ -0,0 +1,65 @@
{ lib
, stdenv
, cacert
, nixosTests
, rustPlatform
, fetchFromGitHub
, darwin
}:
rustPlatform.buildRustPackage rec {
pname = "redlib";
version = "0.34.0";
src = fetchFromGitHub {
owner = "redlib-org";
repo = "redlib";
rev = "refs/tags/v${version}";
hash = "sha256-JpuCX2ae9me+zHxQj5jqQlgDci2NV+TEVUAqnuTn3cA=";
};
patches = [
./auth-fix.patch
];
cargoHash = "sha256-gkRblCHUFiprZeYtu43GIGBZqCq5l/HEGaQN91XbfSs=";
buildInputs = lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
];
checkFlags = [
# All these test try to connect to Reddit.
"--skip=test_fetching_subreddit_quarantined"
"--skip=test_fetching_nsfw_subreddit"
"--skip=test_fetching_ws"
"--skip=test_obfuscated_share_link"
"--skip=test_share_link_strip_json"
"--skip=test_localization_popular"
"--skip=test_fetching_subreddit"
"--skip=test_fetching_user"
# These try to connect to the oauth client
"--skip=test_oauth_client"
"--skip=test_oauth_client_refresh"
"--skip=test_oauth_token_exists"
];
env = {
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
};
passthru.tests = {
inherit (nixosTests) redlib;
};
meta = {
changelog = "https://github.com/redlib-org/redlib/releases/tag/v${version}";
description = "Private front-end for Reddit (Continued fork of Libreddit)";
homepage = "https://github.com/redlib-org/redlib";
license = lib.licenses.agpl3Only;
mainProgram = "redlib";
maintainers = with lib.maintainers; [ soispha ];
};
}