Skip to content

Commit

Permalink
Allow tutors to monitor channels as moderator for course wide channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
cremertim committed Nov 26, 2024
1 parent e3ed347 commit 1138b94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ public Optional<Conversation> isMemberOrCreateForCourseWideElseThrow(Long conver

if (conversation instanceof Channel channel && channel.getIsCourseWide()) {
ConversationParticipant conversationParticipant = ConversationParticipant.createWithDefaultValues(user, channel);
conversationParticipant.setIsModerator(authorizationCheckService.isAtLeastInstructorInCourse(channel.getCourse(), user));
boolean canBecomeModerator = (channel.getIsAnnouncementChannel() ? authorizationCheckService.isAtLeastInstructorInCourse(channel.getCourse(), user)
: authorizationCheckService.isAtLeastTeachingAssistantInCourse(channel.getCourse(), user));
conversationParticipant.setIsModerator(canBecomeModerator);
lastReadDate.ifPresent(conversationParticipant::setLastRead);
conversationParticipantRepository.saveAndFlush(conversationParticipant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ export class AnswerPostReactionsBarComponent extends PostingsReactionsBarDirecti
this.isAuthorOfOriginalPost = this.metisService.metisUserIsAuthorOfPosting(this.posting.post!);
this.isAnswerOfAnnouncement = getAsChannelDTO(this.posting.post?.conversation)?.isAnnouncementChannel ?? false;
const isCourseWideChannel = getAsChannelDTO(this.posting.post?.conversation)?.isCourseWide ?? false;
const isAtLeastInstructorInCourse = this.metisService.metisUserIsAtLeastInstructorInCourse();
const isAtLeastTutorInCourse = this.metisService.metisUserIsAtLeastTutorInCourse();
const canDeleteAndEditAnnouncement = this.isAnswerOfAnnouncement ? this.metisService.metisUserIsAtLeastInstructorInCourse() : true;
const mayEditOrDeleteOtherUsersAnswer =
(isCourseWideChannel && isAtLeastInstructorInCourse) || (getAsChannelDTO(this.metisService.getCurrentConversation())?.hasChannelModerationRights ?? false);
this.mayEditOrDelete = !this.isReadOnlyMode && (this.isAuthorOfPosting || mayEditOrDeleteOtherUsersAnswer);
(isCourseWideChannel && isAtLeastTutorInCourse) || (getAsChannelDTO(this.metisService.getCurrentConversation())?.hasChannelModerationRights ?? false);
this.mayEditOrDelete = !this.isReadOnlyMode && (this.isAuthorOfPosting || mayEditOrDeleteOtherUsersAnswer) && canDeleteAndEditAnnouncement;
this.mayEditOrDeleteOutput.emit(this.mayEditOrDelete);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class PostReactionsBarComponent extends PostingsReactionsBarDirective<Pos
*/
private setCanPin(currentConversation: ConversationDTO | undefined) {
if (!currentConversation) {
this.canPin = this.metisService.metisUserIsAtLeastInstructorInCourse();
this.canPin = this.metisService.metisUserIsAtLeastTutorInCourse();
return;
}

Expand Down Expand Up @@ -186,11 +186,13 @@ export class PostReactionsBarComponent extends PostingsReactionsBarDirective<Pos
}

setMayEditOrDelete(): void {
this.isAtLeastInstructorInCourse = this.metisService.metisUserIsAtLeastInstructorInCourse();
this.isAtLeastTutorInCourse = this.metisService.metisUserIsAtLeastTutorInCourse();
const isCourseWideChannel = getAsChannelDTO(this.posting.conversation)?.isCourseWide ?? false;
const isAnswerOfAnnouncement = getAsChannelDTO(this.posting.conversation)?.isAnnouncementChannel ?? false;
const mayEditOrDeleteOtherUsersAnswer =
(isCourseWideChannel && this.isAtLeastInstructorInCourse) || (getAsChannelDTO(this.metisService.getCurrentConversation())?.hasChannelModerationRights ?? false);
this.mayEditOrDelete = !this.readOnlyMode && !this.previewMode && (this.isAuthorOfPosting || mayEditOrDeleteOtherUsersAnswer);
(isCourseWideChannel && this.isAtLeastTutorInCourse) || (getAsChannelDTO(this.metisService.getCurrentConversation())?.hasChannelModerationRights ?? false);
const canDeleteAndEditAnnouncement = isAnswerOfAnnouncement ? this.metisService.metisUserIsAtLeastInstructorInCourse() : true;
this.mayEditOrDelete = !this.readOnlyMode && !this.previewMode && (this.isAuthorOfPosting || mayEditOrDeleteOtherUsersAnswer) && canDeleteAndEditAnnouncement;
this.mayEditOrDeleteOutput.emit(this.mayEditOrDelete);
}
}

0 comments on commit 1138b94

Please sign in to comment.