Compare commits

...

3 Commits

Author SHA1 Message Date
60e689cca0 patch privacy settings 2025-10-08 03:16:34 +03:00
28ae309042 change names 2025-10-08 03:10:24 +03:00
dd5680742c patch editprivacy 2025-10-08 02:56:35 +03:00
4 changed files with 53 additions and 28 deletions

View File

@ -142,8 +142,17 @@ struct ProfilePermissionsRequestPayload: Encodable {
try container.encode(groupInvitePermission, forKey: .groupInvitePermission) try container.encode(groupInvitePermission, forKey: .groupInvitePermission)
try container.encode(callPermission, forKey: .callPermission) try container.encode(callPermission, forKey: .callPermission)
try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate) try container.encode(forceAutoDeleteMessagesInPrivate, forKey: .forceAutoDeleteMessagesInPrivate)
try container.encodeIfPresent(maxMessageAutoDeleteSeconds, forKey: .maxMessageAutoDeleteSeconds) if let seconds = maxMessageAutoDeleteSeconds {
try container.encodeIfPresent(autoDeleteAfterDays, forKey: .autoDeleteAfterDays) try container.encode(seconds, forKey: .maxMessageAutoDeleteSeconds)
} else {
try container.encodeNil(forKey: .maxMessageAutoDeleteSeconds)
}
if let days = autoDeleteAfterDays {
try container.encode(days, forKey: .autoDeleteAfterDays)
} else {
try container.encodeNil(forKey: .autoDeleteAfterDays)
}
} }
} }

View File

@ -76,8 +76,6 @@ final class ProfileService {
func updateProfile(_ payload: ProfileUpdateRequestPayload, completion: @escaping (Result<String, Error>) -> Void) { func updateProfile(_ payload: ProfileUpdateRequestPayload, completion: @escaping (Result<String, Error>) -> Void) {
let encoder = JSONEncoder() let encoder = JSONEncoder()
encoder.keyEncodingStrategy = .convertToSnakeCase encoder.keyEncodingStrategy = .convertToSnakeCase
print("payload \(payload)")
guard let body = try? encoder.encode(payload) else { guard let body = try? encoder.encode(payload) else {
let message = NSLocalizedString("Не удалось подготовить данные запроса.", comment: "Profile update encoding error") let message = NSLocalizedString("Не удалось подготовить данные запроса.", comment: "Profile update encoding error")
@ -85,6 +83,12 @@ final class ProfileService {
return return
} }
if let jsonString = String(data: body, encoding: .utf8) {
print("📤 Request Body JSON:\n\(jsonString)")
} else {
print("⚠️ Не удалось преобразовать тело запроса в строку")
}
client.request( client.request(
path: "/v1/profile/edit", path: "/v1/profile/edit",
method: .put, method: .put,

View File

@ -518,6 +518,9 @@
}, },
"Локальные чаты" : { "Локальные чаты" : {
"comment" : "Local search section" "comment" : "Local search section"
},
"Максимальное время автоудаления: %@" : {
}, },
"Мини-приложения" : { "Мини-приложения" : {
"comment" : "Applets", "comment" : "Applets",
@ -826,6 +829,9 @@
}, },
"Обратная связь" : { "Обратная связь" : {
},
"Ограничить таймер автоудаления (максимум)" : {
}, },
"Описание" : { "Описание" : {
@ -1071,6 +1077,9 @@
}, },
"Попробуйте изменить запрос поиска." : { "Попробуйте изменить запрос поиска." : {
},
"Приватные чаты" : {
}, },
"Приглашение достигло лимита использования." : { "Приглашение достигло лимита использования." : {
"localizations" : { "localizations" : {
@ -1121,7 +1130,7 @@
"Принимать сообщения от незнакомцев" : { "Принимать сообщения от незнакомцев" : {
}, },
"Принудительное автоудаление в ЛС (Приватный)" : { "Принудительное включение автоудаления сообщений" : {
}, },
"Проверьте данные и повторите попытку." : { "Проверьте данные и повторите попытку." : {
@ -1172,7 +1181,7 @@
"Разрешить поиск профиля" : { "Разрешить поиск профиля" : {
}, },
"Разрешить хранить чаты на сервере (Обычный)" : { "Разрешить хранить чаты на сервере" : {
}, },
"Регистрация" : { "Регистрация" : {
@ -1368,9 +1377,6 @@
} }
} }
} }
},
"Таймер автоудаления: %@" : {
}, },
"Тёмная" : { "Тёмная" : {
"localizations" : { "localizations" : {

View File

@ -11,13 +11,6 @@ struct EditPrivacyView: View {
private var privacyScopeOptions: [PrivacyScope] { PrivacyScope.allCases } private var privacyScopeOptions: [PrivacyScope] { PrivacyScope.allCases }
private var forceAutoDeleteBinding: Binding<Int> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds ?? 30 },
set: { profilePermissions.maxMessageAutoDeleteSeconds = $0 }
)
}
private var autoDeleteAccountEnabled: Binding<Bool> { private var autoDeleteAccountEnabled: Binding<Bool> {
Binding( Binding(
get: { profilePermissions.autoDeleteAfterDays != nil }, get: { profilePermissions.autoDeleteAfterDays != nil },
@ -34,6 +27,22 @@ struct EditPrivacyView: View {
) )
} }
private var autoDeleteTimerEnabled: Binding<Bool> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds != nil },
set: { newValue in
profilePermissions.maxMessageAutoDeleteSeconds = newValue ? (profilePermissions.maxMessageAutoDeleteSeconds ?? 30) : nil
}
)
}
private var autoDeleteTimerBinding: Binding<Int> {
Binding(
get: { profilePermissions.maxMessageAutoDeleteSeconds ?? 30 },
set: { profilePermissions.maxMessageAutoDeleteSeconds = min(max($0, 5), 86400) }
)
}
var body: some View { var body: some View {
Form { Form {
if isLoading { if isLoading {
@ -93,12 +102,16 @@ struct EditPrivacyView: View {
} }
Section(header: Text("Чаты и хранение")) { Section(header: Text("Чаты и хранение")) {
Toggle("Разрешить хранить чаты на сервере (Обычный)", isOn: $profilePermissions.allowServerChats) Toggle("Разрешить хранить чаты на сервере", isOn: $profilePermissions.allowServerChats)
Toggle("Принудительное автоудаление в ЛС (Приватный)", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate) }
Section(header: Text("Приватные чаты")) {
Toggle("Принудительное включение автоудаления сообщений", isOn: $profilePermissions.forceAutoDeleteMessagesInPrivate)
Toggle("Ограничить таймер автоудаления (максимум)", isOn: autoDeleteTimerEnabled)
if profilePermissions.forceAutoDeleteMessagesInPrivate { if autoDeleteTimerEnabled.wrappedValue {
Stepper(value: forceAutoDeleteBinding, in: 5...86400, step: 5) { Stepper(value: autoDeleteTimerBinding, in: 5...86400, step: 5) {
Text("Таймер автоудаления: \(formattedAutoDeleteSeconds(forceAutoDeleteBinding.wrappedValue))") Text("Максимальное время автоудаления: \(formattedAutoDeleteSeconds(autoDeleteTimerBinding.wrappedValue))")
} }
} }
} }
@ -153,13 +166,6 @@ struct EditPrivacyView: View {
) )
} }
.navigationTitle("Настройки приватности") .navigationTitle("Настройки приватности")
.onChange(of: profilePermissions.forceAutoDeleteMessagesInPrivate) { newValue in
if newValue {
profilePermissions.maxMessageAutoDeleteSeconds = profilePermissions.maxMessageAutoDeleteSeconds ?? 30
} else {
profilePermissions.maxMessageAutoDeleteSeconds = nil
}
}
.task { .task {
await loadProfile() await loadProfile()
} }