Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Fixed folder access
Browse files Browse the repository at this point in the history
  • Loading branch information
Migarve55 committed Mar 9, 2019
1 parent b63b0db commit f787fb3
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/app/services/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ChatService {
let message = `
@prefix : <#>.
@prefix schem: <http://schema.org/>.
@prefix s: <${this.thisUser.webId.replace("me","")}>.
@prefix s: <${this.thisUser.webId.replace("#me","#")}>.
:message
a schem:Message;
Expand Down Expand Up @@ -177,31 +177,22 @@ export class ChatService {

async checkFolderStructure() {
await this.rdf.getSession();
await this.basicFolderStructure();
try {
this.getChatUrl(this.thisUser, this.otherUser).then(response => {
fileClient.readFolder(response).then(success => {
console.log("Folder structure correct");
}, err => {
this.createFolderStructure(response.toString()).then(res => {
this.grantAccessToFolder(response, this.otherUser);
});
fileClient.readFolder(response).then(success => {
console.log("Folder structure correct");
}, err => {
this.createFolderStructure(response.toString()).then(res => {
console.log(response);
this.grantAccessToFolder(response, this.otherUser);
});
});
});
});
} catch (error) {
console.log(`Error creating folder structure/with permissions: ${error}`);
}
}

private basicFolderStructure() {
let path = this.thisUser.webId.replace("/profile/card#me", "/private/dechat/");
fileClient.readFolder(path).then(response => {
console.log("Basic folder structure correct");
}), err => {
this.createFolderStructure(path);
}
}

private async createFolderStructure(path : string) {
fileClient.createFolder(path).then(success => {
console.log(`Created folder ${path}.`);
Expand All @@ -216,7 +207,8 @@ export class ChatService {
}

private grantAccessToFolder(path, user : User) {
let webId = user.webId.replace("me", "");
let webId = user.webId.replace("#me", "#");
console.log(webId);
let acl =
`@prefix : <#>.
@prefix n0: <http://www.w3.org/ns/auth/acl#>.
Expand Down

0 comments on commit f787fb3

Please sign in to comment.