mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
fixed content type check, added bit more logging on getnewdata since ep
This commit is contained in:
parent
b1e89249b4
commit
f1a88b7ff5
4 changed files with 26 additions and 7 deletions
|
@ -533,7 +533,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
}
|
||||
|
||||
function getNewUsersSince(since: number) {
|
||||
const users = dbtools.runStatement(
|
||||
const users: User[] = dbtools.runStatement(
|
||||
userDB,
|
||||
`SELECT *
|
||||
FROM users
|
||||
|
@ -774,6 +774,8 @@ function setup(data: SubmoduleData): Submodule {
|
|||
}
|
||||
const newUserCount = dbtools.SelectAll(userDB, 'users').length
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
const hasNewData = resultData.length > 0
|
||||
if (!hasNewData) {
|
||||
logger.Log(
|
||||
|
@ -996,6 +998,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
}
|
||||
|
||||
let hostToLog = remoteHost || 'Unknown host'
|
||||
let sentUsers = 0
|
||||
if (remoteHost) {
|
||||
const remotePeerInfo = peers.find((peer) => {
|
||||
return peerToString(peer) === remoteHost
|
||||
|
@ -1006,12 +1009,14 @@ function setup(data: SubmoduleData): Submodule {
|
|||
if (remotePublicKey) {
|
||||
// FIXME: sign data?
|
||||
const newUsers = getNewUsersSince(since)
|
||||
sentUsers = newUsers.length
|
||||
result.encryptedUsers = encrypt(
|
||||
remotePublicKey,
|
||||
JSON.stringify(newUsers)
|
||||
)
|
||||
// TODO: count sent user count
|
||||
logger.Log(
|
||||
`Sending new users to "${remoteHost}" (encrypted)`,
|
||||
`\tSending new users to "${remoteHost}" (encrypted)`,
|
||||
'green'
|
||||
)
|
||||
} else if (remotePeerInfo) {
|
||||
|
@ -1045,13 +1050,26 @@ function setup(data: SubmoduleData): Submodule {
|
|||
? 'all time'
|
||||
: new Date(since).toLocaleString()
|
||||
|
||||
// TODO: count sent data
|
||||
logger.Log(
|
||||
`Sending new data to ${logger.C(
|
||||
`\tSending new data to ${logger.C(
|
||||
'blue'
|
||||
)}${hostToLog}${logger.C()} since ${logger.C(
|
||||
'blue'
|
||||
)}${dateToLog}${logger.C()} `
|
||||
)
|
||||
logger.logTable(
|
||||
[
|
||||
['Users', 'QDBs', 'Subjs', 'Questions'],
|
||||
[
|
||||
sentUsers,
|
||||
questionDbsWithNewQuestions.length,
|
||||
subjects,
|
||||
questions,
|
||||
],
|
||||
],
|
||||
{ rowPrefix: '\t' }
|
||||
)
|
||||
|
||||
res.json(result)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue