Skip to content

Commit

Permalink
lint auto fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
aspalding committed Oct 30, 2023
1 parent 15e12b9 commit 5f209b4
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 226 deletions.
70 changes: 35 additions & 35 deletions net/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,43 +190,43 @@ module.exports = {
}
break
case 'create':
let question = resLocal.linked.find(({ type }) => type.toLowerCase() === 'question')
const question = resLocal.linked.find(({ type }) => type.toLowerCase() === 'question')
if (question) {
let questionType
const targetActivity = object
let targetActivityChoice = targetActivity.name[0].toLowerCase()
if (Object.hasOwn(question, 'oneOf')) {
questionType = 'oneOf'
} else if (Object.hasOwn(question, 'anyOf')) {
questionType = 'anyOf'
let questionType
const targetActivity = object
const targetActivityChoice = targetActivity.name[0].toLowerCase()
if (Object.hasOwn(question, 'oneOf')) {
questionType = 'oneOf'
} else if (Object.hasOwn(question, 'anyOf')) {
questionType = 'anyOf'
}
const chosenCollection = question[questionType].find(({ name }) => name[0].toLowerCase() === targetActivityChoice)
const chosenCollectionId = apex.objectIdFromValue(chosenCollection.replies)
toDo.push((async () => {
activity = await apex.store.updateActivityMeta(activity, 'collection', chosenCollectionId)
const updatedCollection = await apex.getCollection(chosenCollectionId)
question[questionType].find(({ replies }) => replies.id === chosenCollectionId).replies = updatedCollection
if (question._meta) {
question._meta.voteAndVoter[0].push({
voter: activity.actor[0],
voteName: activity.object[0].name[0]
})
question.votersCount = [...new Set(question._meta.voteAndVoter[0].map(obj => obj.voter))].length
} else {
const voteAndVoter = [{
voter: activity.actor[0],
voteName: activity.object[0].name[0]
}]
question.votersCount = 1
apex.addMeta(question, 'voteAndVoter', voteAndVoter)
}
let chosenCollection = question[questionType].find(({ name }) => name[0].toLowerCase() === targetActivityChoice)
const chosenCollectionId = apex.objectIdFromValue(chosenCollection.replies)
toDo.push((async () => {
activity = await apex.store.updateActivityMeta(activity, 'collection', chosenCollectionId)
let updatedCollection = await apex.getCollection(chosenCollectionId)
question[questionType].find(({ replies }) => replies.id === chosenCollectionId).replies = updatedCollection
if (question._meta) {
question._meta.voteAndVoter[0].push({
voter: activity.actor[0],
voteName: activity.object[0].name[0]
})
question.votersCount = [...new Set(question._meta.voteAndVoter[0].map(obj => obj.voter))].length
} else {
let voteAndVoter = [{
voter: activity.actor[0],
voteName: activity.object[0].name[0]
}]
question.votersCount = 1
apex.addMeta(question, 'voteAndVoter', voteAndVoter)
}
let updatedQuestion = await apex.store.updateObject(question, actorId, true)
if (updatedQuestion) {
resLocal.postWork.push(async () => {
return apex.publishUpdate(recipient, updatedQuestion, actorId)
})
}
})())
const updatedQuestion = await apex.store.updateObject(question, actorId, true)
if (updatedQuestion) {
resLocal.postWork.push(async () => {
return apex.publishUpdate(recipient, updatedQuestion, actorId)
})
}
})())
}
}
Promise.all(toDo).then(() => {
Expand Down
11 changes: 5 additions & 6 deletions net/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ function inboxActivity (req, res, next) {
return next()
}
}
let question = resLocal.linked.find(({ type }) => type.toLowerCase() === 'question')
const question = resLocal.linked.find(({ type }) => type.toLowerCase() === 'question')
if (question) {
let now = new Date()
let pollEndTime = new Date(question.endTime)
const now = new Date()
const pollEndTime = new Date(question.endTime)
if (now > pollEndTime) {
resLocal.status = 403
next()
Expand All @@ -150,15 +150,14 @@ function inboxActivity (req, res, next) {
next()
}
} else if (Object.hasOwn(question, 'anyOf')) {
let hasDuplicateVote = question._meta?.voteAndVoter[0].some(({voter, voteName}) => {
return voter === activity.actor[0] && activity.object[0].name == voteName;
const hasDuplicateVote = question._meta?.voteAndVoter[0].some(({ voter, voteName }) => {
return voter === activity.actor[0] && activity.object[0].name == voteName
})
if (hasDuplicateVote) {
resLocal.status = 403
next()
}
}

}
tasks.push(apex.embedCollections(activity))
Promise.all(tasks).then(() => {
Expand Down
Loading

0 comments on commit 5f209b4

Please sign in to comment.