Commit Graph

124 Commits

Author SHA1 Message Date
Barış Soner Uşaklı
069ac60f62 feat: add uid of user who created flag to action:flags.create 2021-03-01 19:02:00 -05:00
Julian Lam
783786cf8c fix: do not blindly escape a notification's bodyLong
For 7+ years we were escaping this value, but it is in many cases already sanitized (as it may be a post content). For those cases when it is not, I now run it through parse.raw.

Instead of escaping, it now strips p, img, and a tags.
2021-02-09 11:16:40 -05:00
Peter Jaszkowiak
5c2f0f0557 chore: eslint no-restricted-syntax 2021-02-08 18:06:44 -05:00
Peter Jaszkowiak
dab3b23575 chore: eslint no-var, vars-on-top 2021-02-08 18:06:44 -05:00
Peter Jaszkowiak
b56d9e12b5 chore: eslint prefer-arrow-callback 2021-02-08 18:06:44 -05:00
Peter Jaszkowiak
707b55b6a5 chore: eslint prefer-template 2021-02-08 18:06:44 -05:00
Julian Lam
1603566bcc fix: filtering logic of flags [breaking]
When combining filters, the old logic assumed that every filter was
exclusive, unless that filter contained multiple items, in which
case it was added to a list of "or" filters that returned all
matching flags.

A fault was discovered in that if you passed in multiple "or"
states, it did not return flags with the expected filtering.

e.g. open flags, closed flags, flags of cid 1, flags of cid 2

This could return open flags of cid 3, since all of the filters
were "OR"'d.

This logic change updates the behaviour so disparate OR sets are
intersected (ANDed).
2021-01-25 11:29:00 -05:00
Julian Lam
6b1c97db79 feat: feature flag for auto-resolving a user's flags on ban [breaking]
The default behaviour has now been changed to 'off'. Going forward, a user's flags will no longer automatically resolve on ban.
2021-01-25 11:07:29 -05:00
Julian Lam
4ede18ce5f fix: broken test caused by errant .pop(), missing await 2021-01-08 14:15:54 -05:00
Julian Lam
6a1311b4bc refactor: flags lib to have a separate getFlagIdsWithFilters method
added quick filter for unresolved flags
2021-01-08 14:15:54 -05:00
Julian Lam
1e7cf1cbc4 fix: #8971, disallow flags of privileged users (mods, gmods, admins) 2020-11-27 11:54:32 -05:00
Barış Soner Uşaklı
b8cafefce2 fix: winston usages 2020-11-26 13:56:34 -05:00
Julian Lam
6e2da9966e refactor: move plugin hook methods to plugin.hooks.* 2020-11-20 16:32:39 -05:00
Barış Soner Uşaklı
a6afcfd531 feat: #8475, allow flagging self posts
dont count flags towards self posts
dont allow flagging your own account
2020-11-17 21:28:32 -05:00
Julian Lam
0c20351702 feat: additional sorting options for flags
+ upvotes, +downvotes, +replies
2020-08-31 17:21:15 -04:00
Barış Soner Uşaklı
354e6ccc66 feat: banning a user will resolve their post flags 2020-08-22 17:34:19 -04:00
Barış Soner Uşaklı
91d9333a50 fix: username, email history disappering if content was deleted 2020-08-22 17:13:26 -04:00
Julian Lam
346db0d84d feat: flags list sorting, closes #8569 2020-08-18 21:03:59 -04:00
Julian Lam
9c70b6620e feat: pass uid into filter:flags.list 2020-08-14 16:27:02 -04:00
Julian Lam
6c00ec8435 refactor: removed rather redundant flag reporters zset 2020-07-31 11:38:05 -04:00
Julian Lam
0f2b6f1ff7 fix: bug; additional reports could be added by the same user repeatedly 2020-07-31 11:38:05 -04:00
Barış Soner Uşaklı
8bd63f61e0 feat: resolve flag on delete/purge/ban/delete account 2020-07-25 18:26:09 -04:00
Barış Soner Uşaklı
af91c26a6f refactor: get rid of bind calls 2020-07-25 09:14:13 -04:00
Julian Lam
55b0e902fb feat: consolidation of flags to reduce flagspam, #8510
Squashed commit of the following:

commit c6d0939620
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 24 13:41:32 2020 -0400

    fix: more tests

commit 32f9af2a87
Merge: e50907535 4eae927d1
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 24 10:53:04 2020 -0400

    Merge remote-tracking branch 'origin/master' into singleton-flags

commit e509075351
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 24 10:52:46 2020 -0400

    fix: controllers-admin test

commit fd5af99e30
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 17 17:26:55 2020 -0400

    fix(tests): dummy commit to trigger travisCI

commit c452a6ffcf
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 17 17:05:09 2020 -0400

    fix(openapi): openapi spec changes

commit 8089a74e89
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 17 15:48:00 2020 -0400

    fix: reversing the order of reports for display purposes

commit a099892b37
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 17 15:45:44 2020 -0400

    refactor: run all flag creation calls in a single batch

commit b24999682f
Author: Julian Lam <julian@nodebb.org>
Date:   Fri Jul 17 15:08:23 2020 -0400

    feat: handling multiple reporters per flag, #8510

commit 08c75c0200
Author: Julian Lam <julian@nodebb.org>
Date:   Thu Jul 16 20:53:18 2020 -0400

    feat: upgrade script for #8510
2020-07-24 14:10:37 -04:00
Julian Lam
e3e55f25d0 refactor: flag sanity checks, +feat: flag limits
- Added new config flag:limitPerTarget, to disallow flags after an item has
  already been flagged x times (default 0, or infinite)
- New zset flags:byTarget, score is the number of times a flag has been made
  against that item
- "already-flagged" translation key removed, now "post-already-flagged" or
  "user-already-flagged" -- this fixed bug where flagging a user you've already
  flagged would tell you you've already flagged this post already.
- Refactored Flags.canFlag to throw errors only, instead of returning boolean
- Updated ACP form inputs for reputation settings page to be more bootstrappy
- +1 upgrade script
2020-07-15 17:10:49 -04:00
Julian Lam
1441720962 feat: logic for flag note editing, #8499 2020-07-14 13:38:28 -04:00
Julian Lam
f85a45c722 feat: logic for flag note deletion, #8499 2020-07-14 13:38:28 -04:00
Barış Soner Uşaklı
e80379dc0e feat: display stack trace on winston.error 2020-06-20 23:32:12 -04:00
Julian Lam
922d49be0b fix(style): switch..case 2020-06-03 11:26:08 -04:00
Julian Lam
cf00cda07c refactor: src/flags.js because codeclimate 2020-05-26 20:40:55 -04:00
Julian Lam
8d995d1eb6 refactor: flags detail page
- Show account moderation history
- Ban and delete quick actions

Squashed commit of the following:

commit 0e782e65f4d48ae814708e510ec9d01bcdd914e0
Author: Julian Lam <julian@nodebb.org>
Date:   Tue May 26 20:24:53 2020 -0400

    fix(deps): use persona 10.1.41/vanilla 11.1.17

commit 369e073d3c3189d8ce181eb3d573489cbe54d4fc
Author: Julian Lam <julian@nodebb.org>
Date:   Tue May 26 20:23:24 2020 -0400

    fix: allow ban and delete exported methods to have cbs

commit b83a086ea31a77ec82d161306c0b9bc115cb2a3a
Merge: 525aae1ea 256ee45d3
Author: Julian Lam <julian@nodebb.org>
Date:   Tue May 26 08:54:25 2020 -0400

    Merge remote-tracking branch 'origin/master' into flags-improvements

commit 525aae1ea2e5d0103028a0f0c8dde05f172d088e
Author: Julian Lam <julian@nodebb.org>
Date:   Tue May 26 08:53:39 2020 -0400

    feat: integrate ban history and username changes to flag history list

commit 3e68ad28ba266f4c8620a676aa7f463f0a9d1df7
Author: Julian Lam <julian@nodebb.org>
Date:   Mon May 25 18:22:53 2020 -0400

    feat: allow ban and deletion from flag details page

commit a559ea1d8e8883385c2876868d855a0b93516c54
Author: Julian Lam <julian@nodebb.org>
Date:   Mon May 25 18:22:00 2020 -0400

    feat: export banAccount and deleteAccount methods from accounts module
2020-05-26 20:27:16 -04:00
Barış Soner Uşaklı
5ebcdb1806 fix: #8287, fix users:flags as well 2020-05-02 15:34:58 -04:00
Barış Soner Uşaklı
0391856d7d fix: #8286, rescind notif when its resolved/rejected 2020-05-01 13:32:20 -04:00
Julian Lam
ccc6118d30 Testing suite integration for openapi spec (#8263)
* feat: testing suite integration for openapi spec

The testing suite now takes the openapi spec into account. It will
check each route defined, make a call to it, and compare the
response with the defined schema. Any mismatches will cause the
test to fail.

* fix(openapi): removed debug stuff from tests

* fix(openapi): fixed some tests

* fix(openapi): added additional check to tests, test fixes

* fix(openapi): better tests, fixed spec errors

* fix(openapi): bad conditional in test

* fix: oops

* fix(openapi): more tests fixing

* fix(openapi): more tests

* fix(openapi): fix some more tests

* fix: verbose'd an info log

* fix: topic pagination route returns schema-optimized pagination block

* fix(openapi): more test/spec fixes

* fix(openapi): accidentally sending in authenticated jar for anon routes

* fix(openapi): more test/spec fixes

* fix(openapi): more spec fixes

* fix: timestampReadable Invalid Date

* fix(openapi): more tests... almost there

* fix(openapi): more tests fixing

* fix(openapi): finally all tests passing

* fix(openapi): added reverse test to compare response to spec

... and fixed all the tests that broke

* fix: remove tests related to group covers, as route is gone

* fix(openapi): broken test on travis

* fix(openapi): broken test on travis

* fix(openapi): broken test on travis

* fix(openapi): object cache is not present for psql

* fix: tests

Co-authored-by: Barış Soner Uşaklı <barisusakli@gmail.com>
2020-04-23 21:50:08 -04:00
Barış Soner Uşaklı
51236df4ed fix: check if user has read priv before flagging 2020-01-22 12:14:50 -05:00
Julian Lam
8e5a2276af feat: check flag values on save (assignee and state) (#8122)
* feat: add assignee checking when updating flag

Prior to this, it was possible to update the assignee to any value (or
any user. This commit adds checking to allow only admins, global
moderators, or in the case of flagged posts, moderators.

Also some prep work was added for value checking `state`.

* feat: value checking `state` on flag update

The state should be one of the constants defined earlier in the file.
2020-01-20 10:19:23 -05:00
Baris Usakli
2150701f32 fix: missing await 2019-09-28 15:08:51 -04:00
Baris Usakli
ac6eb31c69 refactor: async/await flags.js 2019-09-28 14:37:50 -04:00
Barış Soner Uşaklı
0ced71be39 refactor: async/await flags 2019-09-26 22:51:11 -04:00
Baris Usakli
a651d154ce fix: #7921, dont create wrong entries in db for flag
upgrade script to remove wrong entries
2019-09-24 12:22:40 -04:00
Barış Soner Uşaklı
e32a55460f refactor: remove logs 2019-09-24 00:36:42 -04:00
Barış Soner Uşaklı
9ee1a882ec refactor: async/await flags 2019-09-24 00:30:59 -04:00
Julian Lam
0921230976 fix(style): updated code to follow new eslint recommendations
Squashed commit of the following:

commit f9ce878b26
Author: Julian Lam <julian@nodebb.org>
Date:   Tue Aug 13 14:30:46 2019 -0400

    fix(style): updated code to follow new eslint recommendations

commit 80dd370e41
Author: Julian Lam <julian@nodebb.org>
Date:   Tue Aug 13 14:14:58 2019 -0400

    fix(deps): update dependency sitemap to v4

    Squashed commit of the following:

    commit f4dd9cabb2
    Author: Julian Lam <julian@nodebb.org>
    Date:   Tue Aug 13 11:33:05 2019 -0400

        fix: resolved breaking changes from sitemap v4 upgrade

    commit 9043415ee1
    Merge: e3352b272 72590b346
    Author: Julian Lam <julian@nodebb.org>
    Date:   Tue Aug 13 11:09:55 2019 -0400

        Merge branch 'master' into renovate/sitemap-4.x

    commit e3352b272e
    Author: Renovate Bot <bot@renovateapp.com>
    Date:   Mon Aug 12 07:59:05 2019 +0000

        fix(deps): update dependency sitemap to v4

commit 8e3c0cdcae
Author: Renovate Bot <bot@renovateapp.com>
Date:   Fri Aug 9 00:49:51 2019 +0000

    fix(deps): update dependency commander to v3

commit 2104449d38
Author: Renovate Bot <bot@renovateapp.com>
Date:   Tue Aug 13 15:00:27 2019 +0000

    fix(deps): update dependency mongodb to v3.3.0

commit d2937f446a
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Tue Aug 13 10:36:48 2019 -0400

    feat: async/await admin/controllers

commit 1b97e8b199
Author: Misty (Bot) <deploy@nodebb.org>
Date:   Tue Aug 13 09:28:39 2019 +0000

    Latest translations and fallbacks

commit 69a48957a2
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Mon Aug 12 21:56:09 2019 -0400

    feat: async/await

commit b9b2a7e593
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Mon Aug 12 20:58:29 2019 -0400

    feat: async/await refactor

    controllers/accounts

commit a8d43a1759
Author: Baris Usakli <barisusakli@gmail.com>
Date:   Mon Aug 12 14:49:40 2019 -0400

    feat: async/await controllers/accounts

commit 2f25aae57b
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Sun Aug 11 23:09:50 2019 -0400

    fix: #7831, fix pagination

    convert to async/await

commit c9e83f2374
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Sun Aug 11 00:14:35 2019 -0400

    fix: remove empty line

commit 30be91b26c
Author: Barış Soner Uşaklı <barisusakli@gmail.com>
Date:   Sun Aug 11 00:13:41 2019 -0400

    fix: remove useless catchs and empty line

commit 2e4a71c0b6
Author: Renovate Bot <bot@renovateapp.com>
Date:   Sat Aug 10 06:51:50 2019 +0000

    chore(deps): update dependency eslint-config-airbnb-base to v14
2019-08-13 15:12:27 -04:00
Barış Soner Uşaklı
0d047f4eb9 feat: #7743, webserver 2019-07-22 18:16:18 -04:00
Barış Soner Uşaklı
7b95ebbb6a fix: #7748, if reputation system is disabled, dont check min reputation 2019-07-11 09:54:46 -04:00
Julian Lam
91f0bce628 fix: #7624, default open state on stateless flags 2019-05-21 12:23:19 -04:00
Barış Soner Uşaklı
81aa3a0b8a fix: don't crash in flags.validate if user blocked target 2018-12-09 15:25:43 -05:00
Julian Lam
d027207f88 fix: flags detail page crash if reporter blocks author
Fixed an issue where the flags detail page would crash if the
reporting user flagged a post and then proceeded to block the
post author.

Retrieval of a flag's target data should be irrespective of
block status.

fixes #6925
2018-11-08 13:43:45 -05:00
Barış Soner Uşaklı
f3a679e268 remove parseInts 2018-10-25 17:02:59 -04:00
Barış Soner Uşaklı
9c022afae1 Parse int (#6853)
* Store config fields as JSON in the db

Fewer parseInts

* Remove unnecessary parseInts

* remove some dupe code add tests

* remove console.log

* remove more parseInts

* WIP: read meta.configs defaults from defaults.json

remove more parseInts

* more work

* add log for failing test

* update admin pwd

* fix tests, dont require posts/cache before configs are initialized

* handle saves

* Test boolean conditions

* remove more parseInts

* Fix boolean values

* remove lots more parseInts

* removed json parsing

* renamed var to number

* categories dont have timestamp
2018-10-21 16:47:51 -04:00