fix: refs #7025 rollback
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-04-23 16:59:22 +02:00
parent d94f37f1f9
commit f087a2c318
2 changed files with 2 additions and 20 deletions

View File

@ -11,8 +11,6 @@ module.exports = Self => {
require('../methods/entry/addFromBuy')(Self);
Self.observe('before save', async function(ctx, options) {
const models = Self.app.models;
if (ctx.isNewInstance) return;
const changes = ctx.data || ctx.instance;
@ -23,21 +21,6 @@ module.exports = Self => {
const observationChanged = hasChanges
&& orgData.observation != observation;
const loopbackContext = LoopBackContext.getCurrentContext();
const userId = loopbackContext.active.accessToken.userId;
if (orgData.isConfirmed && orgData.editorFk) {
const {name} = await models.VnUser.findById(orgData.editorFk, null);
const to = `@${name}`;
let message = `<h1>Changes</h1><ul>`;
for (const [key, value] of Object.entries(changes)) message += `<li>${key}: ${value}</li>`;
message += '</ul>';
ctx.req = loopbackContext.active;
await models.Chat.send(ctx, to, message);
}
if (observationChanged) {
let tx;
const myOptions = {};
@ -51,6 +34,8 @@ module.exports = Self => {
}
try {
const loopbackContext = LoopBackContext.getCurrentContext();
const userId = loopbackContext.active.accessToken.userId;
const id = changes.id || orgData.id;
const entry = await Self.app.models.Entry.findById(id, null, myOptions);
await entry.updateAttribute('observationEditorFk', userId, myOptions);

View File

@ -74,9 +74,6 @@
},
"observationEditorFk": {
"type": "number"
},
"editorFk": {
"type": "number"
}
},
"relations": {