send contact message
This commit is contained in:
parent
f1ba3fbd34
commit
cfbc90b50b
2 changed files with 36 additions and 3 deletions
|
@ -14,6 +14,7 @@ from utils import update_dict
|
|||
from . import models
|
||||
import settings
|
||||
import state
|
||||
import tor_request
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -412,3 +413,27 @@ def getActivity(data):
|
|||
'''
|
||||
return state.activity
|
||||
actions.register(getActivity, cache=False)
|
||||
|
||||
def contact(data):
|
||||
'''
|
||||
return {
|
||||
}
|
||||
'''
|
||||
response = {}
|
||||
url = 'http://rnogx24drkbnrxa3.onion/contact'
|
||||
headers = {
|
||||
'User-Agent': settings.USER_AGENT,
|
||||
}
|
||||
try:
|
||||
data = json.dumps(data).encode()
|
||||
opener = tor_request.get_opener()
|
||||
opener.addheaders = list(zip(headers.keys(), headers.values()))
|
||||
r = opener.open(url, data)
|
||||
error = r.status != 200
|
||||
except:
|
||||
logger.debug('failed to send contact', exc_info=True)
|
||||
error = True
|
||||
if error:
|
||||
response = {'error': True}
|
||||
return response
|
||||
actions.register(contact, cache=False)
|
||||
|
|
|
@ -96,6 +96,12 @@ oml.ui.contactForm = function() {
|
|||
subject: data.subject,
|
||||
message: data.message,
|
||||
}, function(result) {
|
||||
var title = Ox._('Message Sent'),
|
||||
content = Ox._('Thanks for your message!<br/><br/>We will get back to you as soon as possible.');
|
||||
if (result.error) {
|
||||
title = Ox._('Error');
|
||||
content = Ox._('Sorry. There was an error sending your message. Please try again later.');
|
||||
}
|
||||
var $dialog = oml.ui.iconDialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
|
@ -104,13 +110,15 @@ oml.ui.contactForm = function() {
|
|||
}).bindEvent({
|
||||
click: function() {
|
||||
$dialog.close();
|
||||
$form.values({subject: '', message: ''});
|
||||
if (!result.error) {
|
||||
$form.values({subject: '', message: ''});
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
content: Ox._('Thanks for your message!<br/><br/>We will get back to you as soon as possible.'),
|
||||
content: content,
|
||||
keys: {enter: 'close', escape: 'close'},
|
||||
title: Ox._('Message Sent')
|
||||
title: title
|
||||
})
|
||||
.open();
|
||||
$sendButton.options({
|
||||
|
|
Loading…
Reference in a new issue