Browse Source

提醒旧版前端分区问题

master v1.4
hole-thu 3 years ago
parent
commit
18262a62e0
  1. 11
      src/api/post.rs
  2. 2
      src/cors.rs
  3. 2
      src/main.rs
  4. 2
      src/models.rs

11
src/api/post.rs

@ -186,10 +186,19 @@ pub async fn publish_post(
db: Db,
rconn: RdsConn,
) -> JsonApi {
let text = if poi.room_id.is_none() {
format!(
"{}\n\n---\n\n\\* 无效分区或来自旧版前端,已默认归档到0区。分区管理说明见 #100426,建议尽快更新前端(点击ⓘ ,点击“立即更新”)。",
&poi.text
)
} else {
poi.text.to_string()
};
let p = Post::create(
&db,
NewPost {
content: poi.text.to_string(),
content: text,
cw: poi.cw.to_string(),
author_hash: user.namehash.to_string(),
author_title: poi.use_title.map(|_| user.custom_title).unwrap_or_default(),

2
src/cors.rs

@ -1,3 +1,5 @@
#![allow(clippy::let_unit_value)]
use rocket::fairing::{Fairing, Info, Kind};
use rocket::http::Header;
use rocket::{Request, Response};

2
src/main.rs

@ -54,7 +54,7 @@ async fn main() -> Result<(), rocket::Error> {
let rconn = RdsConn(rmc.clone());
tokio::spawn(async move {
loop {
for room_id in [None, Some(0), Some(1), Some(42)] {
for room_id in (0..5).map(Some).chain([None, Some(42)]) {
cache::PostListCache::init(room_id, 3, &rconn).clear().await;
}
sleep(Duration::from_secs(5 * 60)).await;

2
src/models.rs

@ -365,7 +365,7 @@ impl Post {
.unwrap();
PostCache::init(&rconn).clear_all().await;
for room_id in [None, Some(0), Some(1), Some(42)] {
for room_id in (0..5).map(Some).chain([None, Some(42)]) {
PostListCache::init(room_id, 2, rconn).clear().await;
}
}

Loading…
Cancel
Save