update Mo 15. Jun 22:31:01 CEST 2020
This commit is contained in:
parent
9425067cf3
commit
7ccbf0a7ac
@ -50,7 +50,7 @@ module.exports = function (io, sql, app_cfg, saver) {
|
||||
var app_id = raw_data.app_id;
|
||||
// nur speichern wenn app_id nicht eigenen globalen app_id entspricht
|
||||
if (app_id != app_cfg.global.app_id) {
|
||||
waip.rmld_speichern(data, remote_ip, function (result) {
|
||||
saver.save_new_rmld(data, remote_ip, app_id, function (result) {
|
||||
if (!result) {
|
||||
sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + remote_ip + ': ' + data);
|
||||
};
|
||||
@ -143,7 +143,7 @@ module.exports = function (io, sql, app_cfg, saver) {
|
||||
var app_id = raw_data.app_id;
|
||||
// nur speichern wenn app_id nicht eigenen globalen app_id entspricht
|
||||
if (app_id != app_cfg.global.app_id) {
|
||||
waip.rmld_speichern(data, app_cfg.endpoint.host, function (result) {
|
||||
saver.save_new_rmld(data, app_cfg.endpoint.host, app_id, function (result) {
|
||||
if (!result) {
|
||||
sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + app_cfg.endpoint.host + ': ' + JSON.stringify(data));
|
||||
};
|
||||
|
||||
@ -244,8 +244,10 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, udp, saver
|
||||
|
||||
// Rueckmeldung entgegennehmen
|
||||
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
|
||||
// Remote-IP erkennen, fuer Fehler-Auswertung
|
||||
var remote_ip = req.headers["x-real-ip"] || req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||
// auf Saver verweisen
|
||||
saver.save_new_rmld(req.body, null, 'web', function (result) {
|
||||
saver.save_new_rmld(req.body, remote_ip, 'web', function (result) {
|
||||
var waip_uuid = req.body.waip_uuid;
|
||||
var rmld_uuid = req.body.rmld_uuid;
|
||||
if (result) {
|
||||
|
||||
@ -61,14 +61,19 @@ module.exports = function (app_cfg, sql, waip, uuidv4) {
|
||||
function save_new_rmld(data, remote_addr, app_id, callback) {
|
||||
validate_rmld(data, function (valid) {
|
||||
if (valid) {
|
||||
|
||||
waip.rmld_speichern(data, app_id, function (result) {
|
||||
if (result) {
|
||||
sql.db_log('RMLD', 'Rückmeldung' + host + ' erhalten und gespeichert: ' + data);
|
||||
callback && callback(result);
|
||||
} else {
|
||||
sql.db_log('RMLD', 'Fehler beim speichern der Rückmeldung' + host + ': ' + rueckmeldung);
|
||||
callback && callback(result);
|
||||
};
|
||||
});
|
||||
} else {
|
||||
sql.db_log('RMLD', 'Fehler: Rückmeldung von nicht valide: ' + waip_data);
|
||||
sql.db_log('RMLD', 'Fehler: Rückmeldung von ' + remote_addr + ' nicht valide: ' + waip_data);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Funktion um zu pruefen, ob Nachricht im JSON-Format ist
|
||||
|
||||
@ -11,7 +11,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api) {
|
||||
sql.db_einsatz_speichern(einsatz_daten, function (waip_id) {
|
||||
sql.db_log('DEBUG', 'Neuen Einsatz mit der ID ' + waip_id + ' gespeichert.');
|
||||
|
||||
// FIXME hier ungewollte Einsaetze ggf. wieder loeschen
|
||||
// FIXME hier ungewollte Einsaetze ggf. wieder loeschen
|
||||
|
||||
// nach dem Speichern anhand der waip_id die beteiligten Wachennummern zum Einsatz ermitteln
|
||||
sql.db_einsatz_get_rooms(waip_id, function (socket_rooms) {
|
||||
@ -99,29 +99,19 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api) {
|
||||
});
|
||||
};
|
||||
|
||||
function rmld_speichern(rueckmeldung, host, callback) {
|
||||
function rmld_speichern(rueckmeldung, app_id, callback) {
|
||||
// Rueckmeldung speichern und verteilen
|
||||
proof.validate_rmld(rueckmeldung, function (valid) {
|
||||
if (valid) {
|
||||
if (!host == null) {
|
||||
host = ' von ' + host;
|
||||
};
|
||||
console.log(rueckmeldung);
|
||||
sql.db_rmld_save(rueckmeldung, function (result) {
|
||||
if (result) {
|
||||
rmld_verteilen_by_uuid(rueckmeldung.waip_uuid, rueckmeldung.rmld_uuid);
|
||||
sql.db_log('RMLD', 'Rückmeldung' + host + ' erhalten und gespeichert: ' + result);
|
||||
callback && callback(result);
|
||||
} else {
|
||||
sql.db_log('RMLD', 'Fehler beim speichern der Rückmeldung' + host + ': ' + rueckmeldung);
|
||||
callback && callback(result);
|
||||
};
|
||||
});
|
||||
sql.db_rmld_save(rueckmeldung, function (saved) {
|
||||
if (saved) {
|
||||
rmld_verteilen_by_uuid(rueckmeldung.waip_uuid, rueckmeldung.rmld_uuid);
|
||||
callback && callback(saved);
|
||||
} else {
|
||||
callback && callback(saved);
|
||||
};
|
||||
});
|
||||
// TODO TEST: Api WAIP
|
||||
api.server_to_client_new_rmld(req.body, 'web');
|
||||
api.client_to_server_new_rmld(req.body, 'web');
|
||||
api.server_to_client_new_rmld(req.body, app_id);
|
||||
api.client_to_server_new_rmld(req.body, app_id);
|
||||
};
|
||||
|
||||
function rmld_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||
@ -161,7 +151,7 @@ module.exports = function (io, sql, fs, brk, async, app_cfg, api) {
|
||||
// Rueckmeldung an einen bestimmten Client senden
|
||||
if (typeof socket.id !== 'undefined') {
|
||||
sql.db_rmld_get_fuer_wache(waip_id, wachen_id, function (rmld_obj) {
|
||||
if (rmld_obj) {
|
||||
if (rmld_obj) {
|
||||
// Rueckmeldung nur an den einen Socket senden
|
||||
socket.emit('io.new_rmld', rmld_obj);
|
||||
sql.db_log('RMLD', 'Vorhandene Rückmeldungen an Socket ' + socket.id + ' gesendet.');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user