This commit is contained in:
PhilReact 2024-10-28 13:56:23 +02:00
parent 4d570068ef
commit cbd372bc07
3 changed files with 983 additions and 882 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ import {
clearAllNotificationsCase, clearAllNotificationsCase,
createGroupCase, createGroupCase,
decryptWalletCase, decryptWalletCase,
encryptAndPublishSymmetricKeyGroupChatCase,
getApiKeyCase, getApiKeyCase,
getCustomNodesFromStorageCase, getCustomNodesFromStorageCase,
getDataPublishesCase, getDataPublishesCase,
@ -1660,7 +1661,7 @@ async function sendChat({ qortAddress, recipientPublicKey, message }) {
return _response; return _response;
} }
async function sendChatGroup({ export async function sendChatGroup({
groupId, groupId,
typeMessage, typeMessage,
chatReference, chatReference,
@ -1991,7 +1992,7 @@ async function createBuyOrderTx({ crosschainAtInfo, useLocal }) {
} }
} }
async function sendChatNotification( export async function sendChatNotification(
res, res,
groupId, groupId,
secretKeyObject, secretKeyObject,
@ -3032,11 +3033,14 @@ function setupMessageListener() {
case "getGroupDataSingle": case "getGroupDataSingle":
getGroupDataSingleCase(request, event); getGroupDataSingleCase(request, event);
break; break;
case "getTimestampEnterChat": case "getTimestampEnterChat":
getTimestampEnterChatCase(request, event); getTimestampEnterChatCase(request, event);
break; break;
case "getGroupNotificationTimestamp": case "getGroupNotificationTimestamp":
getGroupNotificationTimestampCase(request, event); getGroupNotificationTimestampCase(request, event);
break;
case "encryptAndPublishSymmetricKeyGroupChat":
encryptAndPublishSymmetricKeyGroupChatCase(request, event);
break; break;
default: default:
console.error("Unknown action:", request.action); console.error("Unknown action:", request.action);

View File

@ -107,28 +107,36 @@ export const CreateCommonSecret = ({groupId, secretKey, isOwner, myAddress, sec
const secretKeyToSend = !secretKey2 ? null : secretKey2 const secretKeyToSend = !secretKey2 ? null : secretKey2
chrome?.runtime?.sendMessage({ action: "encryptAndPublishSymmetricKeyGroupChat", payload: { window.sendMessage("encryptAndPublishSymmetricKeyGroupChat", {
groupId: groupId, groupId: groupId,
previousData: secretKeyToSend previousData: secretKeyToSend,
} }, (response) => { })
if (!response?.error) { .then((response) => {
setInfoSnack({ if (!response?.error) {
type: "success", setInfoSnack({
message: "Successfully re-encrypted secret key. It may take a couple of minutes for the changes to propagate. Refresh the group in 5mins", type: "success",
}); message: "Successfully re-encrypted secret key. It may take a couple of minutes for the changes to propagate. Refresh the group in 5 mins.",
setOpenSnack(true); });
setTxList((prev)=> [{ setOpenSnack(true);
setTxList((prev) => [
{
...response, ...response,
type: 'created-common-secret', type: 'created-common-secret',
label: `Published secret key for group ${groupId}: awaiting confirmation`, label: `Published secret key for group ${groupId}: awaiting confirmation`,
labelDone: `Published secret key for group ${groupId}: success!`, labelDone: `Published secret key for group ${groupId}: success!`,
done: false, done: false,
groupId, groupId,
},
}, ...prev]) ...prev,
} ]);
setIsLoading(false) }
}); setIsLoading(false);
})
.catch((error) => {
console.error("Failed to encrypt and publish symmetric key for group chat:", error.message || "An error occurred");
setIsLoading(false);
});
} catch (error) { } catch (error) {
} }