Another batch of important updates and fixes
This commit is contained in:
@@ -12,6 +12,15 @@ exports.listComments = async (req, res) => {
|
||||
}
|
||||
|
||||
if (filters.ctxType === 'entry_dict_int') {
|
||||
if (!filters.ctxId) {
|
||||
const NO_COMMENTS_OBJECT = {
|
||||
page: 1,
|
||||
numberOfAllPages: 1,
|
||||
comments: [],
|
||||
commentCount: 0
|
||||
}
|
||||
return res.send(NO_COMMENTS_OBJECT)
|
||||
}
|
||||
const { dictionary_id: dictionaryId } = await Entry.fetch(filters.ctxId)
|
||||
const isEditor = req.user.hasAnyDictionaryRole(dictionaryId)
|
||||
const isPortalAdmin = req.user.hasRole('portal admin')
|
||||
|
||||
@@ -123,6 +123,8 @@ consultancy.createQuestion = async (req, res) => {
|
||||
subject: subjectText,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${emails} (subject: ${subjectText})`)
|
||||
|
||||
res.status(201).send()
|
||||
}
|
||||
@@ -233,11 +235,14 @@ consultancy.assign = async (req, res) => {
|
||||
const emailHtml = await renderAsync('email/consultancy-assigned')
|
||||
|
||||
// TODO i18n - What language are the email title and content (we already have email translated)
|
||||
const emailSubject = req.t('Novo terminološko vprašanje')
|
||||
await email.send({
|
||||
to: emails,
|
||||
subject: req.t('Novo terminološko vprašanje'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${emails} (subject: ${emailSubject})`)
|
||||
|
||||
res.send()
|
||||
}
|
||||
@@ -289,11 +294,14 @@ consultancy.sendToReview = async (req, res) => {
|
||||
const emailHtml = await renderAsync('email/consultancy-item-review')
|
||||
|
||||
// TODO i18n - What language are the email title and content (we already have email translated)
|
||||
const emailSubject = req.t('Potrditev objave')
|
||||
await email.send({
|
||||
to: emails,
|
||||
subject: req.t('Potrditev objave'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${emails} (subject: ${emailSubject})`)
|
||||
|
||||
res.send()
|
||||
}
|
||||
@@ -318,13 +326,16 @@ consultancy.publish = async (req, res) => {
|
||||
portalName
|
||||
}
|
||||
)
|
||||
const emailSubject = i18next.t('Objava terminološkega vprašanja', {
|
||||
lng: author.language
|
||||
})
|
||||
await email.send({
|
||||
to: author.email,
|
||||
subject: i18next.t('Objava terminološkega vprašanja', {
|
||||
lng: author.language
|
||||
}),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${author.email} (subject: ${emailSubject})`)
|
||||
|
||||
await ConsultancyEntry.publish(questionId, answerAuthors)
|
||||
await ConsultancyEntry.indexIntoSearchEngine(questionId, true)
|
||||
|
||||
@@ -55,7 +55,7 @@ dictionary.updateEntry = async (req, res) => {
|
||||
}
|
||||
|
||||
dictionary.fetchEntries = async (req, res) => {
|
||||
const dictionaryId = req.query.id
|
||||
const { dictionaryId } = req.query
|
||||
const hitsQuery = genEditorAllQuery(dictionaryId)
|
||||
const hits = await searchEntryIndex(hitsQuery)
|
||||
|
||||
|
||||
@@ -218,11 +218,14 @@ extraction.begin = async (req, res) => {
|
||||
extractionLink
|
||||
}
|
||||
)
|
||||
const emailSubject = i18next.t('Luščenje končano', { lng: authorLanguage })
|
||||
await email.send({
|
||||
to: authorEmail,
|
||||
subject: i18next.t('Luščenje končano', { lng: authorLanguage }),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${authorEmail} (subject: ${emailSubject})`)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error)
|
||||
|
||||
@@ -18,7 +18,8 @@ users.listUsers = async (req, res) => {
|
||||
|
||||
const { pages_total: numberOfAllPages, results } = await User.fetchAll(
|
||||
resultsPerPage,
|
||||
page
|
||||
page,
|
||||
true
|
||||
)
|
||||
|
||||
res.send({ page, numberOfAllPages, results })
|
||||
@@ -63,11 +64,14 @@ users.updateBasicData = async (req, res) => {
|
||||
changeEmailLink
|
||||
}
|
||||
)
|
||||
const emailSubject = req.t('Sprememba elektronskega naslova')
|
||||
await email.send({
|
||||
to: newEmail,
|
||||
subject: req.t('Sprememba elektronskega naslova'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${newEmail} (subject: ${emailSubject})`)
|
||||
|
||||
const message =
|
||||
req.t(
|
||||
@@ -103,11 +107,14 @@ users.updatePassword = async (req, res) => {
|
||||
username: req.user.userName
|
||||
}
|
||||
)
|
||||
const emailSubject = req.t('Sprememba gesla')
|
||||
await email.send({
|
||||
to: req.user.email,
|
||||
subject: req.t('Sprememba gesla'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${req.user.email} (subject: ${emailSubject})`)
|
||||
|
||||
req.flash('info', 'Geslo je bilo spremenjeno.')
|
||||
res.send()
|
||||
|
||||
@@ -76,11 +76,14 @@ exports.minEntriesRequirementCheckAndAct = {
|
||||
})
|
||||
|
||||
// TODO i18n - What language are the email title and content (we already have email translated)
|
||||
const emailSubject = __('Obvestilo o številu gesel')
|
||||
await email.send({
|
||||
to: allEmails,
|
||||
subject: __('Obvestilo o številu gesel'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${allEmails} (subject: ${emailSubject})`)
|
||||
|
||||
await minEntriesEmailBookmark.set(dictionaryId)
|
||||
},
|
||||
@@ -207,9 +210,12 @@ async function renderAndSendStatusChangeEmails(
|
||||
})
|
||||
|
||||
// TODO i18n - What language are the email title and content (we already have email translated)
|
||||
const emailSubject = __('Sprememba stanja slovarja')
|
||||
await email.send({
|
||||
to: targetEmails,
|
||||
subject: __('Sprememba stanja slovarja'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${targetEmails} (subject: ${emailSubject})`)
|
||||
}
|
||||
|
||||
@@ -442,18 +442,31 @@ exports.entryDetails = async (req, res) => {
|
||||
}
|
||||
|
||||
/* entryData.entry.foreign_entries.forEach((val, idx) => {
|
||||
entry.foreignEntries[idx] = await
|
||||
entry.foreignEntries[idx] = await
|
||||
}) */
|
||||
|
||||
const langs = await Dictionary.fetchLanguages(
|
||||
const allowedLangauges = await Dictionary.fetchLanguages(
|
||||
entryData.dictionary_id,
|
||||
req.determinedLanguage
|
||||
)
|
||||
entryData.foreign_entries.forEach((val, idx) => {
|
||||
try {
|
||||
entry.foreign_entries[idx].name = langs[idx].name
|
||||
} catch (e) {}
|
||||
})
|
||||
const allowedLanguageIDs = allowedLangauges.reduce((agg, el, index) => {
|
||||
agg[el.id] = el.name
|
||||
|
||||
return agg
|
||||
}, {})
|
||||
|
||||
if (entryData.foreign_entries) {
|
||||
entryData.foreign_entries = entryData.foreign_entries.filter(item => {
|
||||
return Object.keys(allowedLanguageIDs).includes(`${item.language_id}`)
|
||||
})
|
||||
|
||||
entryData.foreign_entries.forEach((val, idx) => {
|
||||
try {
|
||||
entry.foreign_entries[idx].name =
|
||||
allowedLanguageIDs[entry.foreign_entries[idx].language_id]
|
||||
} catch (e) {}
|
||||
})
|
||||
}
|
||||
|
||||
res.render('pages/search/result-detail', {
|
||||
allPrimaryDomains,
|
||||
@@ -515,11 +528,14 @@ exports.changeEmail = async (req, res) => {
|
||||
username: user.username
|
||||
}
|
||||
)
|
||||
const emailSubject = req.t('Sprememba elektronskega naslova - uspeh')
|
||||
await email.send({
|
||||
to: user.email,
|
||||
subject: req.t('Sprememba elektronskega naslova - uspeh'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${user.email} (subject: ${emailSubject})`)
|
||||
|
||||
req.flash('info', req.t('Uspešno ste spremenili svoj elektronski naslov.'))
|
||||
if (req.user) return res.redirect(303, '/moj-racun')
|
||||
|
||||
@@ -2,6 +2,7 @@ const { randomBytes } = require('crypto')
|
||||
const { promisify } = require('util')
|
||||
const passport = require('passport')
|
||||
const User = require('../models/user')
|
||||
const Misc = require('../models/system/misc')
|
||||
const email = require('../models/email')
|
||||
const { logout: logoutUser } = require('../middleware/user')
|
||||
const { origin } = require('../config/keys')
|
||||
@@ -14,6 +15,11 @@ const user = {}
|
||||
user.register = async (req, res) => {
|
||||
// TODO Add validation.
|
||||
|
||||
if (req.body.userTag) {
|
||||
await Misc.logHoneypotCatch(req.body)
|
||||
return res.send(req.t('Registracija uspešna'))
|
||||
}
|
||||
|
||||
const userId = await User.create(
|
||||
{
|
||||
...req.body,
|
||||
@@ -32,11 +38,14 @@ user.register = async (req, res) => {
|
||||
username,
|
||||
activationLink
|
||||
})
|
||||
const emailSubject = req.t('Aktivacija računa')
|
||||
await email.send({
|
||||
to: userEmail,
|
||||
subject: req.t('Aktivacija računa'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${userEmail} (subject: ${emailSubject})`)
|
||||
res.send(req.t('Registracija uspešna'))
|
||||
}
|
||||
|
||||
@@ -136,11 +145,14 @@ user.generateResetPasswordToken = async (req, res) => {
|
||||
resetPasswordLink
|
||||
}
|
||||
)
|
||||
const emailSubject = req.t('Ponastavitev gesla')
|
||||
await email.send({
|
||||
to: userEmail,
|
||||
subject: req.t('Ponastavitev gesla'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${userEmail} (subject: ${emailSubject})`)
|
||||
res.send()
|
||||
}
|
||||
|
||||
@@ -162,11 +174,14 @@ user.changePassword = async (req, res) => {
|
||||
username: user.username
|
||||
}
|
||||
)
|
||||
const emailSubject = req.t('Uspešna ponastavitev gesla')
|
||||
await email.send({
|
||||
to: user.email,
|
||||
subject: req.t('Uspešna ponastavitev gesla'),
|
||||
subject: emailSubject,
|
||||
html: emailHtml
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Sent email to ${user.email} (subject: ${emailSubject})`)
|
||||
|
||||
req.flash('info', req.t('Vaše geslo je bilo uspešno ponastavljeno.'))
|
||||
|
||||
@@ -186,7 +201,8 @@ user.list = async (req, res) => {
|
||||
|
||||
const { pages_total: numberOfAllPages, results } = await User.fetchAll(
|
||||
resultsPerPage,
|
||||
1
|
||||
1,
|
||||
true
|
||||
)
|
||||
res.render('pages/admin/user-list', {
|
||||
title: req.t('Seznam uporabnikov'),
|
||||
|
||||
Reference in New Issue
Block a user