fix: don't show replies in main timelines

fix: add ui debounce
fix: make usernames case insensitive
This commit is contained in:
trisua 2025-04-03 16:47:48 -04:00
parent 9f4e8a4d25
commit 8a9394a06a
6 changed files with 14 additions and 8 deletions

View file

@ -75,8 +75,9 @@
</form> </form>
<script> <script>
function register(e) { async function register(e) {
e.preventDefault(); e.preventDefault();
await trigger("atto::debounce", ["users::create"]);
fetch("/api/v1/auth/register", { fetch("/api/v1/auth/register", {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -65,8 +65,9 @@
</div> </div>
<script> <script>
function create_post_from_form(e) { async function create_post_from_form(e) {
e.preventDefault(); e.preventDefault();
await trigger("atto::debounce", ["posts::create"]);
fetch("/api/v1/posts", { fetch("/api/v1/posts", {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -58,8 +58,9 @@
</main> </main>
<script> <script>
function create_community_from_form(e) { async function create_community_from_form(e) {
e.preventDefault(); e.preventDefault();
await trigger("atto::debounce", ["communities::create"]);
fetch("/api/v1/communities", { fetch("/api/v1/communities", {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -141,8 +141,9 @@
</main> </main>
<script> <script>
function create_reply_from_form(e) { async function create_reply_from_form(e) {
e.preventDefault(); e.preventDefault();
await trigger("atto::debounce", ["posts::create"]);
fetch("/api/v1/posts", { fetch("/api/v1/posts", {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -76,11 +76,13 @@ impl DataManager {
/// ///
/// # Arguments /// # Arguments
/// * `data` - a mock [`User`] object to insert /// * `data` - a mock [`User`] object to insert
pub async fn create_user(&self, data: User) -> Result<()> { pub async fn create_user(&self, mut data: User) -> Result<()> {
if self.0.security.registration_enabled == false { if self.0.security.registration_enabled == false {
return Err(Error::RegistrationDisabled); return Err(Error::RegistrationDisabled);
} }
data.username = data.username.to_lowercase();
// check values // check values
if data.username.len() < 2 { if data.username.len() < 2 {
return Err(Error::DataTooShort("username".to_string())); return Err(Error::DataTooShort("username".to_string()));

View file

@ -223,7 +223,7 @@ impl DataManager {
let res = query_rows!( let res = query_rows!(
&conn, &conn,
"SELECT * FROM posts ORDER BY likes DESC, created ASC LIMIT $1 OFFSET $2", "SELECT * FROM posts WHERE replying_to = 0 ORDER BY likes DESC, created ASC LIMIT $1 OFFSET $2",
&[&(batch as i64), &((page * batch) as i64)], &[&(batch as i64), &((page * batch) as i64)],
|x| { Self::get_post_from_row(x) } |x| { Self::get_post_from_row(x) }
); );
@ -268,7 +268,7 @@ impl DataManager {
let res = query_rows!( let res = query_rows!(
&conn, &conn,
&format!( &format!(
"SELECT * FROM posts WHERE community = {} {query_string} ORDER BY created DESC LIMIT $1 OFFSET $2", "SELECT * FROM posts WHERE (community = {} {query_string}) AND replying_to = 0 ORDER BY created DESC LIMIT $1 OFFSET $2",
first.community first.community
), ),
&[&(batch as i64), &((page * batch) as i64)], &[&(batch as i64), &((page * batch) as i64)],
@ -423,7 +423,7 @@ impl DataManager {
// send notification // send notification
if data.owner != rt.owner { if data.owner != rt.owner {
let owner = self.get_user_by_id(rt.owner).await?; let owner = self.get_user_by_id(data.owner).await?;
self.create_notification(Notification::new( self.create_notification(Notification::new(
"Your post has received a new comment!".to_string(), "Your post has received a new comment!".to_string(),
format!( format!(