Keep track of the names a node has been using
This commit is contained in:
parent
99e31d8692
commit
6210f04ea5
3 changed files with 59 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `name_history` (
|
||||||
|
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||||
|
`node_id` BIGINT NOT NULL,
|
||||||
|
`long_name` VARCHAR(191) NOT NULL,
|
||||||
|
`short_name` VARCHAR(191) NOT NULL,
|
||||||
|
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
|
|
||||||
|
INDEX `name_history_node_id_idx`(`node_id`),
|
||||||
|
INDEX `name_history_long_name_idx`(`long_name`),
|
||||||
|
INDEX `name_history_created_at_idx`(`created_at`),
|
||||||
|
INDEX `name_history_updated_at_idx`(`updated_at`),
|
||||||
|
UNIQUE INDEX `name_history_node_id_long_name_short_name_key`(`node_id`, `long_name`, `short_name`),
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
|
|
@ -302,6 +302,26 @@ model Waypoint {
|
||||||
@@map("waypoints")
|
@@map("waypoints")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model NameHistory {
|
||||||
|
id BigInt @id @default(autoincrement())
|
||||||
|
node_id BigInt
|
||||||
|
long_name String
|
||||||
|
short_name String
|
||||||
|
|
||||||
|
created_at DateTime @default(now())
|
||||||
|
updated_at DateTime @default(now()) @updatedAt
|
||||||
|
|
||||||
|
@@index(node_id)
|
||||||
|
@@index(long_name)
|
||||||
|
|
||||||
|
@@index(created_at)
|
||||||
|
@@index(updated_at)
|
||||||
|
@@map("name_history")
|
||||||
|
|
||||||
|
// We only want to keep track of unique name and node_id combinations
|
||||||
|
@@unique([node_id, long_name, short_name])
|
||||||
|
}
|
||||||
|
|
||||||
model BatteryStats {
|
model BatteryStats {
|
||||||
id BigInt @id @default(autoincrement())
|
id BigInt @id @default(autoincrement())
|
||||||
recorded_at DateTime? @default(now())
|
recorded_at DateTime? @default(now())
|
||||||
|
|
|
||||||
23
src/mqtt.js
23
src/mqtt.js
|
|
@ -222,6 +222,7 @@ const collectNeighbourInfo = options["collect-neighbour-info"] ?? false;
|
||||||
const collectMapReports = options["collect-map-reports"] ?? false;
|
const collectMapReports = options["collect-map-reports"] ?? false;
|
||||||
const decryptionKeys = options["decryption-keys"] ?? [
|
const decryptionKeys = options["decryption-keys"] ?? [
|
||||||
"1PG7OiApB1nwvP+rz05pAQ==", // add default "AQ==" decryption key
|
"1PG7OiApB1nwvP+rz05pAQ==", // add default "AQ==" decryption key
|
||||||
|
"PjG/mVAqnannyvqmuYAwd0LZa1AV+wkcUQlacmexEXY=", // Årsta mesh? länkad av [x/0!] divideByZero i meshen
|
||||||
];
|
];
|
||||||
const dropPacketsNotOkToMqtt = options["drop-packets-not-ok-to-mqtt"] ?? false;
|
const dropPacketsNotOkToMqtt = options["drop-packets-not-ok-to-mqtt"] ?? false;
|
||||||
const dropPortnumsWithoutBitfield = options["drop-portnums-without-bitfield"] ?? null;
|
const dropPortnumsWithoutBitfield = options["drop-portnums-without-bitfield"] ?? null;
|
||||||
|
|
@ -960,6 +961,28 @@ client.on("message", async (topic, message) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep track of the names a node has been using.
|
||||||
|
try {
|
||||||
|
await prisma.NameHistory.upsert({
|
||||||
|
where: {
|
||||||
|
node_id_long_name_short_name: {
|
||||||
|
node_id: envelope.packet.from,
|
||||||
|
long_name: user.longName,
|
||||||
|
short_name: user.shortName,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
node_id: envelope.packet.from,
|
||||||
|
long_name: user.longName,
|
||||||
|
short_name: user.shortName,
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
updated_at: new Date(),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(portnum === 8) {
|
else if(portnum === 8) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue