Merge branch 'release' into develop

This commit is contained in:
SabreCat 2023-08-15 15:51:20 -05:00
commit e9845e7b01
5 changed files with 13 additions and 7 deletions

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "habitica",
"version": "5.1.1",
"version": "5.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "5.1.1",
"version": "5.1.2",
"main": "./website/server/index.js",
"dependencies": {
"@babel/core": "^7.22.5",

View file

@ -270,6 +270,9 @@ export default {
methods: {
percent,
showMemberModal (member) {
if (this.$route.name === 'userProfile' && this.$route.params?.userId === member._id) {
return;
}
this.$router.push({ name: 'userProfile', params: { userId: member._id } });
},
},

View file

@ -575,13 +575,15 @@ api.getChallenge = {
// Fetching basic group data
const group = await Group.getGroup({
user, groupId: challenge.group, fields: `${basicGroupFields} purchased`, optionalMembership: true,
user, groupId: challenge.group, fields: `${basicGroupFields} purchased`,
});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
group.purchased = undefined;
if (!group && !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
const chalRes = challenge.toJSON();
chalRes.group = group.toJSON({ minimize: true });
if (group) {
group.purchased = undefined;
chalRes.group = group.toJSON({ minimize: true });
}
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
const chalLeader = await User.findById(chalRes.leader).select(nameFields).exec();
chalRes.leader = chalLeader ? chalLeader.toJSON({ minimize: true }) : null;

View file

@ -93,6 +93,7 @@ schema.methods.canModify = function canModifyChallenge (user) {
schema.methods.canJoin = function canJoinChallenge (user, group) {
// for when leader has left private group that contains the challenge
if (this.isLeader(user)) return true;
if (!group) return false;
if (group.type === 'guild' && group.privacy === 'public') {
return group._id === TAVERN_ID;
}