include PartType in CallLog
This commit is contained in:
parent
63bfbfb40a
commit
63df518c19
|
@ -52,6 +52,7 @@ import im.conversations.android.xmpp.model.jmi.Reject;
|
|||
import im.conversations.android.xmpp.model.jmi.Retract;
|
||||
import im.conversations.android.xmpp.model.stanza.Iq;
|
||||
import im.conversations.android.xmpp.model.stanza.Message;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -179,8 +180,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
private final Queue<PeerConnection.PeerConnectionState> stateHistory = new LinkedList<>();
|
||||
private final RtpSessionNotification rtpSessionNotification;
|
||||
private ScheduledFuture<?> ringingTimeoutFuture;
|
||||
private final CallLogTransformation.Builder callLogTransformationBuilder =
|
||||
new CallLogTransformation.Builder();
|
||||
private final CallLogTransformation.Builder callLogTransformationBuilder;
|
||||
private final ListenableFuture<Boolean> remoteHasVideoFeature;
|
||||
|
||||
public JingleRtpConnection(
|
||||
|
@ -194,6 +194,9 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
this.remoteHasVideoFeature =
|
||||
getManager(DiscoManager.class)
|
||||
.hasFeatureAsync(Entity.presence(id.with), Namespace.JINGLE_FEATURE_VIDEO);
|
||||
final Jid to = isInitiator() ? id.with : connection.getBoundAddress();
|
||||
this.callLogTransformationBuilder =
|
||||
new CallLogTransformation.Builder(id.with, to, initiator, id.sessionId);
|
||||
}
|
||||
|
||||
private static State reasonToState(Reason reason) {
|
||||
|
@ -1347,7 +1350,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
|
||||
private void acceptedOnOtherDevice(final String serverMsgId) {
|
||||
if (serverMsgId != null) {
|
||||
this.callLogTransformationBuilder.setServerMsgId(serverMsgId);
|
||||
this.callLogTransformationBuilder.setStanzaId(serverMsgId);
|
||||
}
|
||||
this.callLogTransformationBuilder.setCarbon(
|
||||
true); // indicate that call was accepted on other device
|
||||
|
@ -1388,7 +1391,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
this.rtpSessionNotification.cancelIncomingCallNotification();
|
||||
this.finish();
|
||||
if (serverMsgId != null) {
|
||||
this.callLogTransformationBuilder.setServerMsgId(serverMsgId);
|
||||
this.callLogTransformationBuilder.setStanzaId(serverMsgId);
|
||||
}
|
||||
this.callLogTransformationBuilder.setCarbon(
|
||||
true); // indicate that call was rejected on other device
|
||||
|
@ -1448,7 +1451,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
this.proposedMedia = Sets.newHashSet(media);
|
||||
})) {
|
||||
if (serverMsgId != null) {
|
||||
this.callLogTransformationBuilder.setServerMsgId(serverMsgId);
|
||||
this.callLogTransformationBuilder.setStanzaId(serverMsgId);
|
||||
}
|
||||
startRinging();
|
||||
} else {
|
||||
|
@ -1502,7 +1505,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
if (isInitiator()) {
|
||||
if (transition(State.PROCEED)) {
|
||||
if (serverMsgId != null) {
|
||||
this.callLogTransformationBuilder.setServerMsgId(serverMsgId);
|
||||
this.callLogTransformationBuilder.setStanzaId(serverMsgId);
|
||||
}
|
||||
final Integer remoteDeviceId = proceed.getDeviceId();
|
||||
if (isOmemoEnabled()) {
|
||||
|
@ -1561,7 +1564,7 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
+ serverMsgId
|
||||
+ ")");
|
||||
if (serverMsgId != null) {
|
||||
this.callLogTransformationBuilder.setServerMsgId(serverMsgId);
|
||||
this.callLogTransformationBuilder.setStanzaId(serverMsgId);
|
||||
}
|
||||
if (target == State.RETRACTED) {
|
||||
this.callLogTransformationBuilder.markUnread();
|
||||
|
@ -2618,17 +2621,20 @@ public class JingleRtpConnection extends AbstractJingleConnection
|
|||
}
|
||||
|
||||
private void writeLogMessageSuccess(final long duration) {
|
||||
this.callLogTransformationBuilder.setDuration(duration);
|
||||
// this.message.setBody(new RtpSessionStatus(true, duration).toString());
|
||||
this.callLogTransformationBuilder.setMedia(getMedia());
|
||||
this.callLogTransformationBuilder.setDuration(Duration.ofMillis(duration));
|
||||
this.writeMessage();
|
||||
}
|
||||
|
||||
private void writeLogMessageMissed() {
|
||||
// this.message.setBody(new RtpSessionStatus(false, 0).toString());
|
||||
this.callLogTransformationBuilder.setIsMissedCall();
|
||||
this.writeMessage();
|
||||
}
|
||||
|
||||
private void writeMessage() {
|
||||
final CallLogTransformation callLogTransformation =
|
||||
this.callLogTransformationBuilder.build();
|
||||
LOGGER.info("writing log message to DB {}", callLogTransformation);
|
||||
// TODO write CallLogEntry to DB
|
||||
}
|
||||
|
||||
|
|
|
@ -4,5 +4,8 @@ public enum PartType {
|
|||
TEXT,
|
||||
FILE,
|
||||
RETRACTION,
|
||||
MODERATION
|
||||
MODERATION,
|
||||
VIDEO_CALL,
|
||||
AUDIO_CALL,
|
||||
MISSED_CALL
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package im.conversations.android.transformer;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import eu.siacs.conversations.xmpp.jingle.Media;
|
||||
import im.conversations.android.database.model.PartType;
|
||||
import im.conversations.android.xmpp.model.stanza.Message;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
public class CallLogTransformation extends Transformation {
|
||||
|
||||
public final Duration duration;
|
||||
public final PartType partType;
|
||||
|
||||
private CallLogTransformation(
|
||||
final Instant receivedAt,
|
||||
|
@ -16,23 +21,71 @@ public class CallLogTransformation extends Transformation {
|
|||
final Jid remote,
|
||||
final String messageId,
|
||||
final String stanzaId,
|
||||
final Duration duration) {
|
||||
final Duration duration,
|
||||
final PartType partType) {
|
||||
super(receivedAt, to, from, remote, Message.Type.NORMAL, messageId, stanzaId, null);
|
||||
this.duration = duration;
|
||||
this.partType = partType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("duration", duration)
|
||||
.add("partType", partType)
|
||||
.add("receivedAt", receivedAt)
|
||||
.add("to", to)
|
||||
.add("from", from)
|
||||
.add("remote", remote)
|
||||
.add("type", type)
|
||||
.add("messageId", messageId)
|
||||
.add("stanzaId", stanzaId)
|
||||
.add("occupantId", occupantId)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
public void setServerMsgId(String serverMsgId) {}
|
||||
private final Instant receivedAt;
|
||||
private final Jid to;
|
||||
private final Jid from;
|
||||
private final Jid remote;
|
||||
private final String messageId;
|
||||
private String stanzaId;
|
||||
private Duration duration;
|
||||
private PartType partType;
|
||||
|
||||
public Builder(final Jid remote, final Jid to, final Jid from, final String sessionId) {
|
||||
this.receivedAt = Instant.now();
|
||||
this.remote = remote;
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
this.messageId = sessionId;
|
||||
}
|
||||
|
||||
public void setStanzaId(final String stanzaId) {
|
||||
this.stanzaId = stanzaId;
|
||||
}
|
||||
|
||||
public void setCarbon(boolean b) {}
|
||||
|
||||
public void markUnread() {}
|
||||
|
||||
public void setDuration(long duration) {}
|
||||
public void setDuration(final Duration duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setIsMissedCall() {
|
||||
this.duration = Duration.ZERO;
|
||||
}
|
||||
|
||||
public void setMedia(final Set<Media> media) {
|
||||
this.partType = Media.audioOnly(media) ? PartType.AUDIO_CALL : PartType.VIDEO_CALL;
|
||||
}
|
||||
|
||||
public CallLogTransformation build() {
|
||||
return new CallLogTransformation(null, null, null, null, null, null, null);
|
||||
return new CallLogTransformation(
|
||||
receivedAt, to, from, remote, messageId, stanzaId, duration, partType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue