fix(sunset): release candidate

This commit is contained in:
SabreCat 2023-08-07 15:04:44 -05:00
parent a8b52ab656
commit 9fa355fbcc
6 changed files with 22 additions and 9 deletions

View file

@ -169,7 +169,6 @@
</h2>
<ul>
<li><a href="/static/faq">{{ $t('faq') }}</a></li>
<li v-html="$t('commGuideLink02')"></li>
<li v-html="$t('commGuideLink03')"></li>
<li v-html="$t('commGuideLink04')"></li>
</ul>

View file

@ -30,7 +30,7 @@
"commGuideHeadingInfractionsEtc": "Infractions, Consequences, and Restoration",
"commGuideHeadingInfractions": "Infractions",
"commGuidePara050": "Overwhelmingly, Habiticans assist each other, are respectful, and work to make the whole community fun and friendly. However, once in a blue moon, something that a Habitican does may violate one of the above Guidelines. When this happens, the Staff will take whatever actions they deem necessary to keep Habitica safe and comfortable for everyone.",
"commGuidePara050": "Overwhelmingly, Habiticans assist each other, are respectful, and work to make the atmosphere here fun and friendly. However, once in a blue moon, something that a Habitican does may violate one of the above Guidelines. When this happens, the Staff will take whatever actions they deem necessary to keep Habitica safe and comfortable for everyone.",
"commGuidePara051": "<strong>There are a variety of infractions, and they are dealt with depending on their severity</strong>. These are not comprehensive lists, and the Staff can make decisions on topics not covered here at their own discretion. The Staff will take context into account when evaluating infractions.",
"commGuideHeadingSevereInfractions": "Severe Infractions",

View file

@ -14,6 +14,7 @@ import {
import {
NotFound,
NotAuthorized,
BadRequest,
} from '../../libs/errors';
import * as Tasks from '../../models/task';
import csvStringify from '../../libs/csvStringify';
@ -266,7 +267,12 @@ api.joinChallenge = {
const group = await Group.getGroup({
user, groupId: challenge.group, fields: basicGroupFields, optionalMembership: true,
});
if (!group || !challenge.canJoin(user, group)) throw new NotFound(res.t('challengeNotFound'));
if (!group || group.type === 'party' && group._id !== user.party._id) {
throw new NotFound(res.t('challengeNotFound'));
}
if (group.type === 'guild' && group._id !== TAVERN_ID && !group.hasActiveGroupPlan()) {
throw new BadRequest(res.t('featureRetired'));
}
const addedSuccessfully = await challenge.addToUser(user);
if (!addedSuccessfully) {
@ -403,8 +409,9 @@ api.getUserChallenges = {
orOptions.push({ leader: user._id });
if (!req.query.member) {
const userGroups = await user.getGroups();
orOptions.push({
group: { $in: user.getGroups() },
group: { $in: userGroups },
}); // Challenges in groups where I'm a member
}

View file

@ -5,6 +5,7 @@ import { authWithHeaders } from '../../middlewares/auth';
import {
model as Group,
basicFields as basicGroupFields,
TAVERN_ID,
} from '../../models/group';
import {
model as User,
@ -411,7 +412,7 @@ api.getGroup = {
const { groupId } = req.params;
const group = await Group.getGroup({ user, groupId, populateLeader: false });
if (!group) {
if (!group || group.type === 'guild' && group._id !== TAVERN_ID && !group.hasActiveGroupPlan()) {
throw new NotFound(res.t('groupNotFound'));
}
@ -1337,7 +1338,7 @@ api.getGroupPlans = {
async handler (req, res) {
const { user } = res.locals;
const userGroups = user.getGroups();
const userGroups = await user.getGroups();
const groups = await Group
.find({

View file

@ -41,6 +41,9 @@ export async function createChallenge (user, req, res) {
});
if (!group) throw new NotFound(res.t('groupNotFound'));
if (!group.isMember(user)) throw new NotAuthorized(res.t('mustBeGroupMember'));
if (group.type === 'guild' && group._id !== TAVERN_ID && !group.hasActiveGroupPlan()) {
throw new BadRequest(res.t('featureRetired'));
}
if (group.leaderOnly && group.leaderOnly.challenges && group.leader !== user._id) {
throw new NotAuthorized(res.t('onlyGroupLeaderChal'));

View file

@ -45,8 +45,11 @@ schema.methods.hasCancelled = function hasCancelled () {
};
// Get an array of groups ids the user is member of
schema.methods.getGroups = function getUserGroups () {
const userGroups = this.guilds.slice(0); // clone this.guilds so we don't modify the original
schema.methods.getGroups = async function getUserGroups () {
const userGroups = await Group.getGroups({
user: this,
types: ['party', 'guilds', 'tavern'],
});
if (this.party._id) userGroups.push(this.party._id);
userGroups.push(TAVERN_ID);
return userGroups;
@ -465,7 +468,7 @@ schema.methods.daysUserHasMissed = function daysUserHasMissed (now, req = {}) {
};
async function getUserGroupData (user) {
const userGroups = user.getGroups();
const userGroups = await user.getGroups();
const groups = await Group
.find({