add: CACHE_BREAKER env var
This commit is contained in:
parent
69fc3ca490
commit
aceb51c21c
7 changed files with 18 additions and 9 deletions
|
@ -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}`.
|
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)
|
## Usage (as a user)
|
||||||
|
|
||||||
|
|
|
@ -495,6 +495,13 @@ pub(crate) async fn initial_context(
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.insert("lang", &lang.data);
|
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
|
ctx
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,7 @@
|
||||||
\"Spotify\",
|
\"Spotify\",
|
||||||
{
|
{
|
||||||
token: new_token,
|
token: new_token,
|
||||||
|
refresh_token: new_refresh_token,
|
||||||
expires_in: expires_in.toString(),
|
expires_in: expires_in.toString(),
|
||||||
name: profile.display_name,
|
name: profile.display_name,
|
||||||
},
|
},
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
("class" "dropdown")
|
("class" "dropdown")
|
||||||
("style" "width: max-content")
|
("style" "width: max-content")
|
||||||
(button
|
(button
|
||||||
("class" "camo raised small")
|
("class" "raised small")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
(icon (text "sliders-horizontal"))
|
(icon (text "sliders-horizontal"))
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
("class" "dropdown")
|
("class" "dropdown")
|
||||||
("style" "width: max-content")
|
("style" "width: max-content")
|
||||||
(button
|
(button
|
||||||
("class" "camo raised small")
|
("class" "raised small")
|
||||||
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
("onclick" "trigger('atto::hooks::dropdown', [event])")
|
||||||
("exclude" "dropdown")
|
("exclude" "dropdown")
|
||||||
(icon (text "sliders-horizontal"))
|
(icon (text "sliders-horizontal"))
|
||||||
|
|
|
@ -300,7 +300,7 @@
|
||||||
|
|
||||||
self.define(
|
self.define(
|
||||||
"repost",
|
"repost",
|
||||||
(
|
async (
|
||||||
_,
|
_,
|
||||||
id,
|
id,
|
||||||
content,
|
content,
|
||||||
|
@ -308,6 +308,7 @@
|
||||||
do_not_redirect = false,
|
do_not_redirect = false,
|
||||||
is_stack = false,
|
is_stack = false,
|
||||||
) => {
|
) => {
|
||||||
|
await trigger("atto::debounce", ["posts::create"]);
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
fetch(`/api/v1/posts/${id}/repost`, {
|
fetch(`/api/v1/posts/${id}/repost`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -892,7 +893,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Date().getTime();
|
const now = Date.now();
|
||||||
const updated = Number.parseInt(updated_) + 8000;
|
const updated = Number.parseInt(updated_) + 8000;
|
||||||
|
|
||||||
let elapsed_since_update = now - updated;
|
let elapsed_since_update = now - updated;
|
||||||
|
|
|
@ -30,7 +30,7 @@ use tetratto_core::{
|
||||||
};
|
};
|
||||||
use tetratto_core::cache::redis::Commands;
|
use tetratto_core::cache::redis::Commands;
|
||||||
use tetratto_shared::{
|
use tetratto_shared::{
|
||||||
hash::{self, random_id},
|
hash::{hash, salt, random_id},
|
||||||
unix_epoch_timestamp,
|
unix_epoch_timestamp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ pub async fn append_associations_request(
|
||||||
|
|
||||||
// resolve tokens
|
// resolve tokens
|
||||||
for token in req.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 {
|
let user_from_token = match data.get_user_by_token(&hashed).await {
|
||||||
Ok(ua) => ua,
|
Ok(ua) => ua,
|
||||||
Err(_) => continue,
|
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) {
|
pub async fn handle_socket(socket: WebSocket, db: DataManager, user_id: String, stream_id: String) {
|
||||||
let (mut sink, mut stream) = socket.split();
|
let (mut sink, mut stream) = socket.split();
|
||||||
let socket_id = tetratto_shared::hash::salt();
|
let socket_id = salt();
|
||||||
db.0.1
|
db.0.1
|
||||||
.incr("atto.active_connections:users".to_string())
|
.incr("atto.active_connections:users".to_string())
|
||||||
.await;
|
.await;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue