mirror of
https://github.com/Qortal/qortal-mobile.git
synced 2025-04-01 18:15:54 +00:00
added qortalRequest
This commit is contained in:
parent
893b1e6f5f
commit
dfc173f868
@ -1909,7 +1909,7 @@ export async function leaveGroup({ groupId }) {
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1965,7 +1965,7 @@ export async function cancelInvitationToGroup({ groupId, qortalAddress }) {
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1992,7 +1992,7 @@ export async function cancelBan({ groupId, qortalAddress }) {
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
export async function registerName({ name, description = "" }) {
|
export async function registerName({ name, description = "" }) {
|
||||||
@ -2073,7 +2073,7 @@ export async function makeAdmin({ groupId, qortalAddress }) {
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2100,7 +2100,7 @@ export async function removeAdmin({ groupId, qortalAddress }) {
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2134,7 +2134,7 @@ export async function banFromGroup({
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2166,7 +2166,7 @@ export async function kickFromGroup({
|
|||||||
|
|
||||||
const res = await processTransactionVersion2(signedBytes);
|
const res = await processTransactionVersion2(signedBytes);
|
||||||
if (!res?.signature)
|
if (!res?.signature)
|
||||||
throw new Error("Transaction was not able to be processed");
|
throw new Error(res?.message || "Transaction was not able to be processed");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ const UIQortalRequests = [
|
|||||||
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
'GET_TX_ACTIVITY_SUMMARY', 'GET_FOREIGN_FEE', 'UPDATE_FOREIGN_FEE',
|
||||||
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
'GET_SERVER_CONNECTION_HISTORY', 'SET_CURRENT_FOREIGN_SERVER',
|
||||||
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
'ADD_FOREIGN_SERVER', 'REMOVE_FOREIGN_SERVER', 'GET_DAY_SUMMARY', 'CREATE_TRADE_BUY_ORDER',
|
||||||
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_GATEWAY', 'SIGN_TRANSACTION', 'ADMIN_ACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN'
|
'CREATE_TRADE_SELL_ORDER', 'CANCEL_TRADE_SELL_ORDER', 'IS_USING_GATEWAY', 'SIGN_TRANSACTION', 'ADMIN_ACTION', 'OPEN_NEW_TAB', 'CREATE_AND_COPY_EMBED_LINK', 'DECRYPT_QORTAL_GROUP_DATA', 'DECRYPT_DATA_WITH_SHARING_KEY', 'DELETE_HOSTED_DATA', 'GET_HOSTED_DATA', 'SHOW_ACTIONS', 'REGISTER_NAME', 'UPDATE_NAME', 'LEAVE_GROUP', 'INVITE_TO_GROUP', 'KICK_FROM_GROUP', 'BAN_FROM_GROUP', 'CANCEL_GROUP_BAN', 'ADD_GROUP_ADMIN'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { gateways, getApiKeyFromStorage } from "./background";
|
import { gateways, getApiKeyFromStorage } from "./background";
|
||||||
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
import { listOfAllQortalRequests } from "./components/Apps/useQortalMessageListener";
|
||||||
import { addForeignServer, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createPoll, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
import { addForeignServer, addGroupAdminRequest, addListItems, adminAction, banFromGroupRequest, cancelGroupBanRequest, cancelSellOrder, createAndCopyEmbedLink, createBuyOrder, createPoll, decryptData, decryptDataWithSharingKey, decryptQortalGroupData, deleteHostedData, deleteListItems, deployAt, encryptData, encryptDataWithSharingKey, encryptQortalGroupData, getCrossChainServerInfo, getDaySummary, getForeignFee, getHostedData, getListItems, getServerConnectionHistory, getTxActivitySummary, getUserAccount, getUserWallet, getUserWalletInfo, getWalletBalance, inviteToGroupRequest, joinGroup, kickFromGroupRequest, leaveGroupRequest, openNewTab, publishMultipleQDNResources, publishQDNResource, registerNameRequest, removeForeignServer, saveFile, sendChatMessage, sendCoin, setCurrentForeignServer, signTransaction, updateForeignFee, updateNameRequest, voteOnPoll } from "./qortalRequests/get";
|
||||||
import { getData, storeData } from "./utils/chromeStorage";
|
import { getData, storeData } from "./utils/chromeStorage";
|
||||||
|
|
||||||
|
|
||||||
@ -1005,6 +1005,25 @@ export const isRunningGateway = async ()=> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "ADD_GROUP_ADMIN" : {
|
||||||
|
try {
|
||||||
|
const res = await addGroupAdminRequest(request.payload, isFromExtension)
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
payload: res,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
} catch (error) {
|
||||||
|
event.source.postMessage({
|
||||||
|
requestId: request.requestId,
|
||||||
|
action: request.action,
|
||||||
|
error: error?.message,
|
||||||
|
type: "backgroundMessageResponse",
|
||||||
|
}, event.origin);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ import {
|
|||||||
inviteToGroup,
|
inviteToGroup,
|
||||||
banFromGroup,
|
banFromGroup,
|
||||||
kickFromGroup,
|
kickFromGroup,
|
||||||
cancelBan
|
cancelBan,
|
||||||
|
makeAdmin
|
||||||
} from "../background";
|
} from "../background";
|
||||||
import { getNameInfo, uint8ArrayToObject } from "../backgroundFunctions/encryption";
|
import { getNameInfo, uint8ArrayToObject } from "../backgroundFunctions/encryption";
|
||||||
import { showSaveFilePicker } from "../components/Apps/useQortalMessageListener";
|
import { showSaveFilePicker } from "../components/Apps/useQortalMessageListener";
|
||||||
@ -4081,3 +4082,50 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
|
|||||||
throw new Error("User declined request");
|
throw new Error("User declined request");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addGroupAdminRequest = async (data, isFromExtension) => {
|
||||||
|
const requiredFields = ["groupId", "qortalAddress"];
|
||||||
|
const missingFields: string[] = [];
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field]) {
|
||||||
|
missingFields.push(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const groupId = data.groupId
|
||||||
|
const qortalAddress = data?.qortalAddress
|
||||||
|
|
||||||
|
let groupInfo = null;
|
||||||
|
try {
|
||||||
|
const url = await createEndpoint(`/groups/${groupId}`);
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch group");
|
||||||
|
|
||||||
|
groupInfo = await response.json();
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = (error && error.message) || "Group not found";
|
||||||
|
throw new Error(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayInvitee = await getNameInfoForOthers(qortalAddress)
|
||||||
|
|
||||||
|
const fee = await getFee("ADD_GROUP_ADMIN");
|
||||||
|
const resPermission = await getUserPermission(
|
||||||
|
{
|
||||||
|
text1: `Do you give this application permission to add user ${displayInvitee || qortalAddress} as an admin?`,
|
||||||
|
highlightedText: `Group: ${groupInfo.groupName}`,
|
||||||
|
fee: fee.fee,
|
||||||
|
},
|
||||||
|
isFromExtension
|
||||||
|
);
|
||||||
|
const { accepted } = resPermission;
|
||||||
|
if (accepted) {
|
||||||
|
const response = await makeAdmin({
|
||||||
|
groupId,
|
||||||
|
qortalAddress,
|
||||||
|
})
|
||||||
|
return response
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw new Error("User declined request");
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user