diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 84442031f..522bc76f4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2292,8 +2292,8 @@ "groupNamePlaceholder": { "message": "Group Name" }, - "inviteFriends": { - "message": "Invite Friends" + "inviteContacts": { + "message": "Invite Contacts" }, "manageModerators": { "message": "Manage Moderators" diff --git a/js/models/conversations.js b/js/models/conversations.js index ba457b522..3f71ae135 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -311,6 +311,10 @@ }, async bumpTyping() { + if (this.isPublic()) { + window.console.debug('public conversation... No need to bumpTyping'); + return; + } // We don't send typing messages if the setting is disabled or we do not have a session // or we blocked that user const devicePubkey = new libsession.Types.PubKey(this.id); @@ -1318,8 +1322,24 @@ options.messageType = message.get('type'); options.isPublic = this.isPublic(); - if (options.isPublic) { - options.publicSendData = await this.getPublicSendData(); + if (this.isPublic()) { + // FIXME audric add back attachments, quote, preview + const openGroup = { + server: this.get('server'), + channel: this.get('channelId'), + conversationId: this.id, + }; + const openGroupParams = { + body, + timestamp: Date.now(), + group: openGroup, + }; + const openGroupMessage = new libsession.Messages.Outgoing.OpenGroupMessage( + openGroupParams + ); + await libsession.getMessageQueue().sendToGroup(openGroupMessage); + + return null; } options.sessionRestoration = sessionRestoration; @@ -1383,6 +1403,8 @@ // let dest = destination; // let numbers = groupNumbers; if (this.isMediumGroup()) { + // FIXME audric to implement back + // dest = this.id; // numbers = [destination]; // options.isMediumGroup = true; @@ -2077,6 +2099,13 @@ // conversation is viewed, another error message shows up for the contact read = read.filter(item => !item.hasErrors); + if (this.isPublic()) { + window.console.debug( + 'public conversation... No need to send read receipt' + ); + return; + } + const devicePubkey = new libsession.Types.PubKey(this.id); const hasSession = await libsession.Protocols.SessionProtocol.hasSession( devicePubkey diff --git a/js/modules/loki_app_dot_net_api.d.ts b/js/modules/loki_app_dot_net_api.d.ts index 446b1bab2..cdb7106e4 100644 --- a/js/modules/loki_app_dot_net_api.d.ts +++ b/js/modules/loki_app_dot_net_api.d.ts @@ -14,12 +14,15 @@ declare class LokiAppDotNetServerAPI { } export interface LokiPublicChannelAPI { - sendMessage(data: { - quote?: Quote; - attachments: Array; - preview: Array; - body?: string; - }): Promise; + sendMessage( + data: { + quote?: Quote; + attachments: Array; + preview: Array; + body?: string; + }, + timestamp: number + ): Promise; } export default LokiAppDotNetServerAPI; diff --git a/ts/session/sending/MessageSender.ts b/ts/session/sending/MessageSender.ts index 0cc3d6cae..d5a33a0e0 100644 --- a/ts/session/sending/MessageSender.ts +++ b/ts/session/sending/MessageSender.ts @@ -100,7 +100,7 @@ export async function sendToOpenGroup( The only problem is that `channelAPI.sendMessage` returns true/false and doesn't throw any error so we can never be sure why sending failed. This should be fixed and we shouldn't rely on returning true/false, rather return nothing (success) or throw an error (failure) */ - const { group, quote, attachments, preview, body } = message; + const { group, quote, attachments, preview, body, timestamp } = message; const channelAPI = await window.lokiPublicChatAPI.findOrCreateChannel( group.server, group.channel, @@ -108,12 +108,15 @@ export async function sendToOpenGroup( ); // Don't think returning true/false on `sendMessage` is a good way - return channelAPI.sendMessage({ - quote, - attachments: attachments || [], - preview, - body, - }); + return channelAPI.sendMessage( + { + quote, + attachments: attachments || [], + preview, + body, + }, + timestamp + ); // TODO: The below should be handled in whichever class calls this /*