Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update upload_privileges.js #173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
63 changes: 36 additions & 27 deletions src/upgrades/1.1.1/upload_privileges.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,46 @@

const async = require('async');
const db = require('../../database');

const privilegesAPI = require('../../privileges');
const meta = require('../../meta');

module.exports = {
name: 'Giving upload privileges',
timestamp: Date.UTC(2016, 6, 12),
method: function (callback) {
const privilegesAPI = require('../../privileges');
const meta = require('../../meta');
db.getSortedSetRange('categories:cid', 0, -1, catchErrors(callback));
}

Check failure on line 13 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Missing trailing comma
}

Check failure on line 14 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

Check failure on line 15 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
function catchErrors(callback) {
return function (err, cids) { if (err) {

Check failure on line 17 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Statement inside of curly braces should be on next line
return callback(err);
}

async.eachSeries(cids, cidNext, callback);
}

Check failure on line 22 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
}

db.getSortedSetRange('categories:cid', 0, -1, (err, cids) => {
if (err) {
return callback(err);
}
function cidNext(cid, next) {
privilegesAPI.categories.list(cid, (err, data) => {
if (err) {
return next(err);
}

Check failure on line 30 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
async.eachSeries(data.groups, (group, groupNext) => {

Check failure on line 31 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 1
groupNext(group, groupNext);

Check failure on line 32 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 3 tabs but found 2
}, next);

Check failure on line 33 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 2 tabs but found 1
})

Check failure on line 34 in src/upgrades/1.1.1/upload_privileges.js

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
}

async.eachSeries(cids, (cid, next) => {
privilegesAPI.categories.list(cid, (err, data) => {
if (err) {
return next(err);
}
async.eachSeries(data.groups, (group, next) => {
if (group.name === 'guests' && parseInt(meta.config.allowGuestUploads, 10) !== 1) {
return next();
}
if (group.privileges['groups:read']) {
privilegesAPI.categories.give(['upload:post:image'], cid, group.name, next);
} else {
next();
}
}, next);
});
}, callback);
});
},
};
function groupNext(callback) {
if (group.name === 'guests' && parseInt(meta.config.allowGuestUploads, 10) !== 1) {
return next();
}

if (group.privileges['groups:read']) {
privilegesAPI.categories.give(['upload:post:image'], cid, group.name, next);
} else {
next();
}
}
Loading