Inject additional information to message payloads
This additional information will be used to inject an element inside
messages quoting their parent message.
Bug: twpowertools:153
Change-Id: I502f9f9d0377ad5cb9be9c2a96cec416609e790f
diff --git a/src/models/Gap.js b/src/models/Gap.js
index 131dfbc..59e4882 100644
--- a/src/models/Gap.js
+++ b/src/models/Gap.js
@@ -21,7 +21,7 @@
}
getStartTimestamp() {
- const a = this.getStartMicroseconds();
+ let a = this.getStartMicroseconds();
if (a == null) a = '0';
return BigInt(a);
}
@@ -35,7 +35,7 @@
}
getEndTimestamp() {
- const a = this.getEndMicroseconds();
+ let a = this.getEndMicroseconds();
if (a == null) a = '0';
return BigInt(a);
}
diff --git a/src/models/Message.js b/src/models/Message.js
index d39a9ab..f5e5b37 100644
--- a/src/models/Message.js
+++ b/src/models/Message.js
@@ -12,7 +12,7 @@
}
getCreatedMicroseconds() {
- const a = this.getCreatedTimestamp();
+ let a = this.getCreatedTimestamp();
if (a === null) a = '0';
return BigInt(a);
}
@@ -33,6 +33,31 @@
this.data[12] = [];
}
+ getPayload() {
+ return this.data[1]?.[4] ?? null;
+ }
+
+ setPayload(value) {
+ if (!this.data[1]) this.data[1] = [];
+ this.data[1][4] = value;
+ }
+
+ getId() {
+ return this.data[1]?.[1]?.[1] ?? null;
+ }
+
+ getAuthor() {
+ return this.data[3] ?? null;
+ }
+
+ getParentMessageId() {
+ return this.data[1]?.[37] ?? null;
+ }
+
+ isComment() {
+ return !!this.getParentMessageId;
+ }
+
toRawMessageOrGap() {
return {1: this.data};
}