feat: Implement privacy preferences for users and agents with new database field, service methods, and API endpoints.

This commit is contained in:
pradeepkumar
2026-02-09 00:55:55 +05:30
parent 6ade2c74c5
commit 789551e443
5 changed files with 191 additions and 0 deletions

View File

@@ -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;
}
}