Skip to content
Snippets Groups Projects
Commit d8ee7504 authored by Klaus-Dieter Quibeldey-Cirkel's avatar Klaus-Dieter Quibeldey-Cirkel
Browse files

Merge branch '178-implement-determine-user-role-interface-for-backend-2' into 'staging'

create role function in comment service, add createdBy to comment.ts, test for...

Closes #178

See merge request arsnova/topic-cloud!144
parents 156338fc 86c7bee6
No related merge requests found
......@@ -423,9 +423,9 @@ export class CommentListComponent implements OnInit, OnDestroy {
case this.owner:
return c.creatorId === this.user.id;
case this.moderator:
return c.creatorId === this.user.id && (this.user.role === 2 || this.user.role === 1);
return this.moderatorIds.includes(c.creatorId);
case this.lecturer:
return c.creatorId === this.user.id && this.user.role === 3;
return c.createdFromLecturer;
}
});
this.hideCommentsList = true;
......
......@@ -64,6 +64,7 @@ export class CommentComponent implements OnInit, AfterViewInit {
isExpandable = false;
selectedKeyword = '';
filterProfanityForModerators = false;
createdBy;
constructor(protected authenticationService: AuthenticationService,
private route: ActivatedRoute,
......
......@@ -26,6 +26,7 @@ export class Comment {
upvotes: number;
downvotes: number;
language: Language;
createdBy;
constructor(roomId: string = '',
creatorId: string = '',
......@@ -46,7 +47,8 @@ export class Comment {
keywordsFromSpacy: SpacyKeyword[] = [],
upvotes = 0,
downvotes = 0,
language = Language.auto) {
language = Language.auto,
createdBy?: any) {
this.id = '';
this.roomId = roomId;
this.creatorId = creatorId;
......@@ -69,6 +71,7 @@ export class Comment {
this.upvotes = upvotes;
this.downvotes = downvotes;
this.language = language;
this.createdBy = createdBy;
}
static mapModelToLanguage(model: Model): Language {
......
......@@ -105,7 +105,7 @@ export class CommentService extends BaseHttpService {
getAckComments(roomId: string): Observable<Comment[]> {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find;
return this.http.post<Comment[]>(connectionUrl, {
properties: { roomId: roomId, ack: true },
properties: { roomId, ack: true },
externalFilters: {}
}, httpOptions).pipe(
map(commentList => commentList.map(comment => this.parseComment(comment))),
......@@ -117,12 +117,10 @@ export class CommentService extends BaseHttpService {
getRejectedComments(roomId: string): Observable<Comment[]> {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find;
return this.http.post<Comment[]>(connectionUrl, {
properties: { roomId: roomId, ack: false },
properties: { roomId, ack: false },
externalFilters: {}
}, httpOptions).pipe(
map(commentList => {
return commentList.map(comment => this.parseComment(comment));
}),
map(commentList => commentList.map(comment => this.parseComment(comment))),
tap(_ => ''),
catchError(this.handleError<Comment[]>('getComments', []))
);
......@@ -131,12 +129,10 @@ export class CommentService extends BaseHttpService {
getComments(roomId: string): Observable<Comment[]> {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find;
return this.http.post<Comment[]>(connectionUrl, {
properties: { roomId: roomId },
properties: { roomId },
externalFilters: {}
}, httpOptions).pipe(
map(commentList => {
return commentList.map(comment => this.parseComment(comment));
}),
map(commentList => commentList.map(comment => this.parseComment(comment))),
tap(_ => ''),
catchError(this.handleError<Comment[]>('getComments', []))
);
......@@ -175,6 +171,14 @@ export class CommentService extends BaseHttpService {
);
}
role(comment: Comment) {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + '/' + comment.id + '/role';
return this.http.patch(connectionUrl, httpOptions).pipe(
tap(_ => ''),
catchError(this.handleError<any>('roleComment'))
);
}
deleteCommentsByRoomId(roomId: string): Observable<Comment> {
const connectionUrl = `${this.apiUrl.base + this.apiUrl.comment}/byRoom?roomId=${roomId}`;
return this.http.delete<Comment>(connectionUrl, httpOptions).pipe(
......@@ -186,7 +190,7 @@ export class CommentService extends BaseHttpService {
countByRoomId(roomId: string, ack: boolean): Observable<number> {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find + this.apiUrl.count;
return this.http.post<number>(connectionUrl, {
properties: { roomId: roomId, ack: ack },
properties: { roomId, ack },
externalFilters: {}
}, httpOptions).pipe(
tap(_ => ''),
......@@ -231,6 +235,7 @@ export class CommentService extends BaseHttpService {
comment.keywordsFromQuestioner = comment.keywordsFromQuestioner ?
JSON.parse(comment.keywordsFromQuestioner as unknown as string) : null;
comment.keywordsFromSpacy = comment.keywordsFromSpacy ? JSON.parse(comment.keywordsFromSpacy as unknown as string) : null;
console.log(comment);
return comment;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment