1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Implement contact form on server side

This commit is contained in:
Chocobozzz 2019-01-09 15:14:29 +01:00
parent 8d00889b60
commit a4101923e6
No known key found for this signature in database
GPG key ID: 583A612D890159BE
32 changed files with 541 additions and 49 deletions

View file

@ -2,7 +2,13 @@ import * as express from 'express'
import { createClient, RedisClient } from 'redis'
import { logger } from '../helpers/logger'
import { generateRandomString } from '../helpers/utils'
import { CONFIG, USER_PASSWORD_RESET_LIFETIME, USER_EMAIL_VERIFY_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers'
import {
CONFIG,
CONTACT_FORM_LIFETIME,
USER_EMAIL_VERIFY_LIFETIME,
USER_PASSWORD_RESET_LIFETIME,
VIDEO_VIEW_LIFETIME
} from '../initializers'
type CachedRoute = {
body: string,
@ -76,6 +82,16 @@ class Redis {
return this.getValue(this.generateVerifyEmailKey(userId))
}
/************* Contact form per IP *************/
async setContactFormIp (ip: string) {
return this.setValue(this.generateContactFormKey(ip), '1', CONTACT_FORM_LIFETIME)
}
async isContactFormIpExists (ip: string) {
return this.exists(this.generateContactFormKey(ip))
}
/************* Views per IP *************/
setIPVideoView (ip: string, videoUUID: string) {
@ -175,7 +191,11 @@ class Redis {
}
private generateViewKey (ip: string, videoUUID: string) {
return videoUUID + '-' + ip
return `views-${videoUUID}-${ip}`
}
private generateContactFormKey (ip: string) {
return 'contact-form-' + ip
}
/************* Redis helpers *************/