ChatBox: click lock button to initiate key exchange

pgp
Alex Gleason 2022-06-14 18:02:32 -05:00
rodzic c65239dd15
commit e8433a88ab
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ import { Stack, HStack, IconButton } from 'soapbox/components/ui';
import UploadProgress from 'soapbox/features/compose/components/upload-progress'; import UploadProgress from 'soapbox/features/compose/components/upload-progress';
import UploadButton from 'soapbox/features/compose/components/upload_button'; import UploadButton from 'soapbox/features/compose/components/upload_button';
import { truncateFilename } from 'soapbox/utils/media'; import { truncateFilename } from 'soapbox/utils/media';
import { initPgpKey } from 'soapbox/utils/pgp';
import ChatMessageList from './chat_message_list'; import ChatMessageList from './chat_message_list';
@ -25,6 +26,7 @@ const messages = defineMessages({
const mapStateToProps = (state, { chatId }) => ({ const mapStateToProps = (state, { chatId }) => ({
me: state.get('me'), me: state.get('me'),
account: state.getIn(['accounts', state.me]),
chat: state.getIn(['chats', 'items', chatId]), chat: state.getIn(['chats', 'items', chatId]),
chatMessageIds: state.getIn(['chat_message_lists', chatId], ImmutableOrderedSet()), chatMessageIds: state.getIn(['chat_message_lists', chatId], ImmutableOrderedSet()),
}); });
@ -169,13 +171,24 @@ class ChatBox extends ImmutablePureComponent {
); );
} }
sendPublicKey = async() => {
const { dispatch, chatId, account } = this.props;
const { publicKey } = await initPgpKey(account.fqn);
const params = {
content: publicKey,
};
dispatch(sendChatMessage(chatId, params));
}
renderEncryptionButton = () => { renderEncryptionButton = () => {
return ( return (
<IconButton <IconButton
className='text-gray-400 hover:text-gray-600' className='text-gray-400 hover:text-gray-600'
iconClassName='h-5 w-5' iconClassName='h-5 w-5'
src={require('@tabler/icons/icons/lock-open.svg')} src={require('@tabler/icons/icons/lock-open.svg')}
onClick={() => {}} onClick={this.sendPublicKey}
transparent transparent
/> />
); );