diff --git a/app/API/messages.py b/app/API/messages.py
index edeed9e..369ad86 100644
--- a/app/API/messages.py
+++ b/app/API/messages.py
@@ -155,4 +155,45 @@ def send_message(register_id, register_r, oun, s, date, school_year, symbol, sen
send = sess.post(f'{link}/NowaWiadomosc.mvc/InsertWiadomosc', data=json.dumps(payload))
- return send.json()
\ No newline at end of file
+ return send.json()
+
+def get_message_content(register_id, register_r, oun, s, date, school_year, symbol, message_id):
+ headers = {
+ 'Accept-Encoding': 'gzip, deflate, br',
+ 'Accept': '*/*',
+ 'Connection': 'keep-alive',
+ "User-Agent": "Wulkanowy-web :)"
+ }
+
+ if oun == 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458':
+ link = f'http://uonetplus-uzytkownik.fakelog.cf/{symbol}'
+ else:
+ link = f'https://uonetplus-uzytkownik.vulcan.net.pl/{symbol}'
+
+ sess = requests.Session()
+
+ sess.cookies.update(s)
+ sess.headers.update(headers)
+
+ index = sess.get(link)
+
+ antiForgeryToken = re.search("antiForgeryToken: '(.)*'", index.text)
+ antiForgeryToken = antiForgeryToken.group()
+ antiForgeryToken = antiForgeryToken.replace('antiForgeryToken: ', '').replace("'", "")
+
+ appGuid = re.search("appGuid: '(.)*'", index.text)
+ appGuid = appGuid.group()
+ appGuid = appGuid.replace('appGuid: ', '').replace("'", "")
+
+ sess.headers.update({
+ 'X-V-RequestVerificationToken': antiForgeryToken,
+ 'X-V-AppGuid': appGuid
+ })
+
+ payload = {
+ 'messageId': message_id
+ }
+
+ content = sess.post(f'{link}/Wiadomosc.mvc/GetInboxMessageDetails', data=json.dumps(payload))
+
+ return content.json()
\ No newline at end of file
diff --git a/app/views.py b/app/views.py
index 9db07e0..b00a057 100644
--- a/app/views.py
+++ b/app/views.py
@@ -14,7 +14,7 @@ from .API.exams import get_exams
from .API.timetable import get_timetable
from .API.notes import get_notes
from .API.attendance import get_attendance
-from .API.messages import get_received_messages, get_sent_messages, get_deleted_messages, get_recipients, send_message
+from .API.messages import get_received_messages, get_sent_messages, get_deleted_messages, get_recipients, send_message, get_message_content
from .API.homeworks import get_homeworks
from .API.mobile_access import get_registered_devices, register_device
from .API.school_data import get_school_data
@@ -293,5 +293,24 @@ def send(request, *args, **kwargs):
send_data = {'data': data['data'], 'subject': data['subject'], 'content': data['content']}
send = send_message(register_id, register_r, oun, s, date, school_year, symbol, send_data)
return JsonResponse(send, safe=False)
+ else:
+ return redirect('../')
+
+def message_content(request, *args, **kwargs):
+ if request.session.has_key('is_logged'):
+ data = json.loads(request.body)
+ cookies_data = json.loads(data['cookies_data'])
+ register_id = cookies_data['data']['register_id']
+ register_r = cookies_data['data']['register_r']
+ oun = cookies_data['data']['oun']
+ s = cookies_data['data']['s']
+ key = bytes(request.session[request.session.session_key], 'utf-8')
+ s = decrypt_cookies(s, key)
+ date = cookies_data['data']['date']
+ school_year = cookies_data['data']['school_year']
+ symbol = cookies_data['data']['symbol']
+ message_id = data['message_id']
+ content = get_message_content(register_id, register_r, oun, s, date, school_year, symbol, message_id)
+ return JsonResponse(content, safe=False)
else:
return redirect('../')
\ No newline at end of file
diff --git a/files/js/messages.js b/files/js/messages.js
index 15a0876..cf646ba 100644
--- a/files/js/messages.js
+++ b/files/js/messages.js
@@ -52,6 +52,8 @@ const getReceivedMessages = () => {
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `${wiadomosc.Data}`
wiadomoscRow.appendChild(dataWyslania)
+
+ document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
@@ -103,6 +105,8 @@ const getSentMessages = () => {
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `${wiadomosc.Data}`
wiadomoscRow.appendChild(dataWyslania)
+
+ document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
@@ -154,6 +158,8 @@ const getDeletedMessages = () => {
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `${wiadomosc.Data}`
wiadomoscRow.appendChild(dataWyslania)
+
+ document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
@@ -224,6 +230,24 @@ const sendMessage = () => {
}
+const getMessageContent = (event) => {
+ send_data = {
+ 'cookies_data': cookies_data,
+ 'message_id': event.target.id
+ }
+ fetch(url = '../api/messages/content', {
+ method: 'POST',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-CSRFToken': csrfcookie_
+ },
+ body: JSON.stringify(send_data)
+ }).then(response => response.json()).then(data => {
+ console.log(data)
+ })
+}
+
received_.addEventListener('click', getReceivedMessages);
sent_.addEventListener('click', getSentMessages);
diff --git a/wulkanowy/urls.py b/wulkanowy/urls.py
index e8cf591..f233c26 100644
--- a/wulkanowy/urls.py
+++ b/wulkanowy/urls.py
@@ -17,7 +17,7 @@ from django.urls import path
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from app.views import default_view, content_view
-from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send
+from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send, message_content
urlpatterns = [
#views
@@ -42,6 +42,7 @@ urlpatterns = [
path('api/messages/deleted', deleted_messages, name='deleted_messages'),
path('api/messages/recipients', recipients, name='recipients'),
path('api/messages/send', send, name='send_message'),
+ path('api/messages/content', message_content, name='message_content'),
]
urlpatterns += staticfiles_urlpatterns()
\ No newline at end of file