Fix messages on remote-initiated chats

This commit is contained in:
2020-05-21 10:49:33 +01:00
parent db7ecc6d98
commit d77d04e9b1
3 changed files with 17 additions and 12 deletions

View File

@@ -108,9 +108,11 @@ impl telepathy::ChannelInterfaceMessages for Channel {
for msg_id in dc::chat::get_chat_msgs(&ctx, self.chat_id, 0, None) {
if let Ok(msg) = dc::message::Message::load_from_db(&ctx, msg_id) {
println!(" A message: {:?}", msg);
match msg.get_state() {
MessageState::InFresh | MessageState::InNoticed => out.push(convert_msg(&msg)),
MessageState::InFresh | MessageState::InNoticed => {
println!(" A message: {:?}", msg);
out.push(convert_msg(&msg))
}
_ => continue,
}
}

View File

@@ -390,10 +390,10 @@ impl Connection {
) {
// Ignore messages that are self-originated.
// FIXME: special-case self-chats
if msg.get_from_id() == dc::constants::DC_CONTACT_ID_SELF {
println!("from ourselves, skipping");
continue;
}
// if msg.get_from_id() == dc::constants::DC_CONTACT_ID_SELF {
// println!("from ourselves, skipping");
// continue;
// }
let parts = convert_msg(&msg);
@@ -414,20 +414,23 @@ impl Connection {
let contacts =
dc::chat::get_chat_contacts(&ctx.clone().read().unwrap(), chat_id);
if contacts.len() != 1 {
if contacts.len() > 1 {
println!("...{} contacts in chat, ignoring!", contacts.len());
continue;
}
let handle = contacts.first().unwrap();
// FIXME: device-specific chat isn't really a self-chat
let handle = contacts
.first()
.unwrap_or(&dc::constants::DC_CONTACT_ID_SELF);
let chan = Channel::new(
actq.clone(),
chat_id,
ctx.clone(),
*handle, // initiator
*handle, // initiator is the remote contact
chan_path,
false, // FIXME: this needs to handle requested channels
dc::constants::DC_CONTACT_ID_SELF, // target is us
false, // FIXME: this needs to handle requested channels
*handle, // target is always the other party
);
actq.send(DbusAction::NewChannel(chan)).unwrap();
actq.send(act).unwrap();

View File

@@ -101,7 +101,7 @@ impl telepathy::ConnectionInterfaceRequests for Connection {
self.actq.clone(),
chat_id,
self.ctx.clone(),
dc::constants::DC_CONTACT_ID_SELF, // initiator is self
dc::constants::DC_CONTACT_ID_SELF, // initiator is self in this case
channel_path.clone(),
true, // requested
target_handle,