mirror of
https://github.com/balzack/databag.git
synced 2025-02-15 04:59:16 +00:00
Merge branch 'e2e' of https://github.com/balzack/databag into e2e
This commit is contained in:
commit
1a0a9bca69
@ -669,7 +669,7 @@ SPEC CHECKSUMS:
|
|||||||
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
FirebaseInstallations: 99d24bac0243cf8b0e96cf5426340d211f0bcc80
|
||||||
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
FirebaseMessaging: 4487bbff9b9b927ba1dd3ea40d1ceb58e4ee3cb5
|
||||||
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
|
||||||
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
|
glog: 3d02b25ca00c2d456734d0bcff864cbc62f6ae1a
|
||||||
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
GoogleDataTransport: 1c8145da7117bd68bbbed00cf304edb6a24de00f
|
||||||
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
GoogleUtilities: 1d20a6ad97ef46f67bbdec158ce00563a671ebb7
|
||||||
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
|
||||||
|
@ -581,9 +581,9 @@ export function useCardContext() {
|
|||||||
const messageIv = iv.toString();
|
const messageIv = iv.toString();
|
||||||
await addContactChannelTopic(node, token, channelId, 'sealedtopic', { messageEncrypted, messageIv });
|
await addContactChannelTopic(node, token, channelId, 'sealedtopic', { messageEncrypted, messageIv });
|
||||||
},
|
},
|
||||||
setChannelTopicSubject: async (cardId, channelId, topicId, data) => {
|
setChannelTopicSubject: async (cardId, channelId, topicId, dataType, data) => {
|
||||||
const { detail, profile } = getCardEntry(cardId);
|
const { detail, profile } = getCardEntry(cardId);
|
||||||
return await setContactChannelTopicSubject(profile.node, `${profile.guid}.${detail.token}`, channelId, topicId, data);
|
return await setContactChannelTopicSubject(profile.node, `${profile.guid}.${detail.token}`, channelId, topicId, dataType, data);
|
||||||
},
|
},
|
||||||
setChannelTopicUnsealedDetail: async (cardId, channelId, topicId, revision, unsealed) => {
|
setChannelTopicUnsealedDetail: async (cardId, channelId, topicId, revision, unsealed) => {
|
||||||
const { guid } = session.current;
|
const { guid } = session.current;
|
||||||
|
@ -278,9 +278,9 @@ export function useChannelContext() {
|
|||||||
const messageIv = iv.toString();
|
const messageIv = iv.toString();
|
||||||
await addChannelTopic(server, appToken, channelId, 'sealedtopic', { messageEncrypted, messageIv });
|
await addChannelTopic(server, appToken, channelId, 'sealedtopic', { messageEncrypted, messageIv });
|
||||||
},
|
},
|
||||||
setTopicSubject: async (channelId, topicId, data) => {
|
setTopicSubject: async (channelId, topicId, dataType, data) => {
|
||||||
const { server, appToken } = session.current;
|
const { server, appToken } = session.current;
|
||||||
return await setChannelTopicSubject(server, appToken, channelId, topicId, data);
|
return await setChannelTopicSubject(server, appToken, channelId, topicId, dataType, data);
|
||||||
},
|
},
|
||||||
setTopicUnsealedDetail: async (channelId, topicId, revision, unsealed) => {
|
setTopicUnsealedDetail: async (channelId, topicId, revision, unsealed) => {
|
||||||
const { guid } = session.current;
|
const { guid } = session.current;
|
||||||
|
@ -131,11 +131,11 @@ export function useConversationContext() {
|
|||||||
}
|
}
|
||||||
return await channel.actions.addTopic(channelId, message, assetId);
|
return await channel.actions.addTopic(channelId, message, assetId);
|
||||||
}
|
}
|
||||||
const setTopicSubject = async (cardId, channelId, topicId, data) => {
|
const setTopicSubject = async (cardId, channelId, topicId, dataType, data) => {
|
||||||
if (cardId) {
|
if (cardId) {
|
||||||
return await card.actions.setChannelTopicSubject(cardId, channelId, topicId, data);
|
return await card.actions.setChannelTopicSubject(cardId, channelId, topicId, dataType, data);
|
||||||
}
|
}
|
||||||
return await channel.actions.setTopicSubject(channelId, topicId, data);
|
return await channel.actions.setTopicSubject(channelId, topicId, dataType, data);
|
||||||
}
|
}
|
||||||
const remove = async (cardId, channelId) => {
|
const remove = async (cardId, channelId) => {
|
||||||
if (cardId) {
|
if (cardId) {
|
||||||
@ -448,7 +448,6 @@ export function useConversationContext() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
unsealTopic: async (topicId, sealKey) => {
|
unsealTopic: async (topicId, sealKey) => {
|
||||||
console.log("UNSEAL TOPIC");
|
|
||||||
try {
|
try {
|
||||||
const topic = topics.current.get(topicId);
|
const topic = topics.current.get(topicId);
|
||||||
const { messageEncrypted, messageIv } = JSON.parse(topic.detail.data);
|
const { messageEncrypted, messageIv } = JSON.parse(topic.detail.data);
|
||||||
@ -466,7 +465,6 @@ console.log("UNSEAL TOPIC");
|
|||||||
await card.actions.setChannelTopicUnsealedDetail(cardId, channelId, topic.topicId, topic.detailRevision, topic.unsealedDetial);
|
await card.actions.setChannelTopicUnsealedDetail(cardId, channelId, topic.topicId, topic.detailRevision, topic.unsealedDetial);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("channel topic", topic);
|
|
||||||
await channel.actions.setTopicUnsealedDetail(channelId, topic.topicId, topic.detailRevision, topic.unsealedDetail);
|
await channel.actions.setTopicUnsealedDetail(channelId, topic.topicId, topic.detailRevision, topic.unsealedDetail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,15 +520,34 @@ console.log("channel topic", topic);
|
|||||||
if (conversationId.current) {
|
if (conversationId.current) {
|
||||||
const { cardId, channelId } = conversationId.current;
|
const { cardId, channelId } = conversationId.current;
|
||||||
if (cardId) {
|
if (cardId) {
|
||||||
return await card.actions.setChannelTopicSubject(cardId, channelId, topicId, data);
|
return await card.actions.setChannelTopicSubject(cardId, channelId, topicId, 'superbasictopic', data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return await channel.actions.setTopicSubject(channelId, topicId, data);
|
return await channel.actions.setTopicSubject(channelId, topicId, 'superbasictopic', data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
force.current = true;
|
force.current = true;
|
||||||
sync();
|
sync();
|
||||||
},
|
},
|
||||||
|
setSealedTopicSubject: async (topicId, data, sealKey) => {
|
||||||
|
if (conversationId.current) {
|
||||||
|
const { cardId, channelId } = conversationId.current;
|
||||||
|
|
||||||
|
const iv = CryptoJS.lib.WordArray.random(128 / 8);
|
||||||
|
const key = CryptoJS.enc.Hex.parse(sealKey);
|
||||||
|
const encrypted = CryptoJS.AES.encrypt(JSON.stringify({ message: data }), key, { iv: iv });
|
||||||
|
const messageEncrypted = encrypted.ciphertext.toString(CryptoJS.enc.Base64)
|
||||||
|
const messageIv = iv.toString();
|
||||||
|
|
||||||
|
if (cardId) {
|
||||||
|
return await card.actions.setChannelTopicSubject(cardId, channelId, topicId, 'sealedtopic', { messageEncrypted, messageIv });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return await channel.actions.setTopicSubject(channelId, topicId, 'sealedtopic', { messageEncrypted, messageIv });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
setCard: async (id) => {
|
setCard: async (id) => {
|
||||||
if (conversationId.current) {
|
if (conversationId.current) {
|
||||||
const { cardId, channelId } = conversationId.current;
|
const { cardId, channelId } = conversationId.current;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Keyboard, KeyboardAvoidingView, ActivityIndicator, Modal, Platform, TextInput, View, TouchableOpacity, Text, } from 'react-native';
|
import { Alert, Keyboard, KeyboardAvoidingView, ActivityIndicator, Modal, Platform, TextInput, View, TouchableOpacity, Text, } from 'react-native';
|
||||||
import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp';
|
import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp';
|
||||||
import { memo, useState, useRef, useEffect } from 'react';
|
import { memo, useState, useRef, useEffect } from 'react';
|
||||||
import { useConversation } from './useConversation.hook';
|
import { useConversation } from './useConversation.hook';
|
||||||
|
@ -103,7 +103,12 @@ export function useConversation() {
|
|||||||
updateState({ editing: false });
|
updateState({ editing: false });
|
||||||
},
|
},
|
||||||
updateTopic: async () => {
|
updateTopic: async () => {
|
||||||
await conversation.actions.setTopicSubject(state.editTopicId, { ...state.editData, text: state.editMessage });
|
if (state.locked) {
|
||||||
|
await conversation.actions.setSealedTopicSubject(state.editTopicId, { ...state.editData, text: state.editMessage }, state.sealKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await conversation.actions.setTopicSubject(state.editTopicId, { ...state.editData, text: state.editMessage });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setEditMessage: (editMessage) => {
|
setEditMessage: (editMessage) => {
|
||||||
updateState({ editMessage });
|
updateState({ editMessage });
|
||||||
|
Loading…
Reference in New Issue
Block a user