Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/posts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = function (Posts) {
const content = data.content.toString();
const timestamp = data.timestamp || Date.now();
const isMain = data.isMain || false;
// raghd - add an anonymous feature for posts const
const isAnonymous = data.isAnonymous === true;

if (!uid && parseInt(uid, 10) !== 0) {
throw new Error('[[error:invalid-uid]]');
Expand All @@ -28,7 +30,8 @@ module.exports = function (Posts) {
}

const pid = data.pid || await db.incrObjectField('global', 'nextPid');
let postData = { pid, uid, tid, content, sourceContent, timestamp };
// raghd - added is anonymous to postdata
let postData = { pid, uid, tid, content, sourceContent, timestamp, isAnonymous};

if (data.toPid) {
postData.toPid = data.toPid;
Expand Down
9 changes: 9 additions & 0 deletions src/posts/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ module.exports = function (Posts) {
function modifyPost(post, fields) {
if (post) {
db.parseIntFields(post, intFields, fields);

//(Lujain change: Handle anonymous posts)
if (post.isAnonymous && parseInt(post.uid, 10) > 0) {
post.displayname = 'Anonymous';
post.username = 'Anonymous';
post.userslug = 'anonymous';
post.picture = '';
}

if (post.hasOwnProperty('upvotes') && post.hasOwnProperty('downvotes')) {
post.votes = post.upvotes - post.downvotes;
}
Expand Down
12 changes: 12 additions & 0 deletions src/posts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
const uidsSignatureSet = new Set(signatureUids.map(uid => parseInt(uid, 10)));
const groupsMap = await getGroupsMap(userData);

//Lujain Changes: mask anonymous users
userData.forEach(u => {

Check failure on line 27 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected parentheses around arrow function argument having a body with curly braces
if (u && u.isAnonymous && u.uid > 0) {

Check failure on line 28 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 3 tabs but found 4 spaces
u.username = 'Anonymous';

Check failure on line 29 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
u.userslug = 'anonymous';

Check failure on line 30 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
u.picture = '';

Check failure on line 31 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
u.fullname = undefined;

Check failure on line 32 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
u.signature = '';

Check failure on line 33 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
u.selectedGroups = [];

Check failure on line 34 in src/posts/user.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 4 tabs but found 3
}
});

userData.forEach((userData, index) => {
userData.signature = validator.escape(String(userData.signature || ''));
userData.fullname = userSettings[index].showfullname ? validator.escape(String(userData.fullname || '')) : undefined;
Expand Down
Loading