From b8b5214f444eb95d3593e162645b83b93263f3ef Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 25 Jan 2025 11:13:12 +0000 Subject: [PATCH] option to restrict recent-uploads visibility --- README.md | 2 ++ copyparty/__main__.py | 1 + copyparty/cfg.py | 1 + copyparty/httpcli.py | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/README.md b/README.md index aa3d6273..60e449fb 100644 --- a/README.md +++ b/README.md @@ -892,6 +892,8 @@ will show uploader IP and upload-time if the visitor has the admin permission * global-option `--ups-when` makes upload-time visible to all users, and not just admins +* global-option `--ups-who` (volflag `ups_who`) specifies who gets access (0=nobody, 1=admins, 2=everyone), default=2 + note that the [🧯 unpost](#unpost) feature is better suited for viewing *your own* recent uploads, as it includes the option to undo/delete them diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 08ad18f5..faf86526 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1344,6 +1344,7 @@ def add_admin(ap): ap2.add_argument("--no-ups-page", action="store_true", help="disable ?ru (list of recent uploads)") ap2.add_argument("--no-up-list", action="store_true", help="don't show list of incoming files in controlpanel") ap2.add_argument("--dl-list", metavar="LVL", type=int, default=2, help="who can see active downloads in the controlpanel? [\033[32m0\033[0m]=nobody, [\033[32m1\033[0m]=admins, [\033[32m2\033[0m]=everyone") + ap2.add_argument("--ups-who", metavar="LVL", type=int, default=2, help="who can see recent uploads on the ?ru page? [\033[32m0\033[0m]=nobody, [\033[32m1\033[0m]=admins, [\033[32m2\033[0m]=everyone (volflag=ups_who)") ap2.add_argument("--ups-when", action="store_true", help="let everyone see upload timestamps on the ?ru page, not just admins") diff --git a/copyparty/cfg.py b/copyparty/cfg.py index dac1aa94..09c8a5fb 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -93,6 +93,7 @@ def vf_vmap() -> dict[str, str]: "unlist", "u2abort", "u2ts", + "ups_who", ): ret[k] = k return ret diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 2a5a86fc..2fcb66ca 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -5152,6 +5152,12 @@ def tx_rups(self) -> bool: adm = "*" in vol.axs.uadmin or self.uname in vol.axs.uadmin dots = "*" in vol.axs.udot or self.uname in vol.axs.udot + lvl = int(vol.flags["ups_who"]) + if not lvl: + continue + elif lvl == 1 and not adm: + continue + n = 1000 q = "select sz, rd, fn, ip, at from up where at>0 order by at desc" for sz, rd, fn, ip, at in cur.execute(q):