Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

Commit a1dc29a

Browse files
authored
Update application.js
1 parent 12b43b0 commit a1dc29a

File tree

1 file changed

+13
-42
lines changed

1 file changed

+13
-42
lines changed

capstone/static/capstone/application.js

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -110,48 +110,19 @@ document.addEventListener('DOMContentLoaded', () => {
110110
if (!message){
111111
return false;
112112
}
113-
let users = []
114-
const request = new Request(
115-
'/ajax/roomdata',
116-
{headers: {'X-CSRFToken': csrf}}
117-
);
118-
fetch(request, {
119-
"method": "POST",
120-
"body": JSON.stringify({
121-
"roomid": path[2]
122-
})
123-
})
124-
.then(response => response.json())
125-
.then(result => {
126-
for(member in result.members) {
127-
let user = result.members[member]
128-
const request = new Request(
129-
'/ajax/getkey',
130-
{headers: {'X-CSRFToken': csrf}}
131-
)
132-
fetch(request, {
133-
"method": "POST",
134-
"body": JSON.stringify({
135-
"user": user
136-
})
137-
})
138-
.then(response => response.json())
139-
.then(result => {
140-
const cipher = cryptico.encrypt(message,result.key,privatekey)
141-
chatSocket.send(JSON.stringify({
142-
"message":JSON.stringify({
143-
"roomid": path[2],
144-
"publickey": result.key,
145-
"sender": currentuser,
146-
"body": cipher.cipher,
147-
"recipient": user,
148-
})
149-
}))
150-
})
151-
}
152-
document.querySelector("#message").value = "";
153-
return false;
154-
})
113+
for(user in window.users){
114+
const cipher = cryptico.encrypt(message,user.key,privatekey)
115+
chatSocket.send(JSON.stringify({
116+
"message":JSON.stringify({
117+
"roomid": path[2],
118+
"publickey": user.key,
119+
"sender": currentuser,
120+
"body": cipher.cipher,
121+
"recipient": user.user,
122+
})
123+
}))
124+
}
125+
document.querySelector("#message").value = "";
155126
}
156127
} else if (path[1] == 'login') {
157128
document.querySelector('#login').onsubmit = () => {

0 commit comments

Comments
 (0)