Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
message-service
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit ce8b606d
authored
2024-06-06 11:37:42 -0300
by
juan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
filtra mail destino ansi
1 parent
23e50b59
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletions
services.py
services.py
View file @
ce8b606
...
@@ -9,6 +9,19 @@ from ValidacionTelefonos import ValidacionTelefonosArgentinos, ValidacionCorreo
...
@@ -9,6 +9,19 @@ from ValidacionTelefonos import ValidacionTelefonosArgentinos, ValidacionCorreo
import
requests
,
json
,
os
,
smtplib
,
config
,
base64
import
requests
,
json
,
os
,
smtplib
,
config
,
base64
import
SmsGateway24
as
Sms
import
SmsGateway24
as
Sms
import
re
def
filtrar_no_ascii
(
texto
):
# Usar una expresión regular para encontrar todos los caracteres que no son ASCII
texto
=
str
(
texto
)
.
replace
(
" "
,
""
)
texto
=
str
(
texto
)
.
replace
(
"
\n
"
,
""
)
texto
=
str
(
texto
)
.
replace
(
"
\t
"
,
""
)
return
re
.
sub
(
r'[^\x00-\x7F]'
,
''
,
texto
)
# Ejemplo de uso
#texto_original = "Correo desde un usuario con caracteres especiales: é, ñ
class
ServiceBase
(
ABC
):
class
ServiceBase
(
ABC
):
# Método para enviar un mensaje
# Método para enviar un mensaje
...
@@ -128,6 +141,14 @@ class Mail(ServiceBase):
...
@@ -128,6 +141,14 @@ class Mail(ServiceBase):
host
=
info
[
"smtp"
][
"host"
]
host
=
info
[
"smtp"
][
"host"
]
except
:
except
:
host
=
False
host
=
False
#print("info",info)
#try:
# info["destino"] = filtrar_no_ascii(info["destino"])
#except Exception as E:
# print(E)
#Aca inserto deteccion de multiples objetivos
#Aca inserto deteccion de multiples objetivos
if
host
==
"MAILMASIVO"
:
if
host
==
"MAILMASIVO"
:
res
=
self
.
sendGrid
(
info
,
data
)
res
=
self
.
sendGrid
(
info
,
data
)
...
@@ -145,7 +166,7 @@ class Mail(ServiceBase):
...
@@ -145,7 +166,7 @@ class Mail(ServiceBase):
destino
=
data
[
Table
.
dest
]
destino
=
data
[
Table
.
dest
]
#print(destino)
#print(destino)
msg
[
'Subject'
]
=
info
[
'subject'
]
msg
[
'Subject'
]
=
info
[
'subject'
]
msg
[
"To"
]
=
Cr
.
ValidarCorreo
(
destino
)
msg
[
"To"
]
=
filtrar_no_ascii
(
Cr
.
ValidarCorreo
(
destino
)
)
print
(
"destino"
,
msg
[
"To"
])
print
(
"destino"
,
msg
[
"To"
])
succ
=
{}
succ
=
{}
if
msg
[
'To'
]
==
False
:
if
msg
[
'To'
]
==
False
:
...
@@ -170,6 +191,7 @@ class Mail(ServiceBase):
...
@@ -170,6 +191,7 @@ class Mail(ServiceBase):
succ
[
file
]
=
False
succ
[
file
]
=
False
except
Exception
as
E
:
except
Exception
as
E
:
print
(
f
"ROMPIO ALGO EN EL ENVIO: {E}"
)
print
(
f
"ROMPIO ALGO EN EL ENVIO: {E}"
)
#tenemos q filtrar from
stadomail
.
MailRompedor
.
append
(
msg
[
'From'
])
stadomail
.
MailRompedor
.
append
(
msg
[
'From'
])
succ
[
file
]
=
False
succ
[
file
]
=
False
return
succ
return
succ
...
@@ -303,6 +325,11 @@ class Mail(ServiceBase):
...
@@ -303,6 +325,11 @@ class Mail(ServiceBase):
for
param
in
i
:
for
param
in
i
:
if
param
not
in
Mail
.
Parameters
:
if
param
not
in
Mail
.
Parameters
:
return
False
return
False
##############limpio fron y to ##########
#i["from"] = filtrar_no_ascii(i["from"])
#i["destino"] = filtrar_no_ascii(i["to"])
#info = json.dumps(i)#reemplaso los datos
#print(i)
return
True
return
True
class
SMS
(
ServiceBase
):
class
SMS
(
ServiceBase
):
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment