mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-07-31 14:11:45 +00:00
Merge branch 'Qortal:master' into master
This commit is contained in:
@@ -2551,15 +2551,13 @@ class ChatPage extends LitElement {
|
||||
const initDirect = async (cid, noInitial) => {
|
||||
let timeoutId
|
||||
let initial = 0
|
||||
|
||||
let directSocketTimeout
|
||||
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ":" + myNode.port
|
||||
|
||||
let nodeProtocol = myNode.protocol
|
||||
let directSocketLink
|
||||
|
||||
if (window.parent.location.protocol === "https:") {
|
||||
if (nodeProtocol === "https") {
|
||||
directSocketLink = `wss://${nodeUrl}/websockets/chat/messages?involving=${window.parent.reduxStore.getState().app.selectedAddress.address}&involving=${cid}&encoding=BASE64&limit=1`
|
||||
} else {
|
||||
// Fallback to http
|
||||
@@ -2675,17 +2673,15 @@ class ChatPage extends LitElement {
|
||||
const initGroup = (gId, noInitial) => {
|
||||
let timeoutId
|
||||
let groupId = Number(gId)
|
||||
|
||||
let initial = 0
|
||||
let count = 0
|
||||
let groupSocketTimeout
|
||||
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ":" + myNode.port
|
||||
|
||||
let nodeProtocol = myNode.protocol
|
||||
let groupSocketLink
|
||||
|
||||
if (window.parent.location.protocol === "https:") {
|
||||
if (nodeProtocol === "https") {
|
||||
groupSocketLink = `wss://${nodeUrl}/websockets/chat/messages?txGroupId=${groupId}&encoding=BASE64&limit=1`
|
||||
} else {
|
||||
// Fallback to http
|
||||
|
@@ -177,7 +177,7 @@ function processText(input) {
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
console.log({ error })
|
||||
console.error({ error })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1081,17 +1081,22 @@ class MessageTemplate extends LitElement {
|
||||
let version = 0
|
||||
let isForwarded = false
|
||||
let isEdited = false
|
||||
|
||||
let isEncrypted = false
|
||||
|
||||
try {
|
||||
const parsedMessageObj = JSON.parse(this.messageObj.decodedMessage)
|
||||
|
||||
if (+parsedMessageObj.version > 1 && parsedMessageObj.messageText) {
|
||||
if (parsedMessageObj.version > 1 && parsedMessageObj.messageText) {
|
||||
messageVersion2 = generateHTML(parsedMessageObj.messageText, [StarterKit, Underline, Highlight, Mention])
|
||||
messageVersion2WithLink = processText(messageVersion2)
|
||||
}
|
||||
|
||||
message = parsedMessageObj.messageText
|
||||
if (parsedMessageObj.version > 1 && parsedMessageObj.message) {
|
||||
messageVersion2 = parsedMessageObj.message
|
||||
messageVersion2WithLink = processText(messageVersion2)
|
||||
}
|
||||
|
||||
message = parsedMessageObj.messageText ? parsedMessageObj.messageText : parsedMessageObj.message
|
||||
repliedToData = this.messageObj.repliedToData
|
||||
isImageDeleted = parsedMessageObj.isImageDeleted
|
||||
isGifDeleted = parsedMessageObj.isGifDeleted
|
||||
@@ -1101,6 +1106,7 @@ class MessageTemplate extends LitElement {
|
||||
version = parsedMessageObj.version
|
||||
isForwarded = parsedMessageObj.type === 'forward'
|
||||
isEdited = parsedMessageObj.isEdited && true
|
||||
isEncrypted = parsedMessageObj.isFromHub || parsedMessageObj.message ? true : false
|
||||
|
||||
if (parsedMessageObj.images && Array.isArray(parsedMessageObj.images) && parsedMessageObj.images.length > 0) {
|
||||
image = parsedMessageObj.images[0]
|
||||
@@ -1132,6 +1138,8 @@ class MessageTemplate extends LitElement {
|
||||
let hideit = hidemsg.includes(this.messageObj.sender)
|
||||
let forwarded = ''
|
||||
let edited = ''
|
||||
let encrypted = ''
|
||||
let decrypted = ''
|
||||
|
||||
levelFounder = html`<level-founder checkleveladdress="${this.messageObj.sender}"></level-founder>`
|
||||
|
||||
@@ -1247,6 +1255,10 @@ class MessageTemplate extends LitElement {
|
||||
</span>
|
||||
`
|
||||
|
||||
encrypted = html` <mwc-icon style="font-size:16px; color: var(--chat-group);">key</mwc-icon> `
|
||||
|
||||
decrypted = html` <mwc-icon style="font-size:16px; color: var(--chat-group);">key_off</mwc-icon> `
|
||||
|
||||
if (repliedToData) {
|
||||
try {
|
||||
repliedToData.decodedMessage = JSON.parse(repliedToData.decodedMessage)
|
||||
@@ -1536,9 +1548,10 @@ class MessageTemplate extends LitElement {
|
||||
<p class="attachment-name">
|
||||
${attachment && attachment.attachmentName}
|
||||
</p>
|
||||
<p class="attachment-size">
|
||||
${attachment.attachmentSize > 0 ?
|
||||
`<p class="attachment-size">
|
||||
${roundToNearestDecimal(attachment.attachmentSize)} mb
|
||||
</p>
|
||||
</p>` : ''}
|
||||
</div>
|
||||
<vaadin-icon
|
||||
@click=${async () => await this.downloadAttachment(attachment)}
|
||||
@@ -1662,23 +1675,38 @@ class MessageTemplate extends LitElement {
|
||||
${this.isInProgress ? html`
|
||||
<p>${translate('chatpage.cchange91')}</p>
|
||||
` : this.isAgo ? html`
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
<message-time timestamp=${this.messageObj.timestamp}></message-time>
|
||||
</span>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div style="margin-top: 4px;">
|
||||
${isEncrypted ? html`${encrypted}` : html`${decrypted}`}
|
||||
</div>
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
<message-time timestamp=${this.messageObj.timestamp}></message-time>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
` : this.isIso ? html`
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
${new Date(this.messageObj.timestamp).toLocaleString()}
|
||||
</span>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div style="margin-top: 4px;">
|
||||
${isEncrypted ? html`${encrypted}` : html`${decrypted}`}
|
||||
</div>
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
${new Date(this.messageObj.timestamp).toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
` : this.isBoth ? html`
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
${new Date(this.messageObj.timestamp).toLocaleString()}
|
||||
( <message-time timestamp=${this.messageObj.timestamp}></message-time> )
|
||||
</span>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div style="margin-top: 4px;">
|
||||
${isEncrypted ? html`${encrypted}` : html`${decrypted}`}
|
||||
</div>
|
||||
<div id="timeformat">
|
||||
<span>
|
||||
${new Date(this.messageObj.timestamp).toLocaleString()}
|
||||
( <message-time timestamp=${this.messageObj.timestamp}></message-time> )
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
` : ''
|
||||
}
|
||||
@@ -2176,7 +2204,7 @@ class MessageTemplate extends LitElement {
|
||||
|
||||
await writeFile(fileHandle, blob).then(() => console.log('FILE SAVED'))
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2014,8 +2014,13 @@ export const chatStyles = css`
|
||||
}
|
||||
|
||||
#messageContent code {
|
||||
background-color: rgba(#616161, 0.1);
|
||||
color: #616161;
|
||||
background: #0D0D0D;
|
||||
color: #FFF;
|
||||
font-family: 'JetBrainsMono', monospace;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
white-space: pre-wrap;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#messageContent pre {
|
||||
@@ -2034,12 +2039,10 @@ export const chatStyles = css`
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
|
||||
#messageContent img {
|
||||
width: 1.7em;
|
||||
height: 1.5em;
|
||||
margin: 0px;
|
||||
|
||||
}
|
||||
|
||||
#messageContent blockquote {
|
||||
@@ -2078,8 +2081,13 @@ export const chatStyles = css`
|
||||
}
|
||||
|
||||
.replied-message code {
|
||||
background-color: rgba(#616161, 0.1);
|
||||
color: #616161;
|
||||
background: #0D0D0D;
|
||||
color: #FFF;
|
||||
font-family: 'JetBrainsMono', monospace;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 0.5rem;
|
||||
white-space: pre-wrap;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.replied-message pre {
|
||||
|
@@ -55,6 +55,125 @@ export const mimeToExtensionMap = {
|
||||
"application/x-bzip2": ".bz2",
|
||||
}
|
||||
|
||||
export const parseQortalLink = (link) => {
|
||||
const prefix = "qortal://use-embed/"
|
||||
|
||||
let params = {}
|
||||
|
||||
if (!link.startsWith(prefix)) {
|
||||
throw new Error("Invalid link format")
|
||||
}
|
||||
|
||||
const [typePart, queryPart] = link.slice(prefix.length).split("?")
|
||||
const type = typePart.split("/")[0].toUpperCase()
|
||||
|
||||
if (queryPart) {
|
||||
const queryPairs = queryPart.split("&")
|
||||
queryPairs.forEach((pair) => {
|
||||
const [key, value] = pair.split("=")
|
||||
if (key && value) {
|
||||
const decodedKey = decodeURIComponent(key.trim())
|
||||
const decodedValue = value.trim().replace(/<\/?[^>]+(>|$)/g,"")
|
||||
params[decodedKey] = decodedValue
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { type, ...params }
|
||||
}
|
||||
|
||||
export const extensionToPointer = (repString) => {
|
||||
const replace00 = repString.split('qortal://use-embed/').join('<newpointer>qortal://use-embed/')
|
||||
const replace01 = replace00.split('.pdf').join('.pdf</newpointer>')
|
||||
const replace02 = replace01.split('.doc').join('.doc</newpointer>')
|
||||
const replace03 = replace02.split('.xls').join('.xls</newpointer>')
|
||||
const replace04 = replace03.split('.ppt').join('.ppt</newpointer>')
|
||||
const replace05 = replace04.split('.odt').join('.odt</newpointer>')
|
||||
const replace06 = replace05.split('.ods').join('.ods</newpointer>')
|
||||
const replace07 = replace06.split('.odp').join('.odp</newpointer>')
|
||||
const replace08 = replace07.split('.txt').join('.txt</newpointer>')
|
||||
const replace09 = replace08.split('.csv').join('.csv</newpointer>')
|
||||
const replace10 = replace09.split('.html').join('.html</newpointer>')
|
||||
const replace11 = replace10.split('.xml').join('.xml</newpointer>')
|
||||
const replace12 = replace11.split('.json').join('.json</newpointer>')
|
||||
const replace13 = replace12.split('.jpg').join('.jpg</newpointer>')
|
||||
const replace14 = replace13.split('.png').join('.png</newpointer>')
|
||||
const replace15 = replace14.split('.gif').join('.gif</newpointer>')
|
||||
const replace16 = replace15.split('.webp').join('.webp</newpointer>')
|
||||
const replace17 = replace16.split('.svg').join('.svg</newpointer>')
|
||||
const replace18 = replace17.split('.tif').join('.tif</newpointer>')
|
||||
const replace19 = replace18.split('.bmp').join('.bmp</newpointer>')
|
||||
const replace20 = replace19.split('.mp3').join('.mp3</newpointer>')
|
||||
const replace21 = replace20.split('.ogg').join('.ogg</newpointer>')
|
||||
const replace22 = replace21.split('.wav').join('.wav</newpointer>')
|
||||
const replace23 = replace22.split('.webm').join('.webm</newpointer>')
|
||||
const replace24 = replace23.split('.ogv').join('.ogv</newpointer>')
|
||||
const replace25 = replace24.split('.avi').join('.avi</newpointer>')
|
||||
const replace26 = replace25.split('.mov').join('.mov</newpointer>')
|
||||
const replace27 = replace26.split('.wmv').join('.wmv</newpointer>')
|
||||
const replace28 = replace27.split('.mpeg').join('.mpeg</newpointer>')
|
||||
const replace29 = replace28.split('.3gp').join('.3gp</newpointer>')
|
||||
const replace30 = replace29.split('.3g2').join('.3g2</newpointer>')
|
||||
const replace31 = replace30.split('.mkv').join('.mkv</newpointer>')
|
||||
const replace32 = replace31.split('.flv').join('.flv</newpointer>')
|
||||
const replace33 = replace32.split('.zip').join('.zip</newpointer>')
|
||||
const replace34 = replace33.split('.rar').join('.rar</newpointer>')
|
||||
const replace35 = replace34.split('.tar').join('.tar</newpointer>')
|
||||
const replace36 = replace35.split('.7z').join('.7z</newpointer>')
|
||||
const replace37 = replace36.split('.gz').join('.gz</newpointer>')
|
||||
const replace38 = replace37.split('.bz2').join('.bz2</newpointer>')
|
||||
|
||||
return replace38
|
||||
}
|
||||
|
||||
export const encodedToChar = (encodedString) => {
|
||||
const encode01 = encodedString.split('&').join('&')
|
||||
const encode02 = encode01.split(' ').join(' ')
|
||||
const encode03 = encode02.split('<').join('<')
|
||||
const encode04 = encode03.split('>').join('>')
|
||||
const encode05 = encode04.split('"').join('"')
|
||||
const encode06 = encode05.split('%20').join(' ')
|
||||
const encode07 = encode06.split('%23').join('#')
|
||||
const encode08 = encode07.split('%24').join('$')
|
||||
const encode09 = encode08.split('%26').join('&')
|
||||
const encode10 = encode09.split('%2B').join('+')
|
||||
const encode11 = encode10.split('%2C').join(',')
|
||||
const encode12 = encode11.split('%2F').join('/')
|
||||
const encode13 = encode12.split('%3A').join(':')
|
||||
const encode14 = encode13.split('%3B').join(';')
|
||||
const encode15 = encode14.split('%3D').join('=')
|
||||
const encode16 = encode15.split('%3F').join('?')
|
||||
const encode17 = encode16.split('%40').join('@')
|
||||
|
||||
return encode17
|
||||
}
|
||||
|
||||
export const embedToString = (embed) => {
|
||||
let embedString = ''
|
||||
let embedService = ''
|
||||
let embedName = ''
|
||||
let embedIdentifier = ''
|
||||
let embedAttachmentName = ''
|
||||
|
||||
if (embed.type === "IMAGE") {
|
||||
embedService = embed.service
|
||||
embedName = embed.name
|
||||
embedIdentifier = embed.identifier
|
||||
embedString = '"images":[{"service":"' + embedService + '","name":"' + embedName + '","identifier":"' + embedIdentifier + '"}],"isImageDeleted":false'
|
||||
} else if (embed.type === "ATTACHMENT") {
|
||||
embedService = embed.service
|
||||
embedName = embed.name
|
||||
embedIdentifier = embed.identifier
|
||||
embedAttachmentName = embed.fileName
|
||||
embedString = '"attachments":[{"service":"' + embedService + '","name":"' + embedName + '","identifier":"' + embedIdentifier + '","attachmentName":"' + embedAttachmentName + '","attachmentSize":0}],"isAttachmentDeleted":false'
|
||||
} else {
|
||||
embedString = '"images":[""]'
|
||||
}
|
||||
|
||||
return embedString
|
||||
}
|
||||
|
||||
|
||||
export const listOfAllQortalRequests = [
|
||||
'IS_USING_GATEWAY',
|
||||
'ADMIN_ACTION',
|
||||
@@ -69,6 +188,7 @@ export const listOfAllQortalRequests = [
|
||||
'DECRYPT_QORTAL_GROUP_DATA',
|
||||
'ENCRYPT_DATA_WITH_SHARING_KEY',
|
||||
'DECRYPT_DATA_WITH_SHARING_KEY',
|
||||
'DECRYPT_AESGCM',
|
||||
'CREATE_TRADE_BUY_ORDER',
|
||||
'CREATE_TRADE_SELL_ORDER',
|
||||
'CANCEL_TRADE_SELL_ORDER',
|
||||
|
@@ -33,6 +33,9 @@ export const ENCRYPT_DATA_WITH_SHARING_KEY = 'ENCRYPT_DATA_WITH_SHARING_KEY'
|
||||
// DECRYPT_DATA_WITH_SHARING_KEY
|
||||
export const DECRYPT_DATA_WITH_SHARING_KEY = 'DECRYPT_DATA_WITH_SHARING_KEY'
|
||||
|
||||
// DECRYPT_AESGCM
|
||||
export const DECRYPT_AESGCM = 'DECRYPT_AESGCM'
|
||||
|
||||
// CREATE_TRADE_BUY_ORDER
|
||||
export const CREATE_TRADE_BUY_ORDER = 'CREATE_TRADE_BUY_ORDER'
|
||||
|
||||
|
@@ -5,7 +5,12 @@ import {
|
||||
uint8ArrayToObject,
|
||||
decryptSingle
|
||||
} from './GroupEncryption.js'
|
||||
|
||||
import {
|
||||
extensionToPointer,
|
||||
encodedToChar,
|
||||
embedToString,
|
||||
parseQortalLink
|
||||
} from './qdn-action-constants.js'
|
||||
|
||||
const nacl = {}
|
||||
|
||||
@@ -2738,7 +2743,6 @@ class Curve25519 {
|
||||
}
|
||||
|
||||
const base58Instant = new Base58()
|
||||
|
||||
const curve25519Instance = new Curve25519()
|
||||
|
||||
self.addEventListener('message', async (e) => {
|
||||
@@ -2762,8 +2766,16 @@ self.addEventListener('message', async (e) => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const decode = (string, keys, ref) => {
|
||||
let repliedToStr = ''
|
||||
let hubSpecialId = ''
|
||||
let hubMessageStr = ''
|
||||
let newMessageObject = ''
|
||||
let reactionStr = ''
|
||||
let messageUseEmbed = {}
|
||||
let editStr = false
|
||||
let embedFileStr = '"images":[""]'
|
||||
|
||||
const binaryString = atob(string)
|
||||
const binaryLength = binaryString.length
|
||||
const bytes = new Uint8Array(binaryLength)
|
||||
@@ -2784,66 +2796,49 @@ const decode = (string, keys, ref) => {
|
||||
return decodedString
|
||||
}
|
||||
} else {
|
||||
let repliedToStr = ''
|
||||
let messageStr = ''
|
||||
let hubString = ''
|
||||
|
||||
const res = decryptSingle(string, keys, false)
|
||||
|
||||
if (res === 'noKey' || res === 'decryptionFailed') {
|
||||
return '{"messageText":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"This message could not be decrypted"}]}]},"images":[""],"repliedTo":"","version":3}'
|
||||
return '{"specialId":"","message":"<p>This message could not be decrypted</p>","repliedTo":"","isEdited":false,"isFromHub":true,"version": 3}'
|
||||
}
|
||||
|
||||
const decryptToUnit8Array = base64ToUint8Array(res)
|
||||
const responseData = uint8ArrayToObject(decryptToUnit8Array)
|
||||
|
||||
if (responseData.type === "notification") {
|
||||
const messageStrRaw = responseData.data.message
|
||||
messageStr = messageStrRaw.trim()
|
||||
}
|
||||
|
||||
if (ref !== "noref") {
|
||||
if (responseData.type === "reaction") {
|
||||
repliedToStr = ref
|
||||
messageStr = responseData.content
|
||||
}
|
||||
}
|
||||
|
||||
if (responseData.hasOwnProperty('message') && typeof responseData['message'] === 'string' && responseData['message'].length) {
|
||||
const messageRep = responseData.message
|
||||
const messageRep1 = messageRep.split('"').join('<upvote>')
|
||||
const messageRep2 = messageRep1.split('</p><p></p><p></p><p></p><p>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep3 = messageRep2.split('</p><p></p><p></p><p>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep4 = messageRep3.split('</p><p></p><p>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep5 = messageRep4.replace('</p><p>', '')
|
||||
const messageRep6 = messageRep5.replace('<p></p>', '')
|
||||
const messageRep7 = messageRep6.replace('<p>', '')
|
||||
const messageRep8 = messageRep7.replace('<br></p>', '')
|
||||
const messageRep9 = messageRep8.replace('</p>', '')
|
||||
const messageRep10 = messageRep9.trim()
|
||||
const messageRep11 = messageRep10.split('<br><br><br><br>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep12 = messageRep11.split('<br><br><br>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep13 = messageRep12.split('<br><br>').join('"},{"type":"hardBreak"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
const messageRep14 = messageRep13.split('<br>').join('"},{"type":"hardBreak"},{"type":"text","text":"')
|
||||
messageStr = messageRep14
|
||||
if (responseData.type === "edit") {
|
||||
editStr = true
|
||||
}
|
||||
|
||||
if (responseData.repliedTo) {
|
||||
repliedToStr = responseData.repliedTo
|
||||
}
|
||||
|
||||
if (responseData.type === "edit") {
|
||||
hubString = '{"messageText":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"' + messageStr + '"}]}]},"images":[""],"repliedTo":"' + repliedToStr + '","version":3,"isEdited":true}'
|
||||
} else if (responseData.type === "reaction") {
|
||||
hubString = '{"messageText":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"' + messageStr + '"}]}]},"images":[""],"repliedTo":"' + repliedToStr + '","version":3,"isReaction":true}'
|
||||
} else {
|
||||
hubString = '{"messageText":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"' + messageStr + '"}]}]},"images":[""],"repliedTo":"' + repliedToStr + '","version":3}'
|
||||
if (responseData.specialId) {
|
||||
hubSpecialId = responseData.specialId
|
||||
}
|
||||
|
||||
const preparedString = hubString.split('<upvote>').join('\\"')
|
||||
const finalString = preparedString.replace(/<\/?[^>]+(>|$)/g, '')
|
||||
if (responseData.type === "notification") {
|
||||
hubMessageStr = responseData.data.message
|
||||
} else if (ref !== "noref" && responseData.type === "reaction") {
|
||||
reactionStr = '"isReaction":true,'
|
||||
repliedToStr = ref
|
||||
hubMessageStr = responseData.content
|
||||
} else if (responseData.message.includes('qortal://use-embed/')) {
|
||||
const useEmbed1 = extensionToPointer(responseData.message)
|
||||
const useEmbed2 = /<newpointer>(.*?)<\/newpointer>/g.exec(useEmbed1)
|
||||
const useEmbed3 = encodedToChar(useEmbed2[1])
|
||||
messageUseEmbed = parseQortalLink(useEmbed3)
|
||||
embedFileStr = embedToString(messageUseEmbed)
|
||||
hubMessageStr = responseData.message.split(useEmbed2[1]).join('')
|
||||
} else {
|
||||
hubMessageStr = responseData.message
|
||||
}
|
||||
|
||||
return finalString
|
||||
const hubMessageFinal = hubMessageStr.split('"').join('"')
|
||||
|
||||
newMessageObject = '{"specialId":"' + hubSpecialId + '","message":"' + hubMessageFinal + '",' + embedFileStr + ',"repliedTo":"' + repliedToStr + '","isEdited":' + editStr + ',"isFromHub":true,' + reactionStr + '"version": 3}'
|
||||
|
||||
return newMessageObject
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2950,4 +2945,4 @@ const decodeMessage = (encodedMessageObj, isReceipient, _publicKey, privateKey,
|
||||
}
|
||||
|
||||
return decodedMessageObj
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -317,7 +317,7 @@ class Chat extends LitElement {
|
||||
<!-- View Chat Over ID -->
|
||||
<mwc-dialog id="viewChatDialog">
|
||||
<div style="text-align: center;">
|
||||
<h1>Please Enter The Group ID</h1>
|
||||
<h1>${translate("modals.mpchange87")}</h1>
|
||||
<hr>
|
||||
<br>
|
||||
</div>
|
||||
@@ -326,7 +326,7 @@ class Chat extends LitElement {
|
||||
style="width: 100%;"
|
||||
required
|
||||
id="groupIdInput"
|
||||
label="Emter Group ID"
|
||||
label="${translate("managegroup.mg8")}"
|
||||
type="number"
|
||||
auto-validate="false"
|
||||
value=""
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -136,9 +136,10 @@ function attemptReconnectNodeStatusSocket() {
|
||||
const initBlockSocket = () => {
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ":" + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let activeBlockSocketLink
|
||||
|
||||
if (window.parent.location.protocol === "https:") {
|
||||
if (nodeProtocol === "https") {
|
||||
activeBlockSocketLink = `wss://${nodeUrl}/websockets/blocks`
|
||||
} else {
|
||||
activeBlockSocketLink = `ws://${nodeUrl}/websockets/blocks`
|
||||
@@ -205,9 +206,10 @@ const pingactiveBlockSocket = () => {
|
||||
const initNodeStatusSocket = () => {
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ":" + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let activeNodeStatusSocketLink
|
||||
|
||||
if (window.parent.location.protocol === "https:") {
|
||||
if (nodeProtocol === "https") {
|
||||
activeNodeStatusSocketLink = `wss://${nodeUrl}/websockets/admin/status`
|
||||
} else {
|
||||
activeNodeStatusSocketLink = `ws://${nodeUrl}/websockets/admin/status`
|
||||
|
@@ -112,9 +112,10 @@ parentEpml.subscribe('logged_in', async isLoggedIn => {
|
||||
const initChatHeadSocket = () => {
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ":" + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let activeChatSocketLink
|
||||
|
||||
if (window.parent.location.protocol === "https:") {
|
||||
if (nodeProtocol === "https") {
|
||||
activeChatSocketLink = `wss://${nodeUrl}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}?encoding=BASE64`
|
||||
} else {
|
||||
activeChatSocketLink = `ws://${nodeUrl}/websockets/chat/active/${window.parent.reduxStore.getState().app.selectedAddress.address}?encoding=BASE64`
|
||||
|
@@ -2882,7 +2882,7 @@ class TradeBotPortal extends LitElement {
|
||||
const initTradeOffersWebSocket = (restarted = false) => {
|
||||
let tradeOffersSocketCounter = 0
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN&includeHistoric=true`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN&includeHistoric=true`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -2914,7 +2914,7 @@ class TradeBotPortal extends LitElement {
|
||||
|
||||
const initTradeBotWebSocket = (restarted = false) => {
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradebot?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradebot?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -2943,7 +2943,7 @@ class TradeBotPortal extends LitElement {
|
||||
|
||||
const initTradePresenceWebSocket = (restarted = false) => {
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradepresence`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradepresence`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -3289,10 +3289,19 @@ class TradeBotPortal extends LitElement {
|
||||
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ':' + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let checkProtocol
|
||||
|
||||
if (nodeProtocol === "https") {
|
||||
checkProtocol = 'wss'
|
||||
} else {
|
||||
checkProtocol = 'ws'
|
||||
}
|
||||
|
||||
const modifiers = [
|
||||
{ searchValue: 'PROTOCOL', replaceValue: checkProtocol },
|
||||
{ searchValue: 'NODEURL', replaceValue: nodeUrl },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin }
|
||||
]
|
||||
|
||||
workers.get(this.selectedCoin).tradesConnectedWorker = this.inlineWorker(this.initSocket, modifiers)
|
||||
|
@@ -2181,7 +2181,7 @@ class TradePortal extends LitElement {
|
||||
const initTradeOffersWebSocket = (restarted = false) => {
|
||||
let tradeOffersSocketCounter = 0
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN&includeHistoric=true`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN&includeHistoric=true`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -2213,7 +2213,7 @@ class TradePortal extends LitElement {
|
||||
|
||||
const initTradeBotWebSocket = (restarted = false) => {
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradebot?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradebot?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -2242,7 +2242,7 @@ class TradePortal extends LitElement {
|
||||
|
||||
const initTradePresenceWebSocket = (restarted = false) => {
|
||||
let socketTimeout
|
||||
let socketLink = `ws://NODEURL/websockets/crosschain/tradepresence`
|
||||
let socketLink = `PROTOCOL://NODEURL/websockets/crosschain/tradepresence`
|
||||
const socket = new WebSocket(socketLink)
|
||||
socket.onopen = () => {
|
||||
setTimeout(pingSocket, 50)
|
||||
@@ -2726,10 +2726,19 @@ class TradePortal extends LitElement {
|
||||
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ':' + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let checkProtocol
|
||||
|
||||
if (nodeProtocol === "https") {
|
||||
checkProtocol = 'wss'
|
||||
} else {
|
||||
checkProtocol = 'ws'
|
||||
}
|
||||
|
||||
const modifiers = [
|
||||
{ searchValue: 'PROTOCOL', replaceValue: checkProtocol },
|
||||
{ searchValue: 'NODEURL', replaceValue: nodeUrl },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin }
|
||||
]
|
||||
|
||||
workers.get(this.selectedCoin).tradesConnectedWorker = this.inlineWorker(this.initSocket, modifiers)
|
||||
@@ -2791,7 +2800,7 @@ class TradePortal extends LitElement {
|
||||
})
|
||||
|
||||
const getCompletedTrades = async () => {
|
||||
const url = `http://NODEURL/crosschain/trades?limit=25&reverse=true&foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const url = `PROTOCOL://NODEURL/crosschain/trades?limit=25&reverse=true&foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const res = await fetch(url)
|
||||
const historicTrades = await res.json()
|
||||
const compareFn = (a, b) => {
|
||||
@@ -2810,7 +2819,7 @@ class TradePortal extends LitElement {
|
||||
}
|
||||
|
||||
const getOffers = async () => {
|
||||
const url = `http://NODEURL/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const url = `PROTOCOL://NODEURL/crosschain/tradeoffers?foreignBlockchain=FOREIGN_BLOCKCHAIN`
|
||||
const res = await fetch(url)
|
||||
const openTradeOrders = await res.json()
|
||||
const myOpenTradeOrders = await openTradeOrders.filter((order) => order.mode === 'OFFERING' && order.qortalCreator === 'SELECTED_ADDRESS')
|
||||
@@ -2872,11 +2881,20 @@ class TradePortal extends LitElement {
|
||||
|
||||
let myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
let nodeUrl = myNode.domain + ':' + myNode.port
|
||||
let nodeProtocol = myNode.protocol
|
||||
let checkProtocol
|
||||
|
||||
if (nodeProtocol === "https") {
|
||||
checkProtocol = 'https'
|
||||
} else {
|
||||
checkProtocol = 'http'
|
||||
}
|
||||
|
||||
const modifiers = [
|
||||
{ searchValue: 'PROTOCOL', replaceValue: checkProtocol },
|
||||
{ searchValue: 'NODEURL', replaceValue: nodeUrl },
|
||||
{ searchValue: 'SELECTED_ADDRESS', replaceValue: this.selectedAddress.address, },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin, },
|
||||
{ searchValue: 'SELECTED_ADDRESS', replaceValue: this.selectedAddress.address },
|
||||
{ searchValue: 'FOREIGN_BLOCKCHAIN', replaceValue: this.selectedCoin, }
|
||||
]
|
||||
|
||||
workers.get(this.selectedCoin).handleStuckTradesConnectedWorker = this.inlineWorker(this.handleStuckTrades, modifiers)
|
||||
|
@@ -1105,6 +1105,19 @@ export const publishData = async ({
|
||||
}
|
||||
}
|
||||
|
||||
export async function getNameInfo(address) {
|
||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
const nodeUrl = `${myNode.protocol}://${myNode.domain}:${myNode.port}`
|
||||
const response = await fetch(`${nodeUrl}/names/address/` + address)
|
||||
const nameData = await response.json()
|
||||
|
||||
if (nameData.length > 0) {
|
||||
return nameData[0].name
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
export const getPublishesFromAdmins = async (admins, groupId) => {
|
||||
const queryString = admins.map((name) => `name=${name}`).join("&")
|
||||
const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
|
||||
@@ -1113,7 +1126,7 @@ export const getPublishesFromAdmins = async (admins, groupId) => {
|
||||
const response = await fetch(url)
|
||||
|
||||
if (!response.ok) {
|
||||
consoöe.error("network error")
|
||||
console.error("network error")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1178,7 +1191,7 @@ export const getPublishesFromAdminsAdminSpace = async (admins, groupId) => {
|
||||
const response = await fetch(url)
|
||||
|
||||
if (!response.ok) {
|
||||
consoöe.error("network error")
|
||||
console.error("network error")
|
||||
return false
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user