Fixed notifications getting spammed when user repeatedly follows and unfollows a user

This commit is contained in:
CaramelKat
2021-11-30 00:09:16 -06:00
committed by CaramelKat
parent 5ba712838d
commit 91d5a2252d
4 changed files with 9 additions and 4 deletions

View File

@@ -200,7 +200,10 @@ router.post('/follow', upload.none(), async function (req, res) {
userToFollow.addToFollowers(user.pid);
user.addToUsers(userToFollow.pid);
res.sendStatus(200);
await database.pushNewNotificationByPID(userToFollow.pid, user.user_id + ' ' + req.lang.notifications.new_follower, '/users/show?pid=' + user.pid)
let content = user.user_id + ' ' + req.lang.notifications.new_follower;
var picked = userToFollow.notification_list.find(o => o.content === content);
if(picked === undefined)
await database.pushNewNotificationByPID(userToFollow.pid, content, '/users/show?pid=' + user.pid)
}
else if(req.body.type === 'false' && user !== null && user.followed_users.indexOf(userToFollow.pid) !== -1)
{

View File

@@ -1136,6 +1136,10 @@ h4 {
.community-page-post-wrapper > h3 {
padding-left: 0;
overflow-wrap: break-word;
width: 760px;
max-width: 760px;
line-break: anywhere;
line-height: 20px;
}
.community-page-post-screenshot {

View File

@@ -287,8 +287,6 @@ function followUser(user) {
var userWrapper = user.parentElement;
var followersElement = document.getElementById('user-page-followers-tab');
var followers = followersElement.innerHTML.trim().substr(0, followersElement.innerHTML.indexOf(' ') + 1);
alert(followersElement.innerHTML)
alert('"' + followers + '"')
if (userWrapper.classList.contains("selected")) {
userWrapper.classList.remove("selected");
user.style.color = '#673DB6';

View File

@@ -40,7 +40,7 @@
<img id="<%= post.id%>" class="community-page-post-painting" src="<%= post.painting_uri %>">
<%}%>
<% if(post.url) { %>
<iframe width="760" height="427.5" src="<%= post.url %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="760" height="427.5" src="<%= post.url.replace('watch?v=','embed/') %>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<%}%>
<% if(post.screenshot !== '' && post.body && post.body.size <= 50) { %>
<div class="community-page-post-text-overlay">