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

Api v3 groups chat clear flags #6570

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
482 commits
Select commit Hold shift + click to select a range
9adfd63
fix merge conflict
paglias Nov 27, 2015
7d53a4f
port task model to es6 and implement discriminators
paglias Nov 27, 2015
cfa776f
starts fixing default tasks and use discriminator
paglias Nov 27, 2015
58d8788
fix linting
paglias Nov 27, 2015
90d7f1f
improve tasks models, fix a part of user pre save, rename auth contro…
paglias Nov 28, 2015
786845e
fix tour/tutorial on signup
paglias Nov 28, 2015
6c90433
misc fixes, add createTask route and ability to get tasks by type to …
paglias Nov 28, 2015
c2dac2c
fix import paths
paglias Nov 28, 2015
454aa37
add tasks to user.tasksOrder or creation
paglias Nov 28, 2015
6849fd4
add ability to remove a task
paglias Nov 29, 2015
5291753
prevent the deletion of challenge tasks
paglias Nov 29, 2015
3002db3
add ability to update tasks, can pass additional fields to Model.sani…
paglias Nov 29, 2015
ebdfe4c
add checklists routes
paglias Nov 30, 2015
1bd794b
simplify tasks naming
paglias Nov 30, 2015
67bcfde
implement move task
paglias Nov 30, 2015
93fcc79
fix trying to move completed todos
paglias Nov 30, 2015
fde47bd
add ability to get completed todos (only 30 for now)
paglias Nov 30, 2015
427c805
fix user tests and misc changes
paglias Dec 2, 2015
62708d4
cleanup
paglias Dec 2, 2015
506609c
starts writing tests for tasks, fix errors in auth middleware and tas…
paglias Dec 3, 2015
c0a99ee
fix user model, sanitize some fields on task creation, add some tests…
paglias Dec 3, 2015
a6648fc
add tags routes, misc fixes
paglias Dec 3, 2015
1e9386f
create model for tags, add routes
paglias Dec 4, 2015
c2ba90a
tests(fix): Add return to expect promise in create task test
crookedneighbor Dec 4, 2015
b0bcfff
tests(tasks): Add pending tests for create task test
crookedneighbor Dec 4, 2015
49cc6db
tests(tasks): Rename test to conform to route style
crookedneighbor Dec 4, 2015
1a2cda0
tests: Add additional pending tests
crookedneighbor Dec 4, 2015
5aca166
tests: Add delete task integration test for v3
crookedneighbor Dec 4, 2015
431fc57
tests: Add pending tests for getting a specific task in v3
crookedneighbor Dec 4, 2015
834ae12
tests: Add pending test for GET /tasks
crookedneighbor Dec 4, 2015
8a872bd
tests: Add pending tests for scoring tasks
crookedneighbor Dec 4, 2015
cb08c38
misc fixes, add tests for some tasks routes
paglias Dec 6, 2015
955b0f0
fix tests
paglias Dec 6, 2015
dc5a1d1
Merge pull request #6309 from HabitRPG/api-v3-tasks
paglias Dec 6, 2015
582aeaf
Merge branch 'develop' into api-v3
paglias Dec 6, 2015
66a675c
simplify some tests, replace tags when updating tags (like for checkl…
paglias Dec 6, 2015
af1946d
starts implementing scoreTask
paglias Dec 6, 2015
0272a36
finish implementing tests for POST-tasks.test.js
paglias Dec 7, 2015
3c44916
finish PUT-tasks_id tests and fix some edge bugs
paglias Dec 7, 2015
237be08
GET-tasks_id tests
paglias Dec 7, 2015
72b2791
refactor scoreTask
paglias Dec 8, 2015
0f3b307
port tests for score and randomDrop
paglias Dec 9, 2015
6a0f956
begins testing score task route
paglias Dec 9, 2015
9ffa0d5
port cron and preening
paglias Dec 10, 2015
501a808
move cron logic back to common
paglias Dec 11, 2015
e6d9c97
change score task route
paglias Dec 11, 2015
a34f41f
misc fixes, GET user (with tests), more comments for preenHistory
paglias Dec 13, 2015
9394fb0
use res.respond
paglias Dec 13, 2015
65bb655
Merge branch 'develop' into api-v3
crookedneighbor Dec 13, 2015
850aeb6
Merge branch 'develop' into api-v3
crookedneighbor Dec 13, 2015
409102a
wip score tests
paglias Dec 13, 2015
f4af730
tests(helpers): Fix local doc update
crookedneighbor Dec 14, 2015
c20617e
tests(apiv3): Remove unused dependency
crookedneighbor Dec 14, 2015
ac61809
tests(apiv3): Remove user dependency
crookedneighbor Dec 14, 2015
9205f01
tests(apiv3): Use lessThan and greaterThan expectation syntax
crookedneighbor Dec 14, 2015
3857316
fix(api): Correct sendTaskWebhook call
crookedneighbor Dec 14, 2015
6709c83
tests(apiv3): Remove incorrect tests
crookedneighbor Dec 14, 2015
1557199
remove user.tasks getter on the server
paglias Dec 14, 2015
9864b8a
tests for tags
paglias Dec 14, 2015
da154d3
tests for tags (missed some files before)
paglias Dec 14, 2015
e547eb2
add tests for tags ops on tasks
paglias Dec 14, 2015
13cbf03
use cron middleware
paglias Dec 15, 2015
a46fa87
disable common tests for api v3
paglias Dec 16, 2015
cc7bd1b
disable server_side (api v2) tests for api v3
paglias Dec 16, 2015
d9e786e
checklists tests
paglias Dec 16, 2015
35316eb
move completed todos outside of tasksOrder (and back) with tests
paglias Dec 16, 2015
2e5c7df
Merge pull request #6343 from HabitRPG/api-v3-tasks2
paglias Dec 16, 2015
bf7fc98
begins porting group model to es6
paglias Dec 16, 2015
455eaf0
add skeleton for groups controller
paglias Dec 16, 2015
bbc47f5
finish porting group model
paglias Dec 17, 2015
18c4949
fixes tests
paglias Dec 17, 2015
21f93c9
WIP(chat): v3 controller
SabreCat Dec 16, 2015
c3b981d
test(api): chat WIP
SabreCat Dec 17, 2015
c7b3e3c
fix(test): Remove only
SabreCat Dec 17, 2015
c1daada
do not store members or invitations on group doc
paglias Dec 18, 2015
ddf77e0
add cliff for completed todos and PMs
paglias Dec 18, 2015
e53bd50
adapt chat routes to groups saved on user model
paglias Dec 18, 2015
7adc060
add GET group
paglias Dec 18, 2015
6b430e6
add getGroup static method and refactor controllers to use it
paglias Dec 18, 2015
1132e39
initial implementation for GET groups
paglias Dec 18, 2015
c4ea3ef
initial implementation for POST group
paglias Dec 18, 2015
d8fae3a
add sanitization to group creation
paglias Dec 18, 2015
33525b1
Added initial group POST tests
TheHollidayInn Dec 19, 2015
ba22575
Merge pull request #6380 from TheHollidayInn/thehollidayinn/api-v3-gr…
paglias Dec 19, 2015
3e87c8d
fix some tests
paglias Dec 19, 2015
8b79f74
fix tests
paglias Dec 19, 2015
83364c1
add leaveGroup, joinGroup and remove member from group methods
paglias Dec 21, 2015
99be74b
misc fixes
paglias Dec 21, 2015
67da5a9
test(chat): user not member of group
SabreCat Dec 21, 2015
a48ece7
fix(test): return functions
SabreCat Dec 21, 2015
77414ca
Added chat post route and initial tests
TheHollidayInn Dec 22, 2015
dff4644
Added chat like route and tests
TheHollidayInn Dec 25, 2015
54109f0
Removed redundant code and changed like route to return only altered …
TheHollidayInn Dec 27, 2015
6ae2c5f
wip on groups controller
paglias Dec 27, 2015
831c8c4
Merge branch 'api-v3-groups' of github.com:HabitRPG/habitrpg into api…
paglias Dec 27, 2015
20092f3
port challenge model
paglias Dec 28, 2015
01e2bb5
port getChallenges
paglias Dec 28, 2015
ba0fb88
port create challenge
paglias Dec 28, 2015
488685c
typo
paglias Dec 28, 2015
ceb2074
fix an import
paglias Dec 28, 2015
b3feb99
Change group save to Group update, added flags route and tests, and m…
TheHollidayInn Dec 28, 2015
9748ffb
add updateGroup route
paglias Dec 28, 2015
cb388ee
Ensured that only one like or flag is updated during query
TheHollidayInn Dec 28, 2015
2750446
Updated POST like route to persist data between updates
TheHollidayInn Dec 29, 2015
ad58a77
Merge pull request #6393 from TheHollidayInn/api-v3-chat-post
paglias Dec 29, 2015
547e8a0
cleanup group model
paglias Dec 29, 2015
565d5f0
Merge branch 'api-v3-groups' of github.com:HabitRPG/habitrpg into api…
paglias Dec 29, 2015
71a910c
temporary fix for eslint
paglias Dec 29, 2015
bce049a
Merge branch 'develop' of github.com:HabitRPG/habitrpg into api-v3
crookedneighbor Dec 29, 2015
ae9ec63
Merge branch 'develop' into api-v3
crookedneighbor Dec 29, 2015
a44090e
Merge branch 'api-v3' into api-v3-groups
paglias Dec 29, 2015
61fc490
port challenges\' tasks scoring
paglias Dec 29, 2015
411bfe1
Fix GET chat tests stopping execution of other tests
KristianTashkov Dec 29, 2015
6003dad
misc fixes, port challenge task scoring, delete chal and select winner
paglias Dec 29, 2015
08e0c67
refactor pushNotifications
paglias Dec 29, 2015
8361afc
Merge pull request #6412 from KristianTashkov/fix-api-v3-tests
paglias Dec 29, 2015
a5aeb69
allow getGroup to optionally work for groups where the user is not a …
paglias Dec 29, 2015
24f1b8c
Merge branch 'api-v3-groups' of github.com:HabitRPG/habitrpg into api…
paglias Dec 29, 2015
eab15a3
tests(api): Port over new integration helper from develop
crookedneighbor Dec 30, 2015
a662d4b
Merge branch 'develop' into api-v3
crookedneighbor Dec 30, 2015
ca1513a
tests(api): Use new user['HTTP_METHOD'] for v3 integration tests
crookedneighbor Dec 30, 2015
cd9fe5f
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Dec 30, 2015
dc3407e
tests(api): Convert groups tests to use user['HTTP_METHOD'] syntax
crookedneighbor Dec 30, 2015
59b8ba0
add TODOs to tavern creation
paglias Dec 30, 2015
25b0c3b
porh auth controller to es7 async functions
paglias Dec 30, 2015
f76c9d0
remove comments
paglias Dec 30, 2015
aebe2fa
finish porting to async/away syntax
paglias Dec 31, 2015
a86c160
Merge pull request #6424 from HabitRPG/api-v3-async
crookedneighbor Dec 31, 2015
bf0a5cb
fix: Remove extranous comma in eslint confi
crookedneighbor Dec 31, 2015
16e8104
chore: Move eslint modules to devDependencies
crookedneighbor Dec 31, 2015
6f220c6
lint: Turn on linting for v3 group tests
crookedneighbor Dec 31, 2015
70151fd
lint: Fix tests that can be fixed with the eslint --fix flag
crookedneighbor Dec 31, 2015
9428c6d
lint: Correct linting errors in api v3 tests
crookedneighbor Dec 31, 2015
aa6f5ff
Merge branch 'develop' into api-v3
crookedneighbor Dec 31, 2015
7cf4368
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Dec 31, 2015
7025bbf
Fix basilist scroll giving logic when joining party
KristianTashkov Dec 29, 2015
3a0e714
Merge branch 'develop' into api-v3
crookedneighbor Dec 31, 2015
90cd322
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Dec 31, 2015
91e7b9e
tests(api): Convert GET and flag chat posts to use async/await
crookedneighbor Jan 1, 2016
775766b
allow multiple tasks to be created at once
paglias Jan 2, 2016
7490bfa
update POST-tasks test to async/await syntax
paglias Jan 2, 2016
743f98d
make sure user.tasksOrder is update only when necessary
paglias Jan 2, 2016
27065b3
more tests for user.tasksOrder
paglias Jan 2, 2016
a775c99
fix linting and add pending test
paglias Jan 2, 2016
3791627
Merge branch 'develop' into api-v3
crookedneighbor Jan 3, 2016
76c97df
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 3, 2016
f80f41f
lint: Correct linting errors in v3 tests
crookedneighbor Jan 3, 2016
f38d0eb
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 3, 2016
5bcce0b
Add tests for group join route
KristianTashkov Jan 2, 2016
45eed84
Merge pull request #6446 from KristianTashkov/group-join-tests
crookedneighbor Jan 3, 2016
d25cb70
wip get and create tasks plus initial user syncing
paglias Jan 4, 2016
b73f5a8
add support for getting single challenges tasks
paglias Jan 4, 2016
6680853
finish adding challenges support for tasks (except syncing)
paglias Jan 4, 2016
3bc8945
adapt current tests and change urls to avoid conflicts
paglias Jan 4, 2016
a5b1dfd
finish implementing tasks syncing for challenges
paglias Jan 5, 2016
3a6d7bd
fix sync of remove challenge task
paglias Jan 6, 2016
2b2dcfe
do not delete completed todos that belongs to a challenge
paglias Jan 6, 2016
8ba486e
change tasks routes to /tasks/(user|challenge)
paglias Jan 6, 2016
9dfcad2
rename tasks tests to match new routes
paglias Jan 6, 2016
f235010
add getChallenge route and remove old code
paglias Jan 6, 2016
ffbd469
Converted posts tests to async/await syntax and updated tests
TheHollidayInn Jan 11, 2016
fffa95c
refactor: Test against party not being private, instead of public
crookedneighbor Jan 12, 2016
ddd0709
Refactor Tags tests to use await syntax
GeorgeSG Jan 12, 2016
88755e6
tests(api): Simplify tests
crookedneighbor Jan 12, 2016
36cd9e9
tests(api): Increase test coverage for group post tests
crookedneighbor Jan 12, 2016
9141598
Updated invite route and function for new standards, and added tests.
TheHollidayInn Jan 7, 2016
1b395b3
Added invite limit and tests for when multiple users with an error
TheHollidayInn Jan 12, 2016
b102ff7
Merge branch 'api-v3-groups-invites' of https://github.com/TheHollida…
paglias Jan 12, 2016
baf0179
Merge branch 'TheHollidayInn-api-v3-groups-invites' into api-v3-groups
paglias Jan 12, 2016
98b0db7
Refactor User tests to use await syntax
GeorgeSG Jan 12, 2016
55db0a4
add routes to get a single user, get members for a group, get members…
paglias Jan 12, 2016
eaddf5a
Refactor notFound test to use await expect syntax
GeorgeSG Jan 12, 2016
1270593
abstract common logic in members controller
paglias Jan 12, 2016
2e3bee0
Refactor User tests to use await expect instead of return expect
GeorgeSG Jan 12, 2016
ac6a027
Refactor Tasks tests to use await syntax
GeorgeSG Jan 12, 2016
99217e8
Added initial group update tests
TheHollidayInn Jan 11, 2016
da02f8c
Removed pending status on test
TheHollidayInn Jan 12, 2016
45aacc1
challenge.group -> challenge.groupId
paglias Jan 12, 2016
e4fd37f
Cleaned up code style and abstracted variables that are reused.
TheHollidayInn Jan 12, 2016
fdfc8fb
Merge branch 'api-v3-groups' into GeorgeSG-api-v3-groups
crookedneighbor Jan 12, 2016
336d8c9
tests(api): Clean up misc test styles
crookedneighbor Jan 12, 2016
ae67efd
Merge branch 'GeorgeSG-api-v3-groups' into api-v3-groups
crookedneighbor Jan 12, 2016
a3fd838
tests(api): Fix PUT /task test to be valid
crookedneighbor Jan 13, 2016
0c30b56
Merge pull request #6498 from TheHollidayInn/api-v3-groups-update
crookedneighbor Jan 13, 2016
c9d378a
tests(api): bring in await format tests
crookedneighbor Jan 13, 2016
7a8321e
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 13, 2016
7c15472
wip on members controllers
paglias Jan 13, 2016
6088b6d
fix edge case where res.respond would not work, misc comments
paglias Jan 13, 2016
914b2eb
Merge branch 'develop' into api-v3
paglias Jan 13, 2016
e2edb97
Merge branch 'api-v3' into api-v3-groups
paglias Jan 13, 2016
771bc0c
put back acceptablePUTPaths variable deleted in merge
paglias Jan 13, 2016
4afad11
Merge branch 'api-v3' into api-v3-groups
paglias Jan 13, 2016
6f6d4ed
Merge branch 'api-v3-groups' into api-v3-members
paglias Jan 13, 2016
b688616
tests(integration): Create separate helper for api integration tests
crookedneighbor Jan 13, 2016
799b378
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 13, 2016
1f4e58e
tests(api): Port integration helper to v3 version for groups tests
crookedneighbor Jan 13, 2016
9a90878
new history preening, save tasks after cron
paglias Jan 13, 2016
52eaecf
Merge branch 'api-v3-groups' of github.com:HabitRPG/habitrpg into api…
paglias Jan 13, 2016
2cc02ee
refactor(test helper): Fix api v3 helper to be specific for v3
crookedneighbor Jan 14, 2016
42530b9
refactor(tests): Adjust tests to use createAndPopulateGroup
crookedneighbor Jan 14, 2016
2b9aa11
Merge branch 'api-v3-groups' into api-v3-challenges-tasks
paglias Jan 14, 2016
0145857
Merge branch 'api-v3-challenges-tasks' into api-v3-groups
paglias Jan 14, 2016
0f5cf31
fix: Update member objects with guild info in test helper
crookedneighbor Jan 14, 2016
5ff54fa
Merge branch 'api-v3-groups' into api-v3-groups-create-and-populate
crookedneighbor Jan 14, 2016
5206469
add unlinkTask route and refactor user.unlink (now user.unlinkChallen…
paglias Jan 14, 2016
7d5a750
fix access to user.tasksOrder
paglias Jan 14, 2016
2a6241d
Merge pull request #6520 from HabitRPG/api-v3-groups-create-and-populate
crookedneighbor Jan 14, 2016
e0b10d4
Merge branch 'api-v3-groups' into api-v3-members
paglias Jan 15, 2016
50a8533
better access control for challenges
paglias Jan 15, 2016
3eb9d4b
members controller: support challenges
paglias Jan 15, 2016
b0caf71
fix several busg with tasks and challenges
paglias Jan 15, 2016
2ee75c1
add tests for getMember
paglias Jan 15, 2016
ad41037
finish tests for members controller
paglias Jan 15, 2016
96c5234
fix missing semicolon
paglias Jan 15, 2016
d7d63ad
populate group.leader
paglias Jan 16, 2016
f447af1
add tests for getting challenge members and fix a lot of bugs
paglias Jan 16, 2016
4e5c4e9
add missing test file
paglias Jan 16, 2016
a59da86
add tests for getting invites to a group
paglias Jan 16, 2016
f8f591e
do not use wait inside for loop
paglias Jan 16, 2016
07f08de
Merge branch 'improve_tests' into api-v3
crookedneighbor Jan 17, 2016
ec9d0fd
tests: Set up placeholder file for api test helpers
crookedneighbor Jan 17, 2016
5dd2dcd
Merge branch 'improve_tests' into api-v3
crookedneighbor Jan 17, 2016
a44cf5e
lint: Fix linting erros in test helpers
crookedneighbor Jan 17, 2016
965c5db
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 17, 2016
5de2503
Merge branch 'develop' into api-v3
crookedneighbor Jan 17, 2016
38cdf07
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 17, 2016
c27f980
Merge branch 'api-v3-groups' into api-v3-members
paglias Jan 17, 2016
8de8ca7
add getChallengeMemberProgress route and misc fixes
paglias Jan 17, 2016
ec7ed9c
add tests for getChallengeMemberProgress route and several bug fixes
paglias Jan 17, 2016
3630f5a
Merge pull request #6504 from HabitRPG/api-v3-members
paglias Jan 17, 2016
0838179
Merge branch 'develop' into api-v3
crookedneighbor Jan 17, 2016
5d803fd
tests(api): Adjust v3 api-integration helper to export all generate m…
crookedneighbor Jan 17, 2016
1e9f24a
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 17, 2016
b75adb4
tests(api): Pull in theunknown's changes to createAndPopulateGroup
crookedneighbor Jan 17, 2016
81e6172
tests: Tighten up generateGroup members helper
crookedneighbor Jan 17, 2016
7b59455
tests(api): Add generateChallenge helper
crookedneighbor Jan 17, 2016
b24ff23
Merge pull request #6542 from crookedneighbor/api_v3_generate_challenge
crookedneighbor Jan 17, 2016
f37b5a7
Challenges join route and tests
KristianTashkov Jan 17, 2016
d93caba
Added initial tests for createChallengeTasks and fixed some issues in…
TheHollidayInn Jan 16, 2016
ee85422
fix dateCompleted not remove from un-completed todos and fix tasks test
paglias Jan 18, 2016
a0a840e
Merge branch 'develop' into api-v3
crookedneighbor Jan 18, 2016
aa68a5e
fix: Update vagrant to use npm 3
crookedneighbor Jan 18, 2016
1ff9db2
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 18, 2016
64c4f0f
Merge branch 'develop' into api-v3
crookedneighbor Jan 18, 2016
4776035
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 18, 2016
32a2b31
Merge branch 'develop' into api-v3
crookedneighbor Jan 19, 2016
66083f7
Merge branch 'api-v3' into api-v3-groups
crookedneighbor Jan 19, 2016
ef6afae
Added intitial group leave tests
TheHollidayInn Jan 13, 2016
1a31f73
fix query when setting new group leader
paglias Jan 20, 2016
9832e55
Added initial clear chat flags tests
TheHollidayInn Jan 22, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
website/public/gen
website/public/common
website/public/apidoc
node_modules
*.swp
.idea*
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.40
4.2
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js
node_js:
- '0.10'
- '4.2'
before_install:
- "npm install -g npm@2"
- "npm install -g npm@3"
- "npm install -g gulp"
- "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10"
- "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list"
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module.exports = function(grunt) {
grunt.registerTask('build:test', ['test:prepare:translations', 'build:dev']);

grunt.registerTask('test:prepare:translations', function() {
var i18n = require('./website/src/libs/i18n'),
var i18n = require('./website/src/libs/api-v3/i18n'),
fs = require('fs');
fs.writeFileSync('test/spec/mocks/translations.js',
"if(!window.env) window.env = {};\n" +
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: node ./website/src/server.js
web: node ./website/src/index.js
69 changes: 69 additions & 0 deletions common/locales/en/api-v3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"missingAuthHeaders": "Missing authentication headers.",
"missingUsernameEmail": "Missing username or email.",
"missingEmail": "Missing email.",
"missingUsername": "Missing username.",
"missingPassword": "Missing password.",
"notAnEmail": "Invalid email address.",
"emailTaken": "Email already taken.",
"usernameTaken": "Username already taken.",
"passwordConfirmationMatch": "Password confirmation doesn't match password.",
"invalidLoginCredentials": "Incorrect username / email and / or password.",
"invalidCredentials": "User not found with given auth credentials.",
"accountSuspended": "Account has been suspended, please contact [email protected] with your UUID \"<%= userId %>\" for assistance.",
"onlyFbSupported": "Only Facebook supported currently.",
"cantDetachFb": "Account lacks another authentication method, can't detach Facebook.",
"onlySocialAttachLocal": "Local auth can only be added to a social account.",
"invalidReqParams": "Invalid request parameters.",
"memberIdRequired": "\"member\" must be a valid UUID.",
"taskIdRequired": "\"taskId\" must be a valid UUID.",
"taskNotFound": "Task not found.",
"invalidTaskType": "Task type must be one of \"habit\", \"daily\", \"todo\", \"reward\".",
"cantDeleteChallengeTasks": "A task belonging to a challenge can't be deleted.",
"checklistOnlyDailyTodo": "Checklists are supported only on dailies and todos",
"checklistItemNotFound": "No checklist item was found with given id.",
"itemIdRequired": "\"itemId\" must be a valid UUID.",
"tagNotFound": "No tag item was found with given id.",
"tagIdRequired": "\"tagId\" must be a valid UUID corresponding to a tag belonging to the user.",
"positionRequired": "\"position\" is required and must be a number.",
"cantMoveCompletedTodo": "Can't move a completed todo.",
"directionUpDown": "\"direction\" is required and must be 'up' or 'down'",
"alreadyTagged": "The task is already tagged with given tag.",
"groupIdRequired": "\"groupId\" must be a valid UUID",
"groupNotFound": "Group not found.",
"groupTypesRequired": "You must supply a valid \"type\" query string.",
"questLeaderCannotLeaveGroup": "You cannot leave your party when you have started a quest. Abort the quest first.",
"cannotLeaveWhileActiveQuest": "You cannot leave party during an active quest. Please leave the quest first.",
"onlyLeaderCanRemoveMember": "Only group leader can remove a member!",
"memberCannotRemoveYourself": "You cannot remove yourself!",
"groupMemberNotFound": "User not found among group's members",
"challengeMemberNotFound": "User not found among challenge's members",
"mustBeGroupMember": "Must be member of the group.",
"keepOrRemoveAll": "req.query.keep must be either \"keep-all\" or \"remove-all\"",
"keepOrRemove": "req.query.keep must be either \"keep\" or \"remove\"",
"canOnlyInviteEmailUuid": "Can only invite using uuids or emails.",
"inviteMissingEmail": "Missing email address in invite.",
"onlyGroupLeaderChal": "Only the group leader can create challenges",
"pubChalsMinPrize": "Prize must be at least 1 Gem for public challenges.",
"cantAfford": "You can't afford this prize. Purchase more gems or lower the prize amount.",
"challengeIdRequired": "\"challengeId\" must be a valid UUID.",
"winnerIdRequired": "\"winnerId\" must be a valid UUID.",
"challengeNotFound": "Challenge not found.",
"onlyLeaderDeleteChal": "Only the challenge leader can delete it.",
"winnerNotFound": "Winner with id \"<%= userId %>\" not found or not part of the challenge.",
"noCompletedTodosChallenge": "\"includeComepletedTodos\" is not supported when fetching a challenge tasks.",
"userTasksNoChallengeId": "When \"tasksOwner\" is \"user\" \"challengeId\" can't be passed.",
"onlyChalLeaderEditTasks": "Tasks belonging to a challenge can only be edited by the leader.",
"userAlreadyInChallenge": "User is already participating in this challenge.",
"invalidTasksOwner": "\"tasksOwner\" must be \"user\" or \"challenge\".",
"partyMustbePrivate": "Parties must be private",
"userAlreadyInGroup": "User already in that group.",
"userAlreadyInvitedToGroup": "User already invited to that group.",
"userAlreadyPendingInvitation": "User already pending invitation.",
"userAlreadyInAParty": "User already in a party.",
"userWithIDNotFound": "User with id \"<%= userId %>\" not found.",
"uuidsMustBeAnArray": "UUIDs invites must be a an Array.",
"emailsMustBeAnArray": "Email invites must be a an Array.",
"canOnlyInviteMaxInvites": "You can only invite \"<%= maxInvites %>\" at a time",
"cantOnlyUnlinkChalTask": "Only challenges tasks can be unlinked."
}
264 changes: 264 additions & 0 deletions common/script/api-v3/cron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
import moment from 'moment';
import _ from 'lodash';
import scoreTask from './scoreTask';
import { preenUserHistory } from './preening';
import common from '../../';
import {
shouldDo,
} from '../cron';

let clearBuffs = {
str: 0,
int: 0,
per: 0,
con: 0,
stealth: 0,
streaks: false,
};

// At end of day, add value to all incomplete Daily & Todo tasks (further incentive)
// For incomplete Dailys, deduct experience
// Make sure to run this function once in a while as server will not take care of overnight calculations.
// And you have to run it every time client connects.
export default function cron (options = {}) {
let {user, tasksByType, analytics, now, daysMissed} = options;

user.auth.timestamps.loggedin = now;
user.lastCron = now;
// Reset the lastDrop count to zero
if (user.items.lastDrop.count > 0) user.items.lastDrop.count = 0;

// "Perfect Day" achievement for perfect-days
let perfect = true;

// end-of-month perks for subscribers
let plan = user.purchased.plan;
if (user.isSubscribed()) {
if (moment(plan.dateUpdated).format('MMYYYY') !== moment().format('MMYYYY')) {
plan.gemsBought = 0; // reset gem-cap
plan.dateUpdated = now;
// For every month, inc their "consecutive months" counter. Give perks based on consecutive blocks
// If they already got perks for those blocks (eg, 6mo subscription, subscription gifts, etc) - then dec the offset until it hits 0
// TODO use month diff instead of ++ / --?
_.defaults(plan.consecutive, {count: 0, offset: 0, trinkets: 0, gemCapExtra: 0}); // FIXME see https://github.com/HabitRPG/habitrpg/issues/4317
plan.consecutive.count++;
if (plan.consecutive.offset > 0) {
plan.consecutive.offset--;
} else if (plan.consecutive.count % 3 === 0) { // every 3 months
plan.consecutive.trinkets++;
plan.consecutive.gemCapExtra += 5;
if (plan.consecutive.gemCapExtra > 25) plan.consecutive.gemCapExtra = 25; // cap it at 50 (hard 25 limit + extra 25)
}
}

// If user cancelled subscription, we give them until 30day's end until it terminates
if (plan.dateTerminated && moment(plan.dateTerminated).isBefore(new Date())) {
_.merge(plan, {
planId: null,
customerId: null,
paymentMethod: null,
});

_.merge(plan.consecutive, {
count: 0,
offset: 0,
gemCapExtra: 0,
});

user.markModified('purchased.plan');
}
}

// User is resting at the inn.
// On cron, buffs are cleared and all dailies are reset without performing damage
if (user.preferences.sleep === true) {
user.stats.buffs = _.cloneDeep(clearBuffs);

tasksByType.dailys.forEach((daily) => {
let completed = daily.completed;
let thatDay = moment(now).subtract({days: 1});

if (shouldDo(thatDay.toDate(), daily, user.preferences) || completed) {
daily.checklist.forEach(box => box.completed = false);
}
daily.completed = false;
});

return;
}

let multiDaysCountAsOneDay = true;
// If the user does not log in for two or more days, cron (mostly) acts as if it were only one day.
// When site-wide difficulty settings are introduced, this can be a user preference option.

// Tally each task
let todoTally = 0;

tasksByType.todos.forEach(task => { // make uncompleted todos redder
scoreTask({
task,
user,
direction: 'down',
cron: true,
times: multiDaysCountAsOneDay ? 1 : daysMissed,
// TODO pass req for analytics?
});

todoTally += task.value;
});

let dailyChecked = 0; // how many dailies were checked?
let dailyDueUnchecked = 0; // how many dailies were cun-hecked?
if (!user.party.quest.progress.down) user.party.quest.progress.down = 0;

tasksByType.dailys.forEach((task) => {
let completed = task.completed;
// Deduct points for missed Daily tasks
let EvadeTask = 0;
let scheduleMisses = daysMissed;

if (completed) {
dailyChecked += 1;
} else {
// dailys repeat, so need to calculate how many they've missed according to their own schedule
scheduleMisses = 0;

for (let i = 0; i < daysMissed; i++) {
let thatDay = moment(now).subtract({days: i + 1});

if (shouldDo(thatDay.toDate(), task, user.preferences)) {
scheduleMisses++;
if (user.stats.buffs.stealth) {
user.stats.buffs.stealth--;
EvadeTask++;
}
if (multiDaysCountAsOneDay) break;
}
}

if (scheduleMisses > EvadeTask) {
perfect = false;

if (task.checklist && task.checklist.length > 0) { // Partially completed checklists dock fewer mana points
let fractionChecked = _.reduce(task.checklist, (m, i) => m + (i.completed ? 1 : 0), 0) / task.checklist.length;
dailyDueUnchecked += 1 - fractionChecked;
dailyChecked += fractionChecked;
} else {
dailyDueUnchecked += 1;
}

let delta = scoreTask({
user,
task,
direction: 'down',
times: multiDaysCountAsOneDay ? 1 : scheduleMisses - EvadeTask,
cron: true,
});

// Apply damage from a boss, less damage for Trivial priority (difficulty)
user.party.quest.progress.down += delta * (task.priority < 1 ? task.priority : 1);
// NB: Medium and Hard priorities do not increase damage from boss. This was by accident
// initially, and when we realised, we could not fix it because users are used to
// their Medium and Hard Dailies doing an Easy amount of damage from boss.
// Easy is task.priority = 1. Anything < 1 will be Trivial (0.1) or any future
// setting between Trivial and Easy.
}
}

task.history.push({
date: Number(new Date()),
value: task.value,
});
task.completed = false;

if (completed || scheduleMisses > 0) {
task.checklist.forEach(i => i.completed = true); // FIXME this should not happen for grey tasks unless they are completed
}
});

tasksByType.habits.forEach((task) => { // slowly reset 'onlies' value to 0
if (task.up === false || task.down === false) {
task.value = Math.abs(task.value) < 0.1 ? 0 : task.value = task.value / 2;
}
});

// Finished tallying
user.history.todos.push({date: now, value: todoTally});

// tally experience
let expTally = user.stats.exp;
let lvl = 0; // iterator
while (lvl < user.stats.lvl - 1) {
lvl++;
expTally += common.tnl(lvl);
}
user.history.exp.push({date: now, value: expTally});

// preen user history so that it doesn't become a performance problem
// also for subscribed users but differentyly
// premium subscribers can keep their full history.
preenUserHistory(user, tasksByType, user.preferences.timezoneOffset);

if (perfect) {
user.achievements.perfect++;
let lvlDiv2 = Math.ceil(common.capByLevel(user.stats.lvl) / 2);
user.stats.buffs = {
str: lvlDiv2,
int: lvlDiv2,
per: lvlDiv2,
con: lvlDiv2,
stealth: 0,
streaks: false,
};
} else {
user.stats.buffs = _.cloneDeep(clearBuffs);
}

// Add 10 MP, or 10% of max MP if that'd be more. Perform this after Perfect Day for maximum benefit
// Adjust for fraction of dailies completed
user.stats.mp += _.max([10, 0.1 * user._statsComputed.maxMP]) * dailyChecked / (dailyDueUnchecked + dailyChecked);
if (user.stats.mp > user._statsComputed.maxMP) user.stats.mp = user._statsComputed.maxMP;

if (dailyDueUnchecked === 0 && dailyChecked === 0) dailyChecked = 1;
user.stats.mp += _.max([10, 0.1 * user._statsComputed.maxMP]) * dailyChecked / (dailyDueUnchecked + dailyChecked);
if (user.stats.mp > user._statsComputed.maxMP) {
user.stats.mp = user._statsComputed.maxMP;
}

// After all is said and done, progress up user's effect on quest, return those values & reset the user's
let progress = user.party.quest.progress;
let _progress = _.cloneDeep(progress);
_.merge(progress, {down: 0, up: 0});
progress.collect = _.transform(progress.collect, (m, v, k) => m[k] = 0);

// Clean PMs - keep 200 for subscribers and 50 for free users
// TODO tests
let maxPMs = user.isSubscribed() ? 200 : 50; // TODO 200 limit for contributors too
let numberOfPMs = Object.keys(user.inbox.messages).length;
if (Object.keys(user.inbox.messages).length > maxPMs) {
_(user.inbox.messages)
.sortBy('timestamp')
.takeRight(numberOfPMs - maxPMs)
.each(pm => {
user.inbox.messages[pm.id] = undefined;
}).value();

user.markModified('inbox.messages');
}

// Analytics
user.flags.cronCount++;
analytics.track('Cron', {
category: 'behavior',
gaLabel: 'Cron Count',
gaValue: user.flags.cronCount,
uuid: user._id,
user, // TODO is it really necessary passing the whole user object?
resting: user.preferences.sleep,
cronCount: user.flags.cronCount,
progressUp: _.min([_progress.up, 900]),
progressDown: _progress.down,
});

return _progress;
}
Loading