Skip to content

Commit

Permalink
fix: dont return flag data to client
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Jan 23, 2020
1 parent 51236df commit 418c174
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/socket.io/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SocketFlags.create = async function (socket, data) {

const flagObj = await flags.create(data.type, data.id, socket.uid, data.reason);
await flags.notify(flagObj, socket.uid);
return flagObj;
return flagObj.flagId;
};

SocketFlags.update = async function (socket, data) {
Expand Down
4 changes: 2 additions & 2 deletions test/controllers-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,10 @@ describe('Admin Controllers', function () {
var socketFlags = require('../src/socket.io/flags');
var oldValue = meta.config['min:rep:flag'];
meta.config['min:rep:flag'] = 0;
socketFlags.create({ uid: regularUid }, { id: pid, type: 'post', reason: 'spam' }, function (err, data) {
socketFlags.create({ uid: regularUid }, { id: pid, type: 'post', reason: 'spam' }, function (err, flagId) {
meta.config['min:rep:flag'] = oldValue;
assert.ifError(err);
request(nconf.get('url') + '/api/flags/' + data.flagId, { jar: moderatorJar, json: true }, function (err, res, body) {
request(nconf.get('url') + '/api/flags/' + flagId, { jar: moderatorJar, json: true }, function (err, res, body) {
assert.ifError(err);
assert(body);
assert.equal(body.reporter.username, 'regular');
Expand Down
6 changes: 1 addition & 5 deletions test/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,7 @@ describe('Flags', function () {

describe('(websockets)', function () {
var SocketFlags = require('../src/socket.io/flags.js');
var tid;
var pid;
var flag;

before(function (done) {
Topics.post({
Expand All @@ -607,7 +605,6 @@ describe('Flags', function () {
title: 'Another topic',
content: 'This is flaggable content',
}, function (err, topic) {
tid = topic.postData.tid;
pid = topic.postData.pid;

done(err);
Expand All @@ -620,8 +617,7 @@ describe('Flags', function () {
type: 'post',
id: pid,
reason: 'foobar',
}, function (err, flagObj) {
flag = flagObj;
}, function (err) {
assert.ifError(err);

Flags.exists('post', pid, 1, function (err, exists) {
Expand Down

0 comments on commit 418c174

Please sign in to comment.