Browse Source

Added chatReference to ChatTransaction and GroupChatTransaction.

Since this affects transaction serialization, it will need to take effect from a future undecided timestamp (defined in constants.js), and both core & UI will need to share the same timestamp.

The feature trigger timestamp comparisons can be removed 24 hours (or more) post-activation. This is because CHAT messages are currently discarded after 24 hours so we don't need to maintain backwards support of the old serialization approach. The feature trigger is only to ensure full chat operation during the 24 hours that the switchover occurs.
chat-reference
CalDescent 2 years ago
parent
commit
d9b1ec488b
  1. 4
      qortal-ui-crypto/api/constants.js
  2. 20
      qortal-ui-crypto/api/transactions/chat/ChatTransaction.js
  3. 20
      qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js
  4. 1
      qortal-ui-plugins/plugins/core/components/ChatModals.js
  5. 2
      qortal-ui-plugins/plugins/core/components/ChatPage.js
  6. 1
      qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js
  7. 1
      qortal-ui-plugins/plugins/core/components/NameMenu.js
  8. 1
      qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js

4
qortal-ui-crypto/api/constants.js

@ -249,6 +249,8 @@ const ERROR_CODES = {
1000: "Not yet released."
}
const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 9999999999999
const QORT_DECIMALS = 1e8
const PROXY_URL = "/proxy/" // Proxy for api calls
@ -265,7 +267,7 @@ const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0
const KDF_THREADS = 16 // 16 Threads seems like a good number :) . No you dumbass nigerian. Its not ! -_-
export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT }
export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT, CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP }
//const TX_TYPES = {
// GENESIS_TRANSACTION: 1,

20
qortal-ui-crypto/api/transactions/chat/ChatTransaction.js

@ -3,6 +3,7 @@ import ChatBase from "./ChatBase.js"
import nacl from '../../deps/nacl-fast.js'
import ed2curve from '../../deps/ed2curve.js'
import { Sha256 } from 'asmcrypto.js'
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants.js'
export default class ChatTransaction extends ChatBase {
@ -29,6 +30,15 @@ export default class ChatTransaction extends ChatBase {
this._hasReceipient[0] = 1
}
set hasChatReference(hasChatReference) {
this._hasChatReference = new Uint8Array(1)
this._hasChatReference[0] = hasChatReference
}
set chatReference(chatReference) {
this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference)
}
set message(message) {
this.messageText = message;
@ -72,6 +82,16 @@ export default class ChatTransaction extends ChatBase {
this._isText,
this._feeBytes
)
// After the feature trigger timestamp we need to include chat reference
if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) {
params.push(this._hasChatReference)
if (this._hasChatReference[0] == 1) {
params.push(this._chatReference)
}
}
return params;
}
}

20
qortal-ui-crypto/api/transactions/chat/GroupChatTransaction.js

@ -1,5 +1,6 @@
"use strict";
import ChatBase from "./ChatBase.js"
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants.js'
export default class GroupChatTransaction extends ChatBase {
constructor() {
@ -18,6 +19,15 @@ export default class GroupChatTransaction extends ChatBase {
this._hasReceipient[0] = hasReceipient
}
set hasChatReference(hasChatReference) {
this._hasChatReference = new Uint8Array(1)
this._hasChatReference[0] = hasChatReference
}
set chatReference(chatReference) {
this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference)
}
set message(message) {
this.messageText = message;
@ -47,6 +57,16 @@ export default class GroupChatTransaction extends ChatBase {
this._isText,
this._feeBytes
)
// After the feature trigger timestamp we need to include chat reference
if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) {
params.push(this._hasChatReference)
if (this._hasChatReference[0] == 1) {
params.push(this._chatReference)
}
}
return params;
}
}

1
qortal-ui-plugins/plugins/core/components/ChatModals.js

@ -183,6 +183,7 @@ class ChatModals extends LitElement {
timestamp: sendTimestamp,
recipient: recipient,
recipientPublicKey: _publicKey,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,

2
qortal-ui-plugins/plugins/core/components/ChatPage.js

@ -667,6 +667,7 @@ class ChatPage extends LitElement {
timestamp: Date.now(),
recipient: this._chatId,
recipientPublicKey: this._publicKey.key,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,
@ -684,6 +685,7 @@ class ChatPage extends LitElement {
timestamp: Date.now(),
groupID: Number(this._chatId),
hasReceipient: 0,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,

1
qortal-ui-plugins/plugins/core/components/ChatWelcomePage.js

@ -410,6 +410,7 @@ class ChatWelcomePage extends LitElement {
timestamp: sendTimestamp,
recipient: recipient,
recipientPublicKey: _publicKey,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,

1
qortal-ui-plugins/plugins/core/components/NameMenu.js

@ -529,6 +529,7 @@ class NameMenu extends LitElement {
timestamp: sendTimestamp,
recipient: recipient,
recipientPublicKey: _publicKey,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,

1
qortal-ui-plugins/plugins/core/messaging/q-chat/q-chat.src.js

@ -819,6 +819,7 @@ class Chat extends LitElement {
timestamp: sendTimestamp,
recipient: recipient,
recipientPublicKey: _publicKey,
hasChatReference: 0,
message: messageText,
lastReference: reference,
proofOfWorkNonce: 0,

Loading…
Cancel
Save