message: fix: carbon copy
diff: -//import {} from '../handler'
  import * as NS from '../namespace'
  import Log from '../../../util/Log'
  import JID from '../../../JID'
  @@ -20,7 +19,7 @@ export default class extends AbstractHandler {
  return this.PRESERVE_HANDLER;
  }
  - let peerJid = new JID(messageElement.getOriginalFrom());
  + let peerJid = new JID(messageElement.getPeer());
  let peerContact = this.account.getContact(peerJid);
  if (typeof peerContact === 'undefined') {
  this.handleUnknownSender(messageElement);
  @@ -40,7 +39,7 @@ export default class extends AbstractHandler {
  htmlMessage: messageElement.getHtmlBody().html(),
  forwarded: messageElement.isForwarded(),
  stamp: messageElement.getTime().getTime(),
  - unread: true //@REVIEW carbon copy?
  + unread: messageElement.isIncoming(),
  });
  let pipe = this.account.getPipe('afterReceiveMessage');
  @@ -48,6 +47,8 @@ export default class extends AbstractHandler {
  pipe.run(peerContact, message, messageElement.get(0)).then(([contact, message]) => {
  if (message.getPlaintextMessage() || message.getHtmlMessage()) {
  contact.getTranscript().pushMessage(message);
  + } else {
  + message.delete();
  }
  });
  @@ -97,6 +98,10 @@ class MessageElement {
  let carbonStanza = $(stanza).find('> ' + NS.getFilter('CARBONS'));
  + if (carbonStanza.get(0) !== forwardedStanza.parent().get(0)) {
  + throw new Error('Forwarded message is not part of carbon copy');
  + }
  +
  this.element = forwardedStanza.find('> message');
  this.forwarded = true;
  @@ -122,6 +127,10 @@ class MessageElement {
  return this.carbon;
  }
  + public isIncoming() {
  + return this.direction === Message.DIRECTION.IN;
  + }
  +
  public find(selector) {
  return this.element.find(selector);
  }
  @@ -142,8 +151,16 @@ class MessageElement {
  return this.element.attr('to');
  }
  + public getPeer() {
  + if (this.isCarbon() && this.getDirection() === Message.DIRECTION.OUT) {
  + return this.getTo();
  + } else {
  + return this.getFrom();
  + }
  + }
  +
  public getOriginalFrom() {
  - return this.isCarbon() ? this.getFrom() : this.originalElement.attr('from');
  + return this.originalElement.attr('from');
  }
  public getOriginalTo() {
  @@ -172,7 +189,7 @@ class MessageElement {
  let body = Utils.removeHTML(this.element.find('> body').text());
  if (this.forwarded && !this.carbon) {
  - return `${this.getOriginalFrom()} ${Translation.t('to')} ${this.getOriginalFrom()} "${body}"`;
  + return `${this.getOriginalFrom()} ${Translation.t('to')} ${this.getOriginalTo()} "${body}"`;
  }
  return body;
  