django-chelseru 2.0.1__tar.gz → 2.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_chelseru-2.0.1/django_chelseru.egg-info → django_chelseru-2.0.3}/PKG-INFO +1 -1
- {django_chelseru-2.0.1 → django_chelseru-2.0.3/django_chelseru.egg-info}/PKG-INFO +1 -1
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/services.py +6 -6
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/views.py +41 -10
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/setup.py +1 -1
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/LICENSE +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/MANIFEST.in +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/README.md +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/README_PA.md +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/django_chelseru.egg-info/SOURCES.txt +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/django_chelseru.egg-info/dependency_links.txt +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/django_chelseru.egg-info/requires.txt +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/django_chelseru.egg-info/top_level.txt +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/__init__.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/admin.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/apps.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/consumers.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/middlewares.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0001_initial.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0002_otpcode_session_user.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0004_rename_message_message_sms.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0005_rename_message_sms_messagesms_chatroom_messagechat.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0008_alter_chatroompermissions_user.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0009_alter_chatroom_status.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0012_payment.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0013_payment_authority_payment_data_payment_status_code.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0014_payment_gateway_title_payment_gateway_url.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0015_payment_message.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0016_payment_card_hash_payment_card_pan_and_more.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0017_alter_payment_callback_url_alter_payment_gateway_url.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0018_alter_payment_ref_id.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0019_payment_created_at_payment_status_payment_updated_at.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0020_payment_paid_at.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0021_alter_payment_message.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0022_payment_pay_mode_wallet.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/__init__.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/models.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/routing.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/serializers.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/settings.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/signals.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/tests.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/urls.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/validators.py +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/pyproject.toml +0 -0
- {django_chelseru-2.0.1 → django_chelseru-2.0.3}/setup.cfg +0 -0
|
@@ -124,22 +124,23 @@ class KavenegarCom:
|
|
|
124
124
|
def send_message_lookup(self, message, template_id, **kwargs):
|
|
125
125
|
try:
|
|
126
126
|
api_url = f'https://api.kavenegar.com/v1/{self.API_KEY}/verify/lookup.json'
|
|
127
|
+
message = ''.join(list(map(lambda x: x if x != ' ' else '-', message.strip())))
|
|
127
128
|
data = {
|
|
128
129
|
'receptor': self.RECEIVER,
|
|
129
130
|
'template': template_id,
|
|
130
|
-
'token': message
|
|
131
|
+
'token': message,
|
|
131
132
|
}
|
|
132
133
|
if kwargs.get('token2'):
|
|
133
|
-
data['token2'] = kwargs.get('token2').strip()
|
|
134
|
+
data['token2'] = ''.join(list(map(lambda x: x if x != ' ' else '-', kwargs.get('token2').strip())))
|
|
134
135
|
|
|
135
136
|
if kwargs.get('token3'):
|
|
136
|
-
data['token3'] = kwargs.get('token3').strip()
|
|
137
|
+
data['token3'] = ''.join(list(map(lambda x: x if x != ' ' else '-', kwargs.get('token3').strip())))
|
|
137
138
|
|
|
138
139
|
if kwargs.get('token10'):
|
|
139
|
-
data['token10'] = kwargs.get('token10')
|
|
140
|
+
data['token10'] = kwargs.get('token10').strip()
|
|
140
141
|
|
|
141
142
|
if kwargs.get('token20'):
|
|
142
|
-
data['token20'] = kwargs.get('token20')
|
|
143
|
+
data['token20'] = kwargs.get('token20').strip()
|
|
143
144
|
|
|
144
145
|
response = requests.post(url=api_url, data=data)
|
|
145
146
|
return response
|
|
@@ -259,7 +260,6 @@ def send_message(mobile_number, message_text, data=None, template_id=None):
|
|
|
259
260
|
else:
|
|
260
261
|
response = service.send_message(message=message_text)
|
|
261
262
|
|
|
262
|
-
print(response.json())
|
|
263
263
|
response_json = response.json()
|
|
264
264
|
entries = response_json.get('entries', [])
|
|
265
265
|
_return = response_json.get('return', {})
|
|
@@ -13,11 +13,18 @@ from .validators import mobile_number as mobile_validator
|
|
|
13
13
|
from .serializers import MessageSerializer, OTPCodeSerializer, SessionSerializer, ChatRoomSerializer, MessageChatSerializer, PaymentSerializer
|
|
14
14
|
from .models import User, ChatRoom
|
|
15
15
|
from django.utils.timezone import now, timedelta
|
|
16
|
-
from django.db import transaction
|
|
16
|
+
from django.db import transaction, IntegrityError, OperationalError
|
|
17
17
|
|
|
18
18
|
from django.conf import settings
|
|
19
19
|
from django.core.exceptions import ImproperlyConfigured
|
|
20
20
|
|
|
21
|
+
import traceback
|
|
22
|
+
import time
|
|
23
|
+
import logging
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
logger = logging.getlogger(__name__)
|
|
27
|
+
|
|
21
28
|
|
|
22
29
|
class MessageSend(APIView):
|
|
23
30
|
permission_classes = (AllowAny, )
|
|
@@ -164,18 +171,14 @@ class Authentication(APIView):
|
|
|
164
171
|
try:
|
|
165
172
|
if 'mobile_number' not in request.data:
|
|
166
173
|
return Response({'error': 'mobile_number is required.'}, status=HTTP_204_NO_CONTENT)
|
|
167
|
-
# assert 'mobile_number' in request.data, 'mobile_number is required.'
|
|
168
174
|
mobile_number = request.data['mobile_number']
|
|
169
175
|
if not mobile_number:
|
|
170
176
|
return Response({'error': 'mobile_number may not be blank.'}, status=HTTP_204_NO_CONTENT)
|
|
171
|
-
# assert mobile_number, 'mobile_number may not be blank.'
|
|
172
177
|
mobile_number_isvalid = mobile_validator(mobile_number)
|
|
173
178
|
if mobile_number_isvalid != True:
|
|
174
179
|
return Response({'error': mobile_number_isvalid}, status=HTTP_204_NO_CONTENT)
|
|
175
|
-
# assert mobile_number_isvalid == True, mobile_number_isvalid
|
|
176
180
|
if 'code' not in request.data:
|
|
177
181
|
return Response({'error': 'code is required.'}, status=HTTP_204_NO_CONTENT)
|
|
178
|
-
# assert 'code' in request.data, 'code is required.'
|
|
179
182
|
|
|
180
183
|
icheck = auth_init_check()
|
|
181
184
|
if icheck and isinstance(icheck, dict) and 'AUTH_SERVICE' in icheck and 'AUTH_METHOD' in icheck:
|
|
@@ -185,9 +188,36 @@ class Authentication(APIView):
|
|
|
185
188
|
return Response({'error': 'The code sent to this mobile number was not found.'}, status=HTTP_401_UNAUTHORIZED)
|
|
186
189
|
|
|
187
190
|
if otp.check_code():
|
|
191
|
+
user = None
|
|
188
192
|
# login / signup
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
try:
|
|
194
|
+
group = int(request.data.get('group'), 0)
|
|
195
|
+
except (ValueError, TypeError):
|
|
196
|
+
group = 0
|
|
197
|
+
|
|
198
|
+
try:
|
|
199
|
+
with transaction.atomic():
|
|
200
|
+
user, created = User.objects.get_or_create(mobile=mobile_number, group=group)
|
|
201
|
+
|
|
202
|
+
except IntegrityError as e:
|
|
203
|
+
logger.warning("IntegrityError on get_or_create for mobile=%s, group=%s: %s", mobile_number, group, e)
|
|
204
|
+
time.sleep(0.05)
|
|
205
|
+
try:
|
|
206
|
+
user = User.objects.get(mobile=mobile_number, group=group)
|
|
207
|
+
created = False
|
|
208
|
+
except User.DoesNotExist:
|
|
209
|
+
logger.error("After IntegrityError, user still not exists for mobile=%s. Trace: %s", mobile_number, traceback.format_exc())
|
|
210
|
+
return Response({'error': 'Server error while creating user.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
211
|
+
except OperationalError as e:
|
|
212
|
+
logger.error("OperationalError when accessing DB for mobile=%s: %s\n%s", mobile_number, e, traceback.format_exc())
|
|
213
|
+
return Response({'error': 'Database operational error, try again later.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
214
|
+
except Exception as e:
|
|
215
|
+
logger.exception("Unexpected error in user get_or_create for mobile=%s: %s", mobile_number, e)
|
|
216
|
+
return Response({'error': 'An internal error occurred.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# user, created = User.objects.get_or_create(mobile=mobile_number, group=group)
|
|
191
221
|
if user:
|
|
192
222
|
auth_method = icheck['AUTH_METHOD']
|
|
193
223
|
auth_service = icheck['AUTH_SERVICE']
|
|
@@ -206,9 +236,10 @@ class Authentication(APIView):
|
|
|
206
236
|
raise
|
|
207
237
|
except AssertionError as e:
|
|
208
238
|
return Response({'error': str(e)}, status=HTTP_204_NO_CONTENT)
|
|
209
|
-
except:
|
|
210
|
-
|
|
211
|
-
|
|
239
|
+
except Exception:
|
|
240
|
+
logger.exception("Error while creating tokens for user (mobile=%s). user object: %r", mobile_number, user)
|
|
241
|
+
return Response({'error': 'Token generation failed.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
|
|
242
|
+
# return Response({'error': 'An error occurred while generating or sending the otpcode, please contact the www.chelseru.com support team.'}, status=HTTP_500_INTERNAL_SERVER_ERROR)
|
|
212
243
|
|
|
213
244
|
|
|
214
245
|
class SessionList(ListAPIView):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/django_chelseru.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0002_otpcode_session_user.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0009_alter_chatroom_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0015_payment_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0018_alter_payment_ref_id.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0020_payment_paid_at.py
RENAMED
|
File without changes
|
{django_chelseru-2.0.1 → django_chelseru-2.0.3}/drfchelseru/migrations/0021_alter_payment_message.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|