fix: move to boot
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
1f2017c272
commit
ff33c926af
|
@ -1,3 +1,5 @@
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('sendCheckingPresence', {
|
Self.remoteMethodCtx('sendCheckingPresence', {
|
||||||
description: 'Creates a message in the chat model checking the user status',
|
description: 'Creates a message in the chat model checking the user status',
|
||||||
|
@ -37,7 +39,7 @@ module.exports = Self => {
|
||||||
if (!recipient)
|
if (!recipient)
|
||||||
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`);
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction())
|
if (!isProduction())
|
||||||
message = `[Test:Environment to user ${userId}] ` + message;
|
message = `[Test:Environment to user ${userId}] ` + message;
|
||||||
|
|
||||||
const chat = await models.Chat.create({
|
const chat = await models.Chat.create({
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('sendQueued', {
|
Self.remoteMethodCtx('sendQueued', {
|
||||||
description: 'Send a RocketChat message',
|
description: 'Send a RocketChat message',
|
||||||
|
@ -94,7 +96,7 @@ module.exports = Self => {
|
||||||
* @return {Promise} - The request promise
|
* @return {Promise} - The request promise
|
||||||
*/
|
*/
|
||||||
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
Self.sendMessage = async function sendMessage(senderFk, recipient, message) {
|
||||||
if (!Self.app.models.Application.isProduction(false)) {
|
if (!isProduction(false)) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return resolve({
|
return resolve({
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
|
@ -149,7 +151,7 @@ module.exports = Self => {
|
||||||
* @return {Promise} - The request promise
|
* @return {Promise} - The request promise
|
||||||
*/
|
*/
|
||||||
Self.getUserStatus = async function getUserStatus(username) {
|
Self.getUserStatus = async function getUserStatus(username) {
|
||||||
if (!Self.app.models.Application.isProduction(false)) {
|
if (!isProduction(false)) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
return resolve({
|
return resolve({
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('deleteTrashFiles', {
|
Self.remoteMethod('deleteTrashFiles', {
|
||||||
|
@ -22,7 +23,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction())
|
if (!isProduction())
|
||||||
throw new UserError(`Action not allowed on the test environment`);
|
throw new UserError(`Action not allowed on the test environment`);
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
|
@ -119,7 +120,7 @@ module.exports = Self => {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction(false))
|
if (!isProduction(false))
|
||||||
throw new UserError('Action not allowed on the test environment');
|
throw new UserError('Action not allowed on the test environment');
|
||||||
|
|
||||||
// delete old
|
// delete old
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('scrub', {
|
Self.remoteMethod('scrub', {
|
||||||
|
@ -43,7 +44,7 @@ module.exports = Self => {
|
||||||
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
Self.scrub = async function(collection, remove, limit, dryRun, skipLock) {
|
||||||
const $ = Self.app.models;
|
const $ = Self.app.models;
|
||||||
|
|
||||||
dryRun = dryRun || !Self.app.models.Application.isProduction(false);
|
dryRun = dryRun || !isProduction(false);
|
||||||
|
|
||||||
const instance = await $.ImageCollection.findOne({
|
const instance = await $.ImageCollection.findOne({
|
||||||
fields: ['id'],
|
fields: ['id'],
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
|
@ -41,7 +42,7 @@ module.exports = Self => {
|
||||||
if (!hasWriteRole)
|
if (!hasWriteRole)
|
||||||
throw new UserError(`You don't have enough privileges`);
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction())
|
if (!isProduction())
|
||||||
throw new UserError(`Action not allowed on the test environment`);
|
throw new UserError(`Action not allowed on the test environment`);
|
||||||
|
|
||||||
// Upload file to temporary path
|
// Upload file to temporary path
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const {Email} = require('vn-print');
|
const {Email} = require('vn-print');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('send', {
|
Self.remoteMethod('send', {
|
||||||
|
@ -70,7 +71,7 @@ module.exports = Self => {
|
||||||
const newParams = Object.assign({}, queueParams, sendParams);
|
const newParams = Object.assign({}, queueParams, sendParams);
|
||||||
const email = new Email(queueName, newParams);
|
const email = new Email(queueName, newParams);
|
||||||
|
|
||||||
if (Self.app.models.Application.isProduction())
|
if (isProduction())
|
||||||
await email.send();
|
await email.send();
|
||||||
|
|
||||||
await queue.updateAttribute('status', statusSent);
|
await queue.updateAttribute('status', statusSent);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const isProductionFn = require('../methods/application/isProduction');
|
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/application/status')(Self);
|
require('../methods/application/status')(Self);
|
||||||
require('../methods/application/post')(Self);
|
require('../methods/application/post')(Self);
|
||||||
|
@ -7,8 +5,4 @@ module.exports = function(Self) {
|
||||||
require('../methods/application/executeProc')(Self);
|
require('../methods/application/executeProc')(Self);
|
||||||
require('../methods/application/executeFunc')(Self);
|
require('../methods/application/executeFunc')(Self);
|
||||||
require('../methods/application/getEnumValues')(Self);
|
require('../methods/application/getEnumValues')(Self);
|
||||||
|
|
||||||
Self.isProduction = (localAsProduction = true) => {
|
|
||||||
return isProductionFn(localAsProduction);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
|
||||||
const ldap = require('../util/ldapjs-extra');
|
const ldap = require('../util/ldapjs-extra');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const nthash = require('smbhash').nthash;
|
const nthash = require('smbhash').nthash;
|
||||||
const isProduction = require('vn-loopback/common/methods/application/isProduction');
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
const shouldSync = isProduction();
|
const shouldSync = isProduction();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
const ldap = require('../util/ldapjs-extra');
|
const ldap = require('../util/ldapjs-extra');
|
||||||
const execFile = require('child_process').execFile;
|
const execFile = require('child_process').execFile;
|
||||||
const isProduction = require('vn-loopback/common/methods/application/isProduction');
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of userAccountControl flags:
|
* Summary of userAccountControl flags:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('send', {
|
Self.remoteMethod('send', {
|
||||||
|
@ -47,7 +48,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
if (!Self.app.models.Application.isProduction(false))
|
if (!isProduction(false))
|
||||||
response = {result: [{status: 'ok'}]};
|
response = {result: [{status: 'ok'}]};
|
||||||
else {
|
else {
|
||||||
const jsonTest = {
|
const jsonTest = {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('download', {
|
Self.remoteMethodCtx('download', {
|
||||||
|
@ -66,7 +67,7 @@ module.exports = Self => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction()) {
|
if (!isProduction()) {
|
||||||
try {
|
try {
|
||||||
await fs.access(file.path);
|
await fs.access(file.path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const print = require('vn-print');
|
const print = require('vn-print');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/invoiceOut/filter')(Self);
|
require('../methods/invoiceOut/filter')(Self);
|
||||||
|
@ -59,7 +60,7 @@ module.exports = Self => {
|
||||||
hasPdf: true
|
hasPdf: true
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
if (Self.app.models.Application.isProduction()) {
|
if (isProduction()) {
|
||||||
await print.storage.write(buffer, {
|
await print.storage.write(buffer, {
|
||||||
type: 'invoice',
|
type: 'invoice',
|
||||||
path: pdfFile.path,
|
path: pdfFile.path,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
const isProduction = require('vn-loopback/server/boot/isProduction');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('upload', {
|
Self.remoteMethodCtx('upload', {
|
||||||
|
@ -111,7 +112,7 @@ module.exports = Self => {
|
||||||
const destinationFile = path.join(
|
const destinationFile = path.join(
|
||||||
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
|
accessContainer.client.root, accessContainer.name, appName, `${toVersion}.7z`);
|
||||||
|
|
||||||
if (!Self.app.models.Application.isProduction())
|
if (!isProduction())
|
||||||
await fs.unlink(srcFile);
|
await fs.unlink(srcFile);
|
||||||
else {
|
else {
|
||||||
await fs.move(srcFile, destinationFile, {
|
await fs.move(srcFile, destinationFile, {
|
||||||
|
|
Loading…
Reference in New Issue