add: CACHE_BREAKER env var

This commit is contained in:
trisua 2025-06-22 18:53:02 -04:00
parent 69fc3ca490
commit aceb51c21c
7 changed files with 18 additions and 9 deletions

View file

@ -33,7 +33,7 @@ Tetratto **requires** Cloudflare Turnstile for registrations. Testing keys are l
A `docs` directory will be generated in the same directory that you ran the `tetratto` binary in. **Markdown** files placed here will be served at `/doc/{*file_name}`. For other types of assets, you can place them in the generated `public` directory. This directory serves everything at `/public/{*file_name}`.
You can configure your port through the `port` key of the configuration file. You can also run the server with the `PORT` environment variable, which will override whatever is set in the configuration file.
You can configure your port through the `port` key of the configuration file. You can also run the server with the `PORT` environment variable, which will override whatever is set in the configuration file. You can also use the `CACHE_BREAKER` environment variable to specify a version number to be used in static asset links in order to break cache entries.
## Usage (as a user)

View file

@ -495,6 +495,13 @@ pub(crate) async fn initial_context(
}
ctx.insert("lang", &lang.data);
ctx.insert("random_cache_breaker", &CACHE_BREAKER.clone());
ctx.insert(
"random_cache_breaker",
&if let Ok(c) = std::env::var("CACHE_BREAKER") {
c
} else {
CACHE_BREAKER.clone()
},
);
ctx
}

View file

@ -322,6 +322,7 @@
\"Spotify\",
{
token: new_token,
refresh_token: new_refresh_token,
expires_in: expires_in.toString(),
name: profile.display_name,
},

View file

@ -136,7 +136,7 @@
("class" "dropdown")
("style" "width: max-content")
(button
("class" "camo raised small")
("class" "raised small")
("onclick" "trigger('atto::hooks::dropdown', [event])")
("exclude" "dropdown")
(icon (text "sliders-horizontal"))

View file

@ -20,7 +20,7 @@
("class" "dropdown")
("style" "width: max-content")
(button
("class" "camo raised small")
("class" "raised small")
("onclick" "trigger('atto::hooks::dropdown', [event])")
("exclude" "dropdown")
(icon (text "sliders-horizontal"))

View file

@ -300,7 +300,7 @@
self.define(
"repost",
(
async (
_,
id,
content,
@ -308,6 +308,7 @@
do_not_redirect = false,
is_stack = false,
) => {
await trigger("atto::debounce", ["posts::create"]);
return new Promise((resolve, _) => {
fetch(`/api/v1/posts/${id}/repost`, {
method: "POST",
@ -892,7 +893,7 @@
return;
}
const now = new Date().getTime();
const now = Date.now();
const updated = Number.parseInt(updated_) + 8000;
let elapsed_since_update = now - updated;

View file

@ -30,7 +30,7 @@ use tetratto_core::{
};
use tetratto_core::cache::redis::Commands;
use tetratto_shared::{
hash::{self, random_id},
hash::{hash, salt, random_id},
unix_epoch_timestamp,
};
@ -185,7 +185,7 @@ pub async fn append_associations_request(
// resolve tokens
for token in req.tokens {
let hashed = hash::hash(token);
let hashed = hash(token);
let user_from_token = match data.get_user_by_token(&hashed).await {
Ok(ua) => ua,
Err(_) => continue,
@ -556,7 +556,7 @@ pub async fn subscription_handler(
pub async fn handle_socket(socket: WebSocket, db: DataManager, user_id: String, stream_id: String) {
let (mut sink, mut stream) = socket.split();
let socket_id = tetratto_shared::hash::salt();
let socket_id = salt();
db.0.1
.incr("atto.active_connections:users".to_string())
.await;