-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist user's visible office setting
- Loading branch information
Showing
6 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app-nest/src/entities/user-settings/user-settings.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller } from "@nestjs/common"; | ||
import BoltAction from "../../bolt/decorators/bolt-action.decorator"; | ||
import BoltActions from "../../bolt/enums/bolt-actions.enum"; | ||
import { BoltActionArgs } from "../../bolt/types/bolt-action-types"; | ||
import { UserSettingsService } from "./user-settings.service"; | ||
|
||
@Controller() | ||
export class UserSettingsController { | ||
constructor(private userSettingsService: UserSettingsService) {} | ||
|
||
@BoltAction(BoltActions.SET_VISIBLE_OFFICE) | ||
async setVisibleOffice({ ack, payload, body }: BoltActionArgs) { | ||
await ack(); | ||
const visibleOfficeId = Number(payload["selected_option"].value); | ||
await this.userSettingsService.setVisibleOffice({ | ||
userSlackId: body.user.id, | ||
visibleOfficeId, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { OmitType, PickType } from "@nestjs/swagger"; | ||
import { UserSettings } from "./user-settings.entity"; | ||
|
||
export class UpsertUserSettingsDto extends OmitType(UserSettings, [ | ||
"visibleOffice", | ||
"user", | ||
]) {} | ||
|
||
export class SetVisibleOfficeDto extends PickType(UserSettings, [ | ||
"userSlackId", | ||
]) { | ||
visibleOfficeId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { TypeOrmModule } from "@nestjs/typeorm"; | ||
import { UserSettingsController } from "./user-settings.controller"; | ||
import { UserSettings } from "./user-settings.entity"; | ||
import { UserSettingsService } from "./user-settings.service"; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([UserSettings])], | ||
providers: [UserSettingsService], | ||
controllers: [UserSettingsController], | ||
exports: [TypeOrmModule, UserSettingsService], | ||
}) | ||
export class UserSettingsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters