Commit Graph

911 Commits

Author SHA1 Message Date
Bart Enkelaar
234258b41e Move from deprecated moment#zone to moment#utcOffset (#12207)
* Issue 10209 - Remove read usages of zone

* Issue 10209 - Add coverage on daysSince and startOfDay cron utility functions

* Issue 10209 - Add unit test for daysUserHasMissed method

* Issue 10209 - Remove usages of deprecated `moment.js#zone` method.

* Issue 10209 - Add helper function to centralise logic

Also simplify timezoneOffsetToUtc function in site.vue

* Issue 10209 - Also add getUtcOffset as method on user

Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
2020-07-25 13:22:41 +02:00
Matteo Pagliazzi
fef9c74f9b Merge branch 'release' into develop 2020-07-19 18:26:48 +02:00
Matteo Pagliazzi
fd7c5b3847 feat(members): allow to fetch up to 60 members at all (#12400) 2020-07-19 18:25:46 +02:00
Amber
ead0b6c56f PR to fix: Disallow line breaks in display names (#12380)
* Update settings.json

* Update index.js

* Update validation.js

* Update validation.js

* Update validation.js

Removes the second check

* Update tests and validation

Added tests, and updated validation
2020-07-18 22:41:19 +02:00
Matteo Pagliazzi
f5e4e2150a fix(tests): remove exclusive unit test 2020-07-18 15:00:31 +02:00
Matteo Pagliazzi
6743dcb08a fix(cors): expose rate limit headers to clients 2020-07-18 15:00:23 +02:00
Matteo Pagliazzi
e7c8833c9a API v3 Rate Limiter (#12117)
* simplify ip address management by using the trust proxy express option

* add setupExpress file

* fix redirects middleware tests

* fix lint

* short circuit the ip blocking middleware

* basic implementation with ip based limiting

* improve logging

* upgrade apidoc

* apidoc: add introduction section

* fix lint

* fix tests

* fix lint

* add unit tests for rate limiter

* do not send retry-after header when points are available

* automatically fix lint

* fix more lint issues

* use userId as key for rate limit when available
2020-07-18 15:00:09 +02:00
Matteo Pagliazzi
4de5140cf7 fix(tests): remove exclusive unit test 2020-07-17 19:14:02 +02:00
Matteo Pagliazzi
7de5a51247 fix(cors): expose rate limit headers to clients 2020-07-17 19:00:16 +02:00
Matteo Pagliazzi
f1173cee6a API v3 Rate Limiter (#12117)
* simplify ip address management by using the trust proxy express option

* add setupExpress file

* fix redirects middleware tests

* fix lint

* short circuit the ip blocking middleware

* basic implementation with ip based limiting

* improve logging

* upgrade apidoc

* apidoc: add introduction section

* fix lint

* fix tests

* fix lint

* add unit tests for rate limiter

* do not send retry-after header when points are available

* automatically fix lint

* fix more lint issues

* use userId as key for rate limit when available
2020-07-17 16:13:51 +02:00
Matteo Pagliazzi
c93bf3e498 MongoDB Transactions (#12335)
* add run-rs to dependencies

* wip: add replica set to api unit github action

* wip: add replica set to api unit github action

* wip: fix gh actions mongodb replica set setting

* usa replica set for integration tests

* add correct mongodb version matrix for integration tests

* use different db connection on gh actions

* Revert "use different db connection on gh actions"

This reverts commit aa8db759d3.

* add example transaction

* add mongo script to package.json

* abstract mongodb utils, connect using hostname on windows

* npm scripts: mongo -> mongo:dev

* add setup script for run-rs on windows

* gh actions: run in test environment

* remove test files

* better error handling, use cross-spawn to avoid issues on windows

* fix lint
2020-07-14 18:55:47 +02:00
PitiTheGrey
e89ff95a21 Add Bulk Feed via query parameter (#12384)
* Update feed.js

New Tests for bulk feeding

* Update POST-user_feed_pet_food.test.js

Added test for bulk-feeding

* Update user.js

Added 'query paramter' for bulk feeding

* Update pets.json

Added "tooMuchFood" for bulk feeding pets

* Update feed.js

Added query parameter option for bulk feeding pets.

* Update feed.js

fixing lint
(bulk feeding)

* Update POST-user_feed_pet_food.test.js

adjustments for testing bulk feeding

* Update feed.js

Bulk feeding 
amount as integer

* Update pets.json

added invalidAmount for bulk feeding

* Update feed.js

Bulk feeding  
Error handling

* Update feed.js

Bulk - feed  
no hardcoded values

* Update pets.json

Get rid of my german accent.
2020-07-13 16:04:03 +02:00
Jalansh
a02c4c1cfd WIP. Accepting a redundant party invite will not remove the user from the party and let the user still be a part of it. Fixes #12291. (#12356)
* Getting the latest code

* Temporary fix for Redundant Party Invite. Needs changes.

* Added logic to check if the user is an existing member of the party that the user is invited to.

* Added a test case for redundant party invite check.

* Changed the test case for redundant party invite to see if it runs successfully.

* Made changes to the test cases.

* Fixed lint errors.

* Removed the exclusive mocha test.

* Referred the issue in the name of the new test case.

* Modified test case to check its veracity.

* Checking if the update statement is working or not.
2020-07-13 16:00:34 +02:00
Matteo Pagliazzi
d861236f44 fix(cors): allow authorization header 2020-07-12 18:22:52 +02:00
tsukimi2
a388abc124 Added code to update user tag list along with the existing code that already involves updating the user documents of challenge members (#12312)
* Piggybacking the updating of user tag list.

When a new task is being added to a challenge, added code to update user tag list along with the existing code that already involves syncing / updating the user documents of challenge members.

* Update comment on number of simulatenaeous users to be updated concurrently in TaskQueue.

* Added comment to explain previous commit caaca469f8 (Update comment on number of simulateneous users to be updated concurrently in TaskQueue)

* Added unit tests for testing commit caaca469f8 (Update comment on number of simulateneous users to be updated concurrently in TaskQueue)

* Removed unused lines from newly added test cases

* Implemented lint suggestions

* Update code with changes requested in PR
2020-07-03 21:55:59 +02:00
Robert Whitaker
af1d13d3a2 Fix bug where updated webhook options failed to save (fixes #12336) (#12342)
* Fix bug where updated webhook options failed to save

This bug was caused by Mongoose not creating getters/setters for array
elements (https://mongoosejs.com/docs/faq.html#array-changes-not-saved).
So, although the webhook was being updated properly, Mongoose was not
actually committing it to the database. Telling Mongoose that the array
of webhooks has changed via `markModified` fixes the issue.

Additionally, the relevant API test case was only checking whether or
not the webhook returned from the PUT endpoint matched the expected
update. Since the endpoint was returning the updated webhook without
querying the database again, this test case would pass. It has been
updated to check both the returned webhook as well as the version of the
webhook that is saved to the database against the expected. In other
words:

`assert returned === saved === expected`

Fixes #12336

* Call markModified on webhook.options instead of user.webhooks

This tells Mongoose that only the modified webhook's options changed
instead of telling it that the entire user.webhooks array changed,
saving a costly DB update.
2020-07-03 16:48:45 +02:00
Matteo Pagliazzi
3d5630d5a2 chore: update sub-deps and fix lint 2020-07-01 18:20:18 +02:00
negue
5e2bfc2c2f added tests: if collapseChecklist is allowed and all others are still blocked (#12337)
* tests: test if collapseChecklist is allowed and all others are still blocked

* fix lint
2020-06-26 19:05:41 +02:00
Matteo Pagliazzi
359ef47ce7 fix(get tasks): improve tests and add ability to fetch group tasks (#12339) 2020-06-26 16:50:49 +02:00
Matteo Pagliazzi
ba16fa6854 Upgrade Server Deps (#12328)
* upgrade uuid

* upgrade gulp-imagemin

* upgrade bcrypt

* upgrade validator.js

* fix uuid import

* upgrade got

* upgrade sinon

* upgrade passport-google-oauth2

* fix unit test
2020-06-22 11:51:52 +02:00
Bart Enkelaar
1c00d7de5b Fix empty link bug and proper error logging in highlightMentions.js (#12228)
* fix(chat) - Don't insert user link in url-less link and properly log source-mapping failures

* fix(chat) - Add link to markdown spec and list of known issues

* fix(chat) - Log regular expression as String
2020-05-31 18:09:43 +02:00
Bart Enkelaar
26f5bf554e fix(chat) - graceful for failure and fix link regex (#12225)
* fix(chat) - graceful for failure and fix link regex

* fix(chat) - Adjust unit test to test for the actual functional failure
2020-05-21 18:00:58 +02:00
Bart Enkelaar
85d290a1fa fix(chat) - Issue 12217 - Allow url-escapable characters in links. (#12218) 2020-05-19 17:28:55 +02:00
Sabe Jones
4c7306491b Merge branch 'develop' into release 2020-05-14 14:03:09 -05:00
Matteo Pagliazzi
092d6726b8 fix(subscriptions): use correct termination date field and add extra check when it is missing 2020-05-14 12:56:12 +02:00
Bart Enkelaar
ef99943646 Don't break up links with user profile link injections (#12100)
* Issue 10924 - Don't break up links with mention links

* Issue 10924 - Recognise links between brackets.

* Issue 10924 - Rely on markdown parser for link determination

* Issue 10924 - Only increment index once in findTextBlocks
2020-05-09 19:37:08 +02:00
Sabe Jones
446122d7b8 To-Do cron task decay fixes (#12072)
* fix(tasks): improve some cron behaviors
Fixes #6488
Fixes #8590

* add test

Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
2020-05-05 18:52:44 +02:00
Bart Enkelaar
93335352ec Dont throw away extra paypal months (#12149)
* Issue 10605 - Don't pointlessly format dates

* fix(10605): Be defensive about setting plan termination dates
2020-05-05 17:16:35 +02:00
negue
1c94c1a968 fix: return full inbox on user-v3-api (#12146)
* fix inbox on user-v3-api + test

* add @benkelaar suggestions
2020-05-02 21:48:16 +02:00
negue
26767f598b API: Adding secret.text to the user-schema (#12121) 2020-05-02 19:59:05 +02:00
Matteo Pagliazzi
9f91775e78 fix(unit tests): re add code removed by mistake in stringUtils tests 2020-04-28 17:00:57 +02:00
Matteo Pagliazzi
61ca931e66 fix(string utils): do not escape possible regular expressions 2020-04-28 16:47:52 +02:00
Bart Enkelaar
66ed0a350b Issue 12138 - Fix chat support for regex chars in code blocks 2020-04-27 13:56:27 +02:00
Bart Enkelaar
dc9800d88a Don't bill (subtract gems) multiple times for multiple unlock item set calls (#12116)
* Issue 11050 - Small tuneups to unlock.js

- Use includes i.o. indexOf
- Extract small function for object setting duplication
- Use every instead of custom counter

* Issue 11050 - Properly store purchased items when purchasing them

* Issue 11050 - Couple more tuneups in unlock.js and implemented partial failure scenario

* Issue 11050 - Fix last lint issue

* Issue 11050 - Check path for gear i.o. failing to write it to purchased

* Issue 11050 - Guarantee variation coverage in tests

* Issue 11050 - Use startsWith instead of includes for background check

* Issue 11050 - Don't unlock lost items
2020-04-24 16:16:34 +02:00
Matteo Pagliazzi
188023b197 fix #12118: pass mandatory second parameter to markdown-it parse method 2020-04-24 12:06:05 +02:00
Matteo Pagliazzi
4fa381f153 Merge branch 'bugfix-extramonths-lost-when-subscription-terminated' of https://github.com/hamboomger/habitica into hamboomger-bugfix-extramonths-lost-when-subscription-terminated 2020-04-20 23:30:19 +02:00
Matteo Pagliazzi
97209e40ad Collection quests: make sure users cannot earn "excess" items (#12098)
* fix(collection quests): make sure users cannot earn "excess" collection items

* add test
2020-04-20 23:12:05 +02:00
Matteo Pagliazzi
8ca5ee99b0 Merge branch 'release' into develop 2020-04-18 16:09:40 +02:00
Matteo Pagliazzi
9364cdc2b4 fix(apple auth): do not try to parse name if it is missing, add query parameters to logs 2020-04-18 16:02:18 +02:00
Carl Vuorinen
2896cf77e0 Handle simultaneous quest accept/reject (#12090)
* Implement atomic quest accept/reject

* Persist quest.members early to avoid simultaneous handling of accept/reject

* Fix quest accept test (missing expectation)

* PR fixes
2020-04-17 22:57:31 +02:00
Bart Enkelaar
9608b9fa9f Don't link user in markdown code blocks - Fixes #[11504] (#12069)
* Improve whitespacing in highlightMentions.js unit test

* Issue 11504 - Don't link users in markdown code blocks

Use the markdown-it parser to determine what parts of the message are code block first.
Then work from those parser tokens back to content parts that should not be handled.

Still convoluted, but can be improved once a "user mention plugin" is added to habitica-markdown.

* Issue 11504 - Put functions in JavaScript order and fix linting issues

* Issue 11504 - Use includes i.o. multiple or checks and added some context.

* Issue 11504 - Add docstring for highlightMentions and simplify fence regex

* Issue 11504 - Replace inline recursor with default parameter value
2020-04-17 22:19:11 +02:00
Matteo Pagliazzi
24e1bfdfba add basic test, disable etag on post routes as well, paypal ipn: prevent set headers after response error 2020-04-17 14:50:09 +02:00
Denys Dorokhov
186b929e59 API-v4 route added: 'api/v4/faq' fixes #11801 (#11905)
* feat(api-v4): new /faq route added

* refactor(server): change of function name in libs/content.js
2020-04-14 22:14:53 +02:00
Matteo Pagliazzi
2a8fc7aea2 Push Notifications Improvements (#12019)
* start fixing push notitifications

* push notifications: refactor error handling

* remove comment and improve logging

* improve emails errors

* wip: start improving webhooks tests

* add max length to push notifications and tests

* fix typos
2020-04-10 16:41:44 +02:00
Phillip Thelen
9d16ab7dba Sign in with Apple (#11793)
* add date check

* achievements modal polishing

* refresh private-messages page when you are already on it

* add countbadge knob to change the example

* fix lint

* typos

* typos

* typos

* add toggle for achievements categories

* typo

* fix test

* fix edit avatar modal cannot be closed

* WIP(settings): subscriber page improvements

* WIP(subscriptions): more design build-out

* fix(css): disabled button styles

* fix(css): better Amazon targeting

* fix hide tooltip + align header correctly

* disable perfect scroll

* load messages on refresh event

* fix header label + conversation actions not breaking layout on hover

* WIP(g1g1): notif

* WIP(g1g1): notif cont'd

* fix(test): snowball change

* fix(event): feature NYE card

* chore(sprites): compile

* fix(bgs): include TT required field

* add gifting banner to the max height calculation

* chore(event): enable winter customizations

* WIP(gifting): partial modal implementation

* feat(gifting): select giftee modal

* fix(gifting): notification order, modal dismiss

* Begin implementing sign in with apple

# Conflicts:
#	package-lock.json
#	website/common/script/constants.js
#	website/server/libs/auth/social.js
#	website/server/models/user/schema.js

* Add apple sign in button to website

* fix lint errors

* fix config json

* fix(modals): correct some repops

* fix(gifting): style updates

* fix(buy): modal style changes

* fix(modals): also clean out "prev"

* Attempt workaround for sign in with apple on android

* temporarily log everything as error

* refactor(modals): hide in dismiss event

* fix temporary test failure

* changes to sign in with apple

* fix: first batch of layout issues for private messages + auto sizing textarea

* fix(modals): new dismiss logic

* fix(modals): new dismiss no go??

* Only use email scope

* print debugging

* .

* ..

* ...

* username second line - open profile on face-avatar/conversation name - fix textarea height

* temporarily disable apple auth and just return data for debugging

* Hopefully this works

* .....

* WIP(subscription): unsubscribed state

* .

* ..

* MAYBE THIS ACTUALLY WORKS???

* Implement apple sign in

* fix some urls

* fix urls

* fix redirect and auth

* attempt to also request name

* fix lint error

* WIP(subscription): partial subscribed

* chore(sprites): compile

* Change approach so that it actually works

* fix config error

* fix lint errors

* Fix

* fix lint error

* lint error

* WIP(subscription): finish subscribed

* refresh on sync

* new "you dont have any messages" style + changed min textarea height

* new conversationItem style / layout

* reset message unread on reload

* chore(npm): update package-locks

* fix styles / textarea height

* feat(subscription): revised sub page RC

* list optOut / chatRevoked informations for each conversation + show why its disabled

* Improve apple redirect view

* Fix apple icon on group task registration page

* WIP(adventure): prereqs

* Block / Unblock - correct disabled states - $gray-200 instead of 300/400

* canReceive not checking chatRevoked

* fix: faceAvatar / userLink open the selected conversation user

* check if the target user is blocking the logged-in user

* fix(subs): style tweaks

* fix(profiles): short circuit contributor
Attempted fix for #11830

* chore(sprites): compile

* fix(content): missing potion data

* fix(content): missing string

* WIP(drops): new modal

* fix(subs): moar style tweaks

* check if blocks is undefined

* max-height instead of height

* fix "no messages" state + canReceive on a new conversation

* WIP(adventure): analytics fixes etc

* Improve apple signin handling

* fixed conversations width (280px on max 768 width page)

* feat(adventure): random egg+potion on 2nd task

* fix(lint): noworkies

* fix(modal): correctly construct classes

* fix(tests): expectations and escape

* Fix typo

* use base url from env variables

* fix lint

* call autosize after message is sent

* fix urls

* always verify token

* throw error when social auth could not retrieve id

* Store emails correctly for apple auth

* Retrieve name when authenticating through apple

* Fix lint errors

* fix all lint errors

* fix(content): missing strings

* Revert "always verify token"

This reverts commit 8ac40c76bf.

# Conflicts:
#	website/server/libs/auth/social.js

* Correctly load name

* remove extra changes

* remove extra logger call

* reset package and package-lock

* add back missing packages

* use name from apple

* add support for multiple apple public keys

* add some unit and integration tests

* add apple auth integration test

* tweak social signup buttons

* pixel pushing

Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
Co-authored-by: Sabe Jones <sabrecat@gmail.com>
Co-authored-by: negue <eugen.bolz@gmail.com>
Co-authored-by: Phillip Thelen <phillip@habitica.com>
2020-04-08 18:44:30 +02:00
hamboomger
b7448e2cfe fix(server-api): cancelSubscription() is no longer called twice when user leaves group 2020-04-05 15:06:16 +03:00
hamboomger
0bc836b490 refactor(payments): unit tests created for calculation of subscription termination date 2020-04-05 15:06:16 +03:00
hamboomger
00d12e83bd refactor(db-schema): group.isSubscribed() method name changed to group.hasActiveGroupPlan() 2020-04-05 15:06:16 +03:00
Matteo Pagliazzi
28bc843779 Misc Webhooks Fixes (#12038)
* fix(webhooks): don t parse response as json

* upgrade got to version 10

* remove old header

* fix tests

* fix email auth

* add migration

* update email error

* split migration in two
2020-04-02 21:48:47 +02:00
Matteo Pagliazzi
e92ff9737a Automatically Logout Banned Users (#12037)
* wip

* logout banned users, fix and refactor language library and middleware

* req.locals -> res.locals

* fix tests

* redirect to login page
2020-04-02 21:46:01 +02:00