mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-14 20:11:22 +00:00
Add check condition
This commit is contained in:
parent
1e078e1324
commit
5444bacdd0
@ -440,7 +440,7 @@ const handleNotificationDirect = async (directs) => {
|
||||
let isFocused;
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
let isDisableNotifications =
|
||||
const isDisableNotifications =
|
||||
(await getUserSettings({ key: 'disable-push-notifications' })) || false;
|
||||
const dataDirects = directs.filter((direct) => direct?.sender !== address);
|
||||
try {
|
||||
@ -1734,7 +1734,7 @@ export async function decryptSingleFunc({
|
||||
secretKeyObject,
|
||||
skipDecodeBase64,
|
||||
}) {
|
||||
let holdMessages = [];
|
||||
const holdMessages = [];
|
||||
|
||||
for (const message of messages) {
|
||||
try {
|
||||
@ -1744,9 +1744,11 @@ export async function decryptSingleFunc({
|
||||
skipDecodeBase64,
|
||||
});
|
||||
|
||||
if (res) {
|
||||
const decryptToUnit8Array = base64ToUint8Array(res);
|
||||
const responseData = uint8ArrayToObject(decryptToUnit8Array);
|
||||
holdMessages.push({ ...message, decryptedData: responseData });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@ -1758,7 +1760,7 @@ export async function decryptSingleForPublishes({
|
||||
secretKeyObject,
|
||||
skipDecodeBase64,
|
||||
}) {
|
||||
let holdMessages = [];
|
||||
const holdMessages = [];
|
||||
|
||||
for (const message of messages) {
|
||||
try {
|
||||
@ -2888,6 +2890,7 @@ export async function getTimestampEnterChat() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTimestampMention() {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
@ -2900,6 +2903,7 @@ export async function getTimestampMention() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTimestampGroupAnnouncement() {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
@ -2996,6 +3000,7 @@ async function getGroupData() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getGroupDataSingle(groupId) {
|
||||
const wallet = await getSaveWallet();
|
||||
const address = wallet.address0;
|
||||
@ -3266,6 +3271,7 @@ function setupMessageListener() {
|
||||
break;
|
||||
case 'updateThreadActivity':
|
||||
updateThreadActivityCase(request, event);
|
||||
break;
|
||||
case 'decryptGroupEncryption':
|
||||
decryptGroupEncryptionCase(request, event);
|
||||
break;
|
||||
@ -3411,7 +3417,7 @@ export const checkNewMessages = async () => {
|
||||
myName = userData.name;
|
||||
}
|
||||
|
||||
let newAnnouncements = [];
|
||||
const newAnnouncements = [];
|
||||
const activeData = (await getStoredData('active-groups-directs')) || {
|
||||
groups: [],
|
||||
directs: [],
|
||||
@ -3463,7 +3469,8 @@ export const checkNewMessages = async () => {
|
||||
}
|
||||
})
|
||||
);
|
||||
let isDisableNotifications =
|
||||
|
||||
const isDisableNotifications =
|
||||
(await getUserSettings({ key: 'disable-push-notifications' })) || false;
|
||||
|
||||
if (
|
||||
@ -3611,8 +3618,8 @@ export const checkThreads = async (bringBack) => {
|
||||
if (userData?.name) {
|
||||
myName = userData.name;
|
||||
}
|
||||
let newAnnouncements = [];
|
||||
let dataToBringBack = [];
|
||||
const newAnnouncements = [];
|
||||
const dataToBringBack = [];
|
||||
const threadActivity = await getThreadActivity();
|
||||
if (!threadActivity) return null;
|
||||
|
||||
@ -3627,7 +3634,6 @@ export const checkThreads = async (bringBack) => {
|
||||
for (const thread of selectedThreads) {
|
||||
try {
|
||||
const identifier = `thmsg-${thread?.threadId}`;
|
||||
const name = thread?.qortalName;
|
||||
const endpoint = await getArbitraryEndpoint();
|
||||
const url = await createEndpoint(
|
||||
`${endpoint}?mode=ALL&service=DOCUMENT&identifier=${identifier}&limit=1&includemetadata=false&offset=${0}&reverse=true&prefix=true`
|
||||
@ -3643,7 +3649,6 @@ export const checkThreads = async (bringBack) => {
|
||||
const latestMessage = responseData.filter(
|
||||
(pub) => pub?.name !== myName
|
||||
)[0];
|
||||
// const latestMessage = responseData[0]
|
||||
|
||||
if (!latestMessage) {
|
||||
continue;
|
||||
@ -3717,7 +3722,7 @@ export const checkThreads = async (bringBack) => {
|
||||
'_type=thread-post' +
|
||||
`_data=${JSON.stringify(newAnnouncements[0])}`
|
||||
);
|
||||
let isDisableNotifications =
|
||||
const isDisableNotifications =
|
||||
(await getUserSettings({ key: 'disable-push-notifications' })) || false;
|
||||
if (!isDisableNotifications) {
|
||||
// Check user settings to see if notifications are disabled
|
||||
|
@ -276,15 +276,13 @@ export async function getNameInfo(address: string) {
|
||||
}
|
||||
|
||||
export const getGroupAdmins = async (groupNumber: number) => {
|
||||
// const validApi = await findUsableApi();
|
||||
|
||||
const response = await fetch(
|
||||
`${getBaseApiReact()}/groups/members/${groupNumber}?limit=0&onlyAdmins=true`
|
||||
);
|
||||
const groupData = await response.json();
|
||||
let members: any = [];
|
||||
let membersAddresses = [];
|
||||
let both = [];
|
||||
const members: any = [];
|
||||
const membersAddresses = [];
|
||||
const both = [];
|
||||
|
||||
const getMemNames = groupData?.members?.map(async (member) => {
|
||||
if (member?.member) {
|
||||
@ -601,9 +599,11 @@ export const Group = ({
|
||||
|
||||
const getGroupOwner = async (groupId) => {
|
||||
try {
|
||||
if (groupId == 0) return;
|
||||
|
||||
const url = `${getBaseApiReact()}/groups/${groupId}`;
|
||||
const response = await fetch(url);
|
||||
let data = await response.json();
|
||||
const data = await response.json();
|
||||
|
||||
const name = await getNameInfo(data?.owner);
|
||||
if (name) {
|
||||
@ -742,7 +742,7 @@ export const Group = ({
|
||||
data = await res.text();
|
||||
}
|
||||
|
||||
const decryptedKey: any = await decryptResource(data);
|
||||
const decryptedKey: any = await decryptResource(data, null);
|
||||
const dataint8Array = base64ToUint8Array(decryptedKey.data);
|
||||
const decryptedKeyToObject = uint8ArrayToObject(dataint8Array);
|
||||
|
||||
@ -877,6 +877,8 @@ export const Group = ({
|
||||
};
|
||||
|
||||
const getOwnerNameForGroup = async (owner: string, groupId: string) => {
|
||||
if (groupId == '0') return;
|
||||
|
||||
try {
|
||||
if (!owner) return;
|
||||
if (groupsOwnerNamesRef.current[groupId]) return;
|
||||
@ -899,7 +901,7 @@ export const Group = ({
|
||||
const url = `${getBaseApiReact()}/groups/member/${address}`;
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error('Cannot get group properties');
|
||||
let data = await response.json();
|
||||
const data = await response.json();
|
||||
const transformToObject = data.reduce((result, item) => {
|
||||
result[item.groupId] = item;
|
||||
return result;
|
||||
|
@ -303,6 +303,7 @@ export const decryptSingle = async ({
|
||||
// First, decode the base64-encoded input (if skipDecodeBase64 is not set)
|
||||
const decodedData = skipDecodeBase64 ? data64 : atob(data64);
|
||||
|
||||
if (secretKeyObject) {
|
||||
// Then, decode it again for the specific format (if double encoding is used)
|
||||
const decodeForNumber = atob(decodedData);
|
||||
|
||||
@ -390,7 +391,11 @@ export const decryptSingle = async ({
|
||||
}
|
||||
|
||||
// Decrypt the data using the nonce and messageKey
|
||||
const decryptedData = nacl.secretbox.open(Uint8ArrayData, nonce, messageKey);
|
||||
const decryptedData = nacl.secretbox.open(
|
||||
Uint8ArrayData,
|
||||
nonce,
|
||||
messageKey
|
||||
);
|
||||
|
||||
// Check if decryption was successful
|
||||
if (!decryptedData) {
|
||||
@ -403,6 +408,9 @@ export const decryptSingle = async ({
|
||||
|
||||
// Convert the decrypted Uint8Array back to a Base64 string
|
||||
return uint8ArrayToBase64(decryptedData);
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
export const decryptGroupEncryptionWithSharingKey = async ({
|
||||
|
Loading…
x
Reference in New Issue
Block a user