handle bad user ids in mail ui better
This commit is contained in:
parent
e0f59784b1
commit
c2b7246048
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name" : "pms",
|
"name" : "pms",
|
||||||
"version" : "0.1.1",
|
"version" : "0.1.2",
|
||||||
"author" : "onionr"
|
"author" : "onionr"
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import notifier
|
|||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
plugin_name = 'pms'
|
plugin_name = 'pms'
|
||||||
PLUGIN_VERSION = '0.1.1'
|
PLUGIN_VERSION = '0.1.2'
|
||||||
|
|
||||||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
||||||
import sentboxdb, mailapi, loadinbox # import after path insert
|
import sentboxdb, mailapi, loadinbox # import after path insert
|
||||||
|
@ -62,7 +62,16 @@ function sendMail(toData, message, subject){
|
|||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
"token": webpass
|
"token": webpass
|
||||||
}})
|
}}).then(function(resp){
|
||||||
|
if (!resp.ok){
|
||||||
|
PNotify.error({
|
||||||
|
text: 'Malformed input'
|
||||||
|
})
|
||||||
|
sendForm.style.display = 'block'
|
||||||
|
throw new Error("Malformed input in sendmail")
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
})
|
||||||
.then((resp) => resp.text()) // Transform the data into text
|
.then((resp) => resp.text()) // Transform the data into text
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
sendForm.style.display = 'block'
|
sendForm.style.display = 'block'
|
||||||
@ -83,13 +92,18 @@ friendPicker.onchange = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendForm.onsubmit = function(){
|
sendForm.onsubmit = function(){
|
||||||
if (! to.value.includes("-") && to.value.length !== 56 && to.value.length !== 52){
|
let getInstances = function(string, word) {
|
||||||
PNotify.error({
|
return string.split(word).length - 1;
|
||||||
text: 'User ID is not valid'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
sendMail(to.value, messageContent.value, subject.value)
|
if(getInstances(to.value, '-') != 15){
|
||||||
|
if (to.value.length != 56 && to.value.length != 52){
|
||||||
|
PNotify.error({
|
||||||
|
text: 'User ID is not valid'
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
sendMail(to.value, messageContent.value, subject.value)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user