Browse Source

fix kick out

bugfix/timeout-logging
Evan Feenstra 4 years ago
parent
commit
0c176c0945
  1. 8
      api/controllers/chats.ts
  2. 8
      dist/api/controllers/chats.js
  3. 2
      dist/api/controllers/chats.js.map
  4. 11
      dist/public/index.html
  5. 86159
      dist/public/js/app.js
  6. BIN
      dist/public/relay.jpg
  7. 372
      dist/public/semantic.min.css

8
api/controllers/chats.ts

@ -20,7 +20,7 @@ export async function kickChatMember(req, res){
return failure(res, "missing param")
}
// remove chat.contactIds
let chat = await models.Chat.findOne({ where: { chatId } })
let chat = await models.Chat.findOne({ where: { id:chatId } })
const contactIds = JSON.parse(chat.contactIds || '[]')
const newContactIds = contactIds.filter(cid=>cid!==contactId)
await chat.update({ contactIds: JSON.stringify(newContactIds) })
@ -356,12 +356,10 @@ export async function receiveGroupLeave(payload) {
}
} else {
console.log('==> received leave as subsribers')
// check if im the only one in "members"
// if im the one in members
// i've been kicked out!
// check if im in "members", if so i've been kicked out!
const owner = await models.Contact.findOne({where:{isOwner:true}})
let imKickedOut = false
for (let [pubkey, _] of Object.entries(chat_members)) {
for (let pubkey of Object.keys(chat_members)) {
console.log('==> member pubkey', pubkey, owner.publicKey)
if(pubkey===owner.publicKey) {
imKickedOut = true

8
dist/api/controllers/chats.js

@ -30,7 +30,7 @@ function kickChatMember(req, res) {
return res_1.failure(res, "missing param");
}
// remove chat.contactIds
let chat = yield models_1.models.Chat.findOne({ where: { chatId } });
let chat = yield models_1.models.Chat.findOne({ where: { id: chatId } });
const contactIds = JSON.parse(chat.contactIds || '[]');
const newContactIds = contactIds.filter(cid => cid !== contactId);
yield chat.update({ contactIds: JSON.stringify(newContactIds) });
@ -343,12 +343,10 @@ function receiveGroupLeave(payload) {
}
else {
console.log('==> received leave as subsribers');
// check if im the only one in "members"
// if im the one in members
// i've been kicked out!
// check if im in "members", if so i've been kicked out!
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
let imKickedOut = false;
for (let [pubkey, _] of Object.entries(chat_members)) {
for (let pubkey of Object.keys(chat_members)) {
console.log('==> member pubkey', pubkey, owner.publicKey);
if (pubkey === owner.publicKey) {
imKickedOut = true;

2
dist/api/controllers/chats.js.map

File diff suppressed because one or more lines are too long

11
dist/public/index.html

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>React app</title>
</head>
<body>
<div id="app"></div>
<script src="/static/js/app.js"></script>
<link href="/static/semantic.min.css" rel="stylesheet" />
</body>
</html>

86159
dist/public/js/app.js

File diff suppressed because one or more lines are too long

BIN
dist/public/relay.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

372
dist/public/semantic.min.css

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save