Skip to content

Commit

Permalink
last access changes
Browse files Browse the repository at this point in the history
updated changes as smile suggested, created a new canStaff section in the member controller, I also added this section from the controller to the check for which info can be pulled in member service, also changed the watch to watch on the username.
  • Loading branch information
buddysal authored and smile0711 committed Aug 25, 2024
1 parent 570c99f commit b6ff2fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api/src/controllers/member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class MemberController {
if (typeof request.params.id !== 'undefined') {
if (await this.memberService.canAdmin(session.id)) {
memberInfo = await this.memberService.getMemberInfoAdmin(parseInt(request.params.id));
} else if (await this.memberService.canStaff(session.id)) {
memberInfo = await this.memberService.getMemberInfoAdmin(parseInt(request.params.id));
} else if (parseInt(request.params.id) === session.id) {
memberInfo = await this.memberService.getMemberInfo(parseInt(request.params.id));
} else {
Expand Down
16 changes: 14 additions & 2 deletions api/src/services/member/member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ export class MemberService {
return !!roleAssignments.find(assignment => ADMIN_ROLES.includes(assignment.role_id));
}

public async canStaff(memberId: number): Promise<boolean> {
const roleAssignments = await this.roleAssignmentRepository.getByMemberId(memberId);
// Extracted staff roles into a constant for easy management
const STAFF_ROLES = [
this.roleRepository.roleMap.ColonyLeader,
this.roleRepository.roleMap.ColonyDeputy,
this.roleRepository.roleMap.NeighborhoodLeader,
this.roleRepository.roleMap.NeighborhoodDeputy,
this.roleRepository.roleMap.BlockLeader,
this.roleRepository.roleMap.BlockDeputy,
];
return !!roleAssignments.find(assignment => STAFF_ROLES.includes(assignment.role_id));
}

public async joinedPlace(id: number, placeId: number, is3d: number): Promise<void> {
const now = new Date();
await this.memberRepository.joinedPlace(id, {
Expand Down Expand Up @@ -189,7 +203,6 @@ export class MemberService {
lastName: member.lastname,
chatdefault: member.chatdefault,
primary_role_id: member.primary_role_id,
lastAccess: member.last_activity,
};
}

Expand All @@ -212,7 +225,6 @@ export class MemberService {
username: member.username,
xp: member.xp,
chatdefault: member.chatdefault,
lastAccess: member.last_activity,
};
}

Expand Down
3 changes: 0 additions & 3 deletions api/src/types/views/member-info.view.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export interface MemberInfoView {
primary_role_id?: number;
/**add chatdefault */
chatdefault?: number;
/**Last access */
lastAccess: Date;

}

export interface MemberAdminView {
Expand Down
3 changes: 2 additions & 1 deletion spa/src/components/place/home/main2d.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default Vue.extend({
return {
memberInfo: {},
canAdmin: false,
loaded: false,
};
},
Expand Down Expand Up @@ -154,7 +155,7 @@ export default Vue.extend({
watch: {
"$store.data.place.block": {
handler() {
if (this.$store.data.place.block) {
if (this.$route.params.username) {
this.loaded = true;
this.checkAdmin();
}
Expand Down

0 comments on commit b6ff2fe

Please sign in to comment.