diff --git a/crates/app/src/public/js/me.js b/crates/app/src/public/js/me.js index 6cc76af..f88acb7 100644 --- a/crates/app/src/public/js/me.js +++ b/crates/app/src/public/js/me.js @@ -129,7 +129,9 @@ res.message, ]); - window.location.href = `/post/${id}`; + if (res.ok) { + window.location.href = `/post/${id}`; + } }); }); diff --git a/crates/app/src/routes/api/v1/communities/posts.rs b/crates/app/src/routes/api/v1/communities/posts.rs index 0a76fa0..6e578ce 100644 --- a/crates/app/src/routes/api/v1/communities/posts.rs +++ b/crates/app/src/routes/api/v1/communities/posts.rs @@ -356,6 +356,18 @@ pub async fn vote_request( Err(e) => return Json(e.into()), }; + // check associated accounts for prior votes + for id in user.associated { + if data.get_pollvote_by_owner_poll(id, poll.id).await.is_ok() { + return Json( + Error::MiscError( + "You've already voted on this poll on a different account".to_string(), + ) + .into(), + ); + } + } + // ... match data .create_pollvote(PollVote::new(user.id, poll.id, req.option))