drop typing message for public groups and fix opengroup sending

pull/1194/head
Audric Ackermann 5 years ago
parent b07b195102
commit cae608fd01
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -2292,8 +2292,8 @@
"groupNamePlaceholder": { "groupNamePlaceholder": {
"message": "Group Name" "message": "Group Name"
}, },
"inviteFriends": { "inviteContacts": {
"message": "Invite Friends" "message": "Invite Contacts"
}, },
"manageModerators": { "manageModerators": {
"message": "Manage Moderators" "message": "Manage Moderators"

@ -311,6 +311,10 @@
}, },
async bumpTyping() { 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 // We don't send typing messages if the setting is disabled or we do not have a session
// or we blocked that user // or we blocked that user
const devicePubkey = new libsession.Types.PubKey(this.id); const devicePubkey = new libsession.Types.PubKey(this.id);
@ -1318,8 +1322,24 @@
options.messageType = message.get('type'); options.messageType = message.get('type');
options.isPublic = this.isPublic(); options.isPublic = this.isPublic();
if (options.isPublic) { if (this.isPublic()) {
options.publicSendData = await this.getPublicSendData(); // 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; options.sessionRestoration = sessionRestoration;
@ -1383,6 +1403,8 @@
// let dest = destination; // let dest = destination;
// let numbers = groupNumbers; // let numbers = groupNumbers;
if (this.isMediumGroup()) { if (this.isMediumGroup()) {
// FIXME audric to implement back
// dest = this.id; // dest = this.id;
// numbers = [destination]; // numbers = [destination];
// options.isMediumGroup = true; // options.isMediumGroup = true;
@ -2077,6 +2099,13 @@
// conversation is viewed, another error message shows up for the contact // conversation is viewed, another error message shows up for the contact
read = read.filter(item => !item.hasErrors); 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 devicePubkey = new libsession.Types.PubKey(this.id);
const hasSession = await libsession.Protocols.SessionProtocol.hasSession( const hasSession = await libsession.Protocols.SessionProtocol.hasSession(
devicePubkey devicePubkey

@ -14,12 +14,15 @@ declare class LokiAppDotNetServerAPI {
} }
export interface LokiPublicChannelAPI { export interface LokiPublicChannelAPI {
sendMessage(data: { sendMessage(
quote?: Quote; data: {
attachments: Array<AttachmentPointer>; quote?: Quote;
preview: Array<Preview>; attachments: Array<AttachmentPointer>;
body?: string; preview: Array<Preview>;
}): Promise<boolean>; body?: string;
},
timestamp: number
): Promise<boolean>;
} }
export default LokiAppDotNetServerAPI; export default LokiAppDotNetServerAPI;

@ -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. 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) 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( const channelAPI = await window.lokiPublicChatAPI.findOrCreateChannel(
group.server, group.server,
group.channel, group.channel,
@ -108,12 +108,15 @@ export async function sendToOpenGroup(
); );
// Don't think returning true/false on `sendMessage` is a good way // Don't think returning true/false on `sendMessage` is a good way
return channelAPI.sendMessage({ return channelAPI.sendMessage(
quote, {
attachments: attachments || [], quote,
preview, attachments: attachments || [],
body, preview,
}); body,
},
timestamp
);
// TODO: The below should be handled in whichever class calls this // TODO: The below should be handled in whichever class calls this
/* /*

Loading…
Cancel
Save