remove the need for lokiPublicChatAPI and reorganize the process/notes

pull/679/head
Ryan Tharp 5 years ago
parent d58a835af4
commit eb888874e1

@ -1,4 +1,4 @@
/* global Whisper, i18n, lokiPublicChatAPI, ConversationController, friends */ /* global Whisper, i18n, ConversationController, friends */
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
(function() { (function() {
@ -36,24 +36,19 @@
return this.resolveWith({ errorCode: i18n('publicChatExists') }); return this.resolveWith({ errorCode: i18n('publicChatExists') });
} }
const serverAPI = await lokiPublicChatAPI.findOrCreateServer( // create conversation
sslServerUrl
);
if (!serverAPI) {
// Url incorrect or server not compatible
return this.resolveWith({ errorCode: i18n('connectToServerFail') });
}
const conversation = await ConversationController.getOrCreateAndWait( const conversation = await ConversationController.getOrCreateAndWait(
conversationId, conversationId,
'group' 'group'
); );
await serverAPI.findOrCreateChannel(channelId, conversationId); // convert conversation to a public one
await conversation.setPublicSource(sslServerUrl, channelId); await conversation.setPublicSource(sslServerUrl, channelId);
await conversation.set({ active_at: Date.now() }); // set friend and appropriate SYNC messages for multidevice
await conversation.setFriendRequestStatus( await conversation.setFriendRequestStatus(
friends.friendRequestStatusEnum.friends friends.friendRequestStatusEnum.friends
); );
// and finally activate it
conversation.getPublicSendData(); // may want "await" if you want to use the API
return this.resolveWith({ conversation }); return this.resolveWith({ conversation });
}, },
resolveWith(result) { resolveWith(result) {

Loading…
Cancel
Save