mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
sending new users to peers on user creation
This commit is contained in:
parent
2f24f214b2
commit
cb0ad03336
9 changed files with 351 additions and 172 deletions
|
@ -30,6 +30,7 @@ import {
|
|||
Submodule,
|
||||
} from '../../../types/basicTypes'
|
||||
import dbtools from '../../../utils/dbtools'
|
||||
import { queueWork } from '../../../worker/workerPool'
|
||||
|
||||
const minimumAlowwedSessions = 2 // how many sessions are allowed for a user
|
||||
const usersDbBackupPath = 'data/dbs/backup'
|
||||
|
@ -150,12 +151,14 @@ function setup(data: SubmoduleData): Submodule {
|
|||
)
|
||||
|
||||
const pw = uuidv4()
|
||||
const insertRes = dbtools.Insert(userDB, 'users', {
|
||||
const newUser: Omit<User, 'id'> = {
|
||||
pw: pw,
|
||||
avaiblePWRequests: 0,
|
||||
created: new Date().getTime(),
|
||||
createdBy: requestingUser.id,
|
||||
})
|
||||
}
|
||||
|
||||
const insertRes = dbtools.Insert(userDB, 'users', newUser)
|
||||
|
||||
logger.Log(
|
||||
`User #${requestingUser.id} created new user #${insertRes.lastInsertRowid}`,
|
||||
|
@ -173,6 +176,13 @@ function setup(data: SubmoduleData): Submodule {
|
|||
dayDiff: getDayDiff(requestingUser.created),
|
||||
userCount: dbtools.TableInfo(userDB, 'users').dataCount,
|
||||
})
|
||||
|
||||
queueWork({
|
||||
type: 'sendUsersToPeers',
|
||||
data: {
|
||||
newUsers: [newUser],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
app.post('/login', (req: Request, res: any) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue