feat: Implement privacy preferences for users and agents with new database field, service methods, and API endpoints.
This commit is contained in:
@@ -441,4 +441,48 @@ export class UsersService {
|
||||
|
||||
return updatedUser.notificationPreferences;
|
||||
}
|
||||
|
||||
// =============================================
|
||||
// PRIVACY PREFERENCES
|
||||
// =============================================
|
||||
|
||||
async getPrivacyPreferences(userId: string) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { privacyPreferences: true },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException('User not found');
|
||||
}
|
||||
|
||||
// Return preferences or default empty object
|
||||
return user.privacyPreferences || { privacySettings: {}, dataSettings: {} };
|
||||
}
|
||||
|
||||
async updatePrivacyPreferences(
|
||||
userId: string,
|
||||
preferences: {
|
||||
privacySettings?: Record<string, string>;
|
||||
dataSettings?: Record<string, boolean>;
|
||||
},
|
||||
) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException('User not found');
|
||||
}
|
||||
|
||||
const updatedUser = await this.prisma.user.update({
|
||||
where: { id: userId },
|
||||
data: {
|
||||
privacyPreferences: preferences,
|
||||
},
|
||||
select: { privacyPreferences: true },
|
||||
});
|
||||
|
||||
return updatedUser.privacyPreferences;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user