Fix messages on remote-initiated chats
This commit is contained in:
@@ -108,9 +108,11 @@ impl telepathy::ChannelInterfaceMessages for Channel {
|
|||||||
|
|
||||||
for msg_id in dc::chat::get_chat_msgs(&ctx, self.chat_id, 0, None) {
|
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) {
|
if let Ok(msg) = dc::message::Message::load_from_db(&ctx, msg_id) {
|
||||||
println!(" A message: {:?}", msg);
|
|
||||||
match msg.get_state() {
|
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,
|
_ => continue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -390,10 +390,10 @@ impl Connection {
|
|||||||
) {
|
) {
|
||||||
// Ignore messages that are self-originated.
|
// Ignore messages that are self-originated.
|
||||||
// FIXME: special-case self-chats
|
// FIXME: special-case self-chats
|
||||||
if msg.get_from_id() == dc::constants::DC_CONTACT_ID_SELF {
|
// if msg.get_from_id() == dc::constants::DC_CONTACT_ID_SELF {
|
||||||
println!("from ourselves, skipping");
|
// println!("from ourselves, skipping");
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
let parts = convert_msg(&msg);
|
let parts = convert_msg(&msg);
|
||||||
|
|
||||||
@@ -414,20 +414,23 @@ impl Connection {
|
|||||||
|
|
||||||
let contacts =
|
let contacts =
|
||||||
dc::chat::get_chat_contacts(&ctx.clone().read().unwrap(), chat_id);
|
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());
|
println!("...{} contacts in chat, ignoring!", contacts.len());
|
||||||
continue;
|
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(
|
let chan = Channel::new(
|
||||||
actq.clone(),
|
actq.clone(),
|
||||||
chat_id,
|
chat_id,
|
||||||
ctx.clone(),
|
ctx.clone(),
|
||||||
*handle, // initiator
|
*handle, // initiator is the remote contact
|
||||||
chan_path,
|
chan_path,
|
||||||
false, // FIXME: this needs to handle requested channels
|
false, // FIXME: this needs to handle requested channels
|
||||||
dc::constants::DC_CONTACT_ID_SELF, // target is us
|
*handle, // target is always the other party
|
||||||
);
|
);
|
||||||
actq.send(DbusAction::NewChannel(chan)).unwrap();
|
actq.send(DbusAction::NewChannel(chan)).unwrap();
|
||||||
actq.send(act).unwrap();
|
actq.send(act).unwrap();
|
||||||
|
@@ -101,7 +101,7 @@ impl telepathy::ConnectionInterfaceRequests for Connection {
|
|||||||
self.actq.clone(),
|
self.actq.clone(),
|
||||||
chat_id,
|
chat_id,
|
||||||
self.ctx.clone(),
|
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(),
|
channel_path.clone(),
|
||||||
true, // requested
|
true, // requested
|
||||||
target_handle,
|
target_handle,
|
||||||
|
Reference in New Issue
Block a user