mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-09 20:28:29 +03:00
integration: catches cases around trusting another person
This commit is contained in:
parent
0af4431bd3
commit
6898ae8295
@ -63,8 +63,9 @@ export default class IntegrationPage extends React.Component {
|
||||
};
|
||||
|
||||
_handleTrust = async (user) => {
|
||||
const response = await Actions.createTrustRelationship({ userId: user.id });
|
||||
console.log(response);
|
||||
const response = await Actions.createTrustRelationship({
|
||||
userId: user.target_user_id ? user.target_user_id : user.id,
|
||||
});
|
||||
|
||||
await this._handleUpdate();
|
||||
};
|
||||
@ -93,9 +94,27 @@ export default class IntegrationPage extends React.Component {
|
||||
<div css={STYLES_ROW}>
|
||||
<div css={STYLES_COLUMN}>
|
||||
{this.state.viewer.trusted.map((each) => {
|
||||
const status = [];
|
||||
if (each.owner_user_id === this.state.viewer.id) {
|
||||
status.push("THIS IS A REQUEST YOU MADE");
|
||||
}
|
||||
|
||||
if (!each.data.verified) {
|
||||
status.push(
|
||||
"BUT THE PERSON YOU ASKED TO ACCEPT HAS NOT ACCEPTED"
|
||||
);
|
||||
}
|
||||
|
||||
each.status = status;
|
||||
|
||||
return (
|
||||
<div css={STYLES_ITEM} key={each.id}>
|
||||
{JSON.stringify(each, null, 1)}{" "}
|
||||
<div>
|
||||
<button onClick={() => this._handleTrust(each)}>
|
||||
Cancel Pending Request Or Delete Friend
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
@ -34,9 +34,41 @@ export default async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (!req.body.data || !req.body.data.userId) {
|
||||
return res.status(500).json({
|
||||
decorator: "SERVER_TRUSTED_RELATIONSHIP_MUST_PROVIDE_SOMEONE_TO_TRUST",
|
||||
error: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (user.id === req.body.data.userId) {
|
||||
return res.status(500).json({
|
||||
decorator: "SERVER_TRUSTED_RELATIONSHIP_CAN_NOT_TRUST_YOURSELF",
|
||||
error: true,
|
||||
});
|
||||
}
|
||||
|
||||
const targetUser = await Data.getUserById({
|
||||
id: req.body.data.userId,
|
||||
});
|
||||
|
||||
if (!targetUser) {
|
||||
return res.status(404).json({
|
||||
decorator: "SERVER_TRUSTED_RELATIONSHIP_TARGET_USER_NOT_FOUND",
|
||||
error: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (targetUser.error) {
|
||||
return res.status(500).json({
|
||||
decorator: "SERVER_TRUSTED_RELATIONSHIP_TARGET_USER_NOT_FOUND",
|
||||
error: true,
|
||||
});
|
||||
}
|
||||
|
||||
const existingResponse = await Data.getTrustedRelationshipByUserIds({
|
||||
ownerUserId: user.id,
|
||||
targetUserId: req.body.data.userId,
|
||||
targetUserId: targetUser.id,
|
||||
});
|
||||
|
||||
if (existingResponse && existingResponse.error) {
|
||||
|
Loading…
Reference in New Issue
Block a user