##// END OF EJS Templates
Removed old websocket related code (since websockets are no longer supported
neko259 -
r1948:be2714ff default
parent child Browse files
Show More
@@ -1,24 +1,22 b''
1 """
1 """
2 This module contains helper functions and helper classes.
2 This module contains helper functions and helper classes.
3 """
3 """
4 import hashlib
4 import time
5 import uuid
5 import uuid
6
6
7 from boards.abstracts.constants import FILE_DIRECTORY
7 import hashlib
8 from random import random
9 import time
10 import hmac
8 import hmac
11
9 import magic
10 import os
11 from django import forms
12 from django.core.cache import cache
12 from django.core.cache import cache
13 from django.db.models import Model
13 from django.db.models import Model
14 from django import forms
15 from django.template.defaultfilters import filesizeformat
14 from django.template.defaultfilters import filesizeformat
16 from django.utils import timezone
15 from django.utils import timezone
17 from django.utils.translation import ugettext_lazy as _
16 from django.utils.translation import ugettext_lazy as _
18 import magic
19 import os
20
17
21 import boards
18 import boards
19 from boards.abstracts.constants import FILE_DIRECTORY
22 from boards.settings import get_bool
20 from boards.settings import get_bool
23 from neboard import settings
21 from neboard import settings
24
22
@@ -58,20 +56,6 b' def datetime_to_epoch(datetime):'
58 * 1000000 + datetime.microsecond)
56 * 1000000 + datetime.microsecond)
59
57
60
58
61 def get_websocket_token(user_id='', timestamp=''):
62 """
63 Create token to validate information provided by new connection.
64 """
65
66 sign = hmac.new(settings.CENTRIFUGE_PROJECT_SECRET.encode())
67 sign.update(settings.CENTRIFUGE_PROJECT_ID.encode())
68 sign.update(user_id.encode())
69 sign.update(timestamp.encode())
70 token = sign.hexdigest()
71
72 return token
73
74
75 # TODO Test this carefully
59 # TODO Test this carefully
76 def cached_result(key_method=None):
60 def cached_result(key_method=None):
77 """
61 """
@@ -117,7 +101,7 b' def get_file_hash(file) -> str:'
117
101
118 def validate_file_size(size: int):
102 def validate_file_size(size: int):
119 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
103 max_size = boards.settings.get_int('Forms', 'MaxFileSize')
120 if max_size > 0 and size > max_size:
104 if 0 < max_size < size:
121 raise forms.ValidationError(
105 raise forms.ValidationError(
122 _('File must be less than %s but is %s.')
106 _('File must be less than %s but is %s.')
123 % (filesizeformat(max_size), filesizeformat(size)))
107 % (filesizeformat(max_size), filesizeformat(size)))
General Comments 0
You need to be logged in to leave comments. Login now