Skip to content

Commit

Permalink
feat: added notice notification type for moderator actions
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelKat committed Jan 15, 2025
1 parent 333ae08 commit aa4f100
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/models/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const NotificationSchema = new Schema({
pid: String,
type: String,
link: String,
image: String,
text: String,
objectID: String,
users: [{
user: String,
Expand Down
10 changes: 10 additions & 0 deletions src/services/juxt-web/routes/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ router.post('/accounts/:pid', async (req, res) => {
res.json({
error: false
});

if (req.body.account_status === 1) {
await util.newNotification({
pid: pid,
type: 'notice',
text: `You have been limited from posting until ${moment(req.body.ban_lift_date)}. Reason: \"${req.body.ban_reason}\". If you have any questions contact the moderators in the Discord server or forum.`,
image: '/images/bandwidthalert.png',
link: '/titles/2551084080/new'
});
}
});

router.delete('/:reportID', async function (req, res) {
Expand Down
11 changes: 11 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,17 @@ async function newNotification(notification) {
});
await newNotification.save();
}
} else if (notification.type == 'notice') {
const newNotification = new NOTIFICATION({
pid: notification.pid,
type: notification.type,
text: notification.text,
image: notification.image,
link: notification.link,
read: false,
lastUpdated: now
});
await newNotification.save();
}
/*else if(notification.type === 'yeah') {
// { pid: userToFollowContent.pid, type: "follow", objectID: req.pid, link: `/users/${req.pid}` }
Expand Down
Binary file added src/webfiles/ctr/images/bandwidthalert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions src/webfiles/ctr/partials/notifications.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@
<%}%>
</div>
</li>
<%}%>
<%}%>
<%} else if (notification.type === 'notice') {%>
<li>
<a href="<%= notification.link %>" data-pjax="#body" class="icon-container notify">
<img src="<%= notification.image %>" class="icon">
</a>
<a class="body" href="<%= notification.link %>">
<span class="text">
<span class="nick-name"><%= notification.text %></span>
<span class="timestamp"> <%= moment(notification.lastUpdated).fromNow() %></span>
</span>
</a>
</li>
<%}%>
<%}%>
<%}%>
</ul>
Binary file added src/webfiles/portal/images/bandwidthalert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions src/webfiles/portal/partials/notifications.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@
<%}%>
</div>
</li>
<%}%>
<%}%>
<%} else if (notification.type === 'notice') {%>
<li>
<a href="<%= notification.link %>" data-pjax="#body" class="icon-container notify">
<img src="<%= notification.image %>" class="icon">
</a>
<a class="body" href="<%= notification.link %>">
<span class="text">
<span class="nick-name"><%= notification.text %></span>
<span class="timestamp"> <%= moment(notification.lastUpdated).fromNow() %></span>
</span>
</a>
</li>
<%}%>
<%}%>
<%}%>
</ul>
Binary file added src/webfiles/web/images/bandwidthalert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions src/webfiles/web/partials/notifications.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
</a>
</div>
</li>
<%}%>
<%}%>
<%} else if (notification.type === 'notice') {%>
<li>
<div class="hover">
<a href="<%= notification.link %>" data-pjax="#body" class="icon-container notify">
<img src="<%= notification.image %>" class="icon">
</a>
<a class="body" href="<%= notification.link %>">
<span class="text">
<span class="nick-name"><%= notification.text %></span>
<span class="timestamp"> <%= moment(notification.lastUpdated).fromNow() %></span>
</span>
</a>
</div>
</li>
<%}%>
<%}%>
</ul>

0 comments on commit aa4f100

Please sign in to comment.