change feature name and remove deleted accounts

This commit is contained in:
otsmr 2026-04-29 16:13:58 +02:00
parent c9b8e32d32
commit a015cb2cb8
9 changed files with 58 additions and 144 deletions

View file

@ -25,6 +25,7 @@ import 'package:twonly/src/services/mediafiles/mediafile.service.dart';
import 'package:twonly/src/services/notifications/fcm.notifications.dart'; import 'package:twonly/src/services/notifications/fcm.notifications.dart';
import 'package:twonly/src/services/notifications/setup.notifications.dart'; import 'package:twonly/src/services/notifications/setup.notifications.dart';
import 'package:twonly/src/services/user.service.dart'; import 'package:twonly/src/services/user.service.dart';
import 'package:twonly/src/services/user_discovery.service.dart';
import 'package:twonly/src/utils/avatars.dart'; import 'package:twonly/src/utils/avatars.dart';
import 'package:twonly/src/utils/log.dart'; import 'package:twonly/src/utils/log.dart';
import 'package:twonly/src/utils/secure_storage.dart'; import 'package:twonly/src/utils/secure_storage.dart';
@ -94,19 +95,19 @@ void main() async {
); );
} }
unawaited(performTwonlySafeBackup());
unawaited(initializeBackgroundTaskManager());
await runMigrations(); await runMigrations();
await twonlyDB.messagesDao.purgeMessageTable(); await twonlyDB.messagesDao.purgeMessageTable();
await twonlyDB.receiptsDao.purgeReceivedReceipts(); await twonlyDB.receiptsDao.purgeReceivedReceipts();
await UserDiscoveryService.removeDeletedContacts();
unawaited(MediaFileService.purgeTempFolder()); unawaited(MediaFileService.purgeTempFolder());
unawaited(setupPushNotification()); unawaited(setupPushNotification());
unawaited(finishStartedPreprocessing()); unawaited(finishStartedPreprocessing());
unawaited(createPushAvatars()); unawaited(createPushAvatars());
unawaited(performTwonlySafeBackup());
unawaited(initializeBackgroundTaskManager());
} }
await apiService.listenToNetworkChanges(); await apiService.listenToNetworkChanges();

View file

@ -136,8 +136,10 @@ class ContactsDao extends DatabaseAccessor<TwonlyDB> with _$ContactsDaoMixin {
Stream<List<Contact>> watchContactsAnnouncedViaUserDiscovery() { Stream<List<Contact>> watchContactsAnnouncedViaUserDiscovery() {
return (select(contacts)..where((t) { return (select(contacts)..where((t) {
var expr = t.userDiscoveryVersion.isNotNull() & var expr =
t.userDiscoveryVersion.isNotNull() &
t.userDiscoveryExcluded.equals(false) & t.userDiscoveryExcluded.equals(false) &
t.accountDeleted.equals(false) &
t.mediaSendCounter.isBiggerOrEqualValue( t.mediaSendCounter.isBiggerOrEqualValue(
userService.currentUser.requiredSendImages, userService.currentUser.requiredSendImages,
); );
@ -147,13 +149,16 @@ class ContactsDao extends DatabaseAccessor<TwonlyDB> with _$ContactsDaoMixin {
} }
return expr; return expr;
})).watch(); }))
.watch();
} }
Future<List<Contact>> getContactsAnnouncedViaUserDiscovery() async { Future<List<Contact>> getContactsAnnouncedViaUserDiscovery() async {
return (select(contacts)..where((t) { return (select(contacts)..where((t) {
var expr = t.userDiscoveryVersion.isNotNull() & var expr =
t.userDiscoveryVersion.isNotNull() &
t.userDiscoveryExcluded.equals(false) & t.userDiscoveryExcluded.equals(false) &
t.accountDeleted.equals(false) &
t.mediaSendCounter.isBiggerOrEqualValue( t.mediaSendCounter.isBiggerOrEqualValue(
userService.currentUser.requiredSendImages, userService.currentUser.requiredSendImages,
); );
@ -163,7 +168,8 @@ class ContactsDao extends DatabaseAccessor<TwonlyDB> with _$ContactsDaoMixin {
} }
return expr; return expr;
})).get(); }))
.get();
} }
Stream<List<Contact>> watchAllContacts() { Stream<List<Contact>> watchAllContacts() {

View file

@ -2390,12 +2390,6 @@ abstract class AppLocalizations {
/// **'Share your friends'** /// **'Share your friends'**
String get onboardingUserDiscoveryShareFriends; String get onboardingUserDiscoveryShareFriends;
/// No description provided for @onboardingUserDiscoveryIncreaseTrust.
///
/// In en, this message translates to:
/// **'Increase trust'**
String get onboardingUserDiscoveryIncreaseTrust;
/// No description provided for @onboardingUserDiscoveryShareFriendsDesc. /// No description provided for @onboardingUserDiscoveryShareFriendsDesc.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -2414,12 +2408,6 @@ abstract class AppLocalizations {
/// **'Be informed about who is requesting'** /// **'Be informed about who is requesting'**
String get onboardingUserDiscoveryWhoIsRequesting; String get onboardingUserDiscoveryWhoIsRequesting;
/// No description provided for @userDiscoverySettingsEnableAllContacts.
///
/// In en, this message translates to:
/// **'Enabled for all contacts'**
String get userDiscoverySettingsEnableAllContacts;
/// No description provided for @userDiscoverySettingsManualApproval. /// No description provided for @userDiscoverySettingsManualApproval.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -2438,12 +2426,6 @@ abstract class AppLocalizations {
/// **'Let your friends find you'** /// **'Let your friends find you'**
String get onboardingUserDiscoveryLetFriendsFindYou; String get onboardingUserDiscoveryLetFriendsFindYou;
/// No description provided for @onboardingUserDiscoveryLetFriendsFindYouDesc.
///
/// In en, this message translates to:
/// **'To help your friends find you, *you can be suggested* to people with whom you have *mutual friends*.'**
String get onboardingUserDiscoveryLetFriendsFindYouDesc;
/// No description provided for @onboardingUserDiscoveryBeRecommended. /// No description provided for @onboardingUserDiscoveryBeRecommended.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -2804,12 +2786,6 @@ abstract class AppLocalizations {
/// **'Accept'** /// **'Accept'**
String get contactActionAccept; String get contactActionAccept;
/// No description provided for @userDiscoverySettingsMinImages.
///
/// In en, this message translates to:
/// **'Choose the minimum number of images you must have send to a person before you securely share your friends with them.'**
String get userDiscoverySettingsMinImages;
/// No description provided for @userDiscoverySettingsMutualFriends. /// No description provided for @userDiscoverySettingsMutualFriends.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -2825,7 +2801,7 @@ abstract class AppLocalizations {
/// No description provided for @userDiscoveryEnabledDisableWarning. /// No description provided for @userDiscoveryEnabledDisableWarning.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'If you disable the \"Share your friends\" feature, you will no longer see suggestions. You will also stop sharing your friends with new contacts.'** /// **'If you disable the \"Mutual Friends\" feature, you will no longer see suggestions. You will also stop sharing your friends with new contacts.'**
String get userDiscoveryEnabledDisableWarning; String get userDiscoveryEnabledDisableWarning;
/// No description provided for @userDiscoveryEnabledChangeSettings. /// No description provided for @userDiscoveryEnabledChangeSettings.
@ -2837,7 +2813,7 @@ abstract class AppLocalizations {
/// No description provided for @userDiscoveryEnabledFaq. /// No description provided for @userDiscoveryEnabledFaq.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'In our FAQ we explain how the \"Share your friends\" feature works.'** /// **'In our FAQ we explain how the \"Mutual Friends\" feature works.'**
String get userDiscoveryEnabledFaq; String get userDiscoveryEnabledFaq;
/// No description provided for @userDiscoveryDisabledIntro. /// No description provided for @userDiscoveryDisabledIntro.
@ -2846,36 +2822,12 @@ abstract class AppLocalizations {
/// **'twonly does *not* collect your phone number or needs access to your contacts. Instead, twonly can *find your friends through mutual friends*.'** /// **'twonly does *not* collect your phone number or needs access to your contacts. Instead, twonly can *find your friends through mutual friends*.'**
String get userDiscoveryDisabledIntro; String get userDiscoveryDisabledIntro;
/// No description provided for @userDiscoveryDisabledDecide.
///
/// In en, this message translates to:
/// **'Decide for yourself who can see your friends. You can change your mind at *any time* or *hide specific people*.'**
String get userDiscoveryDisabledDecide;
/// No description provided for @userDiscoverySettingsTitle. /// No description provided for @userDiscoverySettingsTitle.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Share your friends'** /// **'Mutual Friends'**
String get userDiscoverySettingsTitle; String get userDiscoverySettingsTitle;
/// No description provided for @userDiscoverySettingsMinImagesTitle.
///
/// In en, this message translates to:
/// **'Number of images send'**
String get userDiscoverySettingsMinImagesTitle;
/// No description provided for @userDiscoverySettingsMutualFriendsTitle.
///
/// In en, this message translates to:
/// **'Number of mutual friends'**
String get userDiscoverySettingsMutualFriendsTitle;
/// No description provided for @userDiscoveryDisabledYouHaveControl.
///
/// In en, this message translates to:
/// **'You are in control'**
String get userDiscoveryDisabledYouHaveControl;
/// No description provided for @userDiscoveryDisabledLearnMore. /// No description provided for @userDiscoveryDisabledLearnMore.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
@ -2903,7 +2855,7 @@ abstract class AppLocalizations {
/// No description provided for @userDiscoverySettingsCurrentlyDisabled. /// No description provided for @userDiscoverySettingsCurrentlyDisabled.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'The feature \"Share your friends\" is currently disabled.'** /// **'The feature \"Mutual Friends\" is currently disabled.'**
String get userDiscoverySettingsCurrentlyDisabled; String get userDiscoverySettingsCurrentlyDisabled;
/// No description provided for @userDiscoveryEnabledNoFriendsShared. /// No description provided for @userDiscoveryEnabledNoFriendsShared.

View file

@ -1304,9 +1304,6 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get onboardingUserDiscoveryShareFriends => 'Freunde teilen'; String get onboardingUserDiscoveryShareFriends => 'Freunde teilen';
@override
String get onboardingUserDiscoveryIncreaseTrust => 'Erhöhe Vertrauen';
@override @override
String get onboardingUserDiscoveryShareFriendsDesc => String get onboardingUserDiscoveryShareFriendsDesc =>
'Teile deinen Freunden mit, wen du kennst und wen du verifiziert hast. Freunde können von deiner Freundesliste *nur gemeinsame Freunde sehen*.'; 'Teile deinen Freunden mit, wen du kennst und wen du verifiziert hast. Freunde können von deiner Freundesliste *nur gemeinsame Freunde sehen*.';
@ -1319,10 +1316,6 @@ class AppLocalizationsDe extends AppLocalizations {
String get onboardingUserDiscoveryWhoIsRequesting => String get onboardingUserDiscoveryWhoIsRequesting =>
'Erfahre, wer dich anfragt'; 'Erfahre, wer dich anfragt';
@override
String get userDiscoverySettingsEnableAllContacts =>
'Für alle Kontakte aktivieren';
@override @override
String get userDiscoverySettingsManualApproval => 'Manuelle Zustimmung'; String get userDiscoverySettingsManualApproval => 'Manuelle Zustimmung';
@ -1334,10 +1327,6 @@ class AppLocalizationsDe extends AppLocalizations {
String get onboardingUserDiscoveryLetFriendsFindYou => String get onboardingUserDiscoveryLetFriendsFindYou =>
'Lass dich von deinen Freunden finden'; 'Lass dich von deinen Freunden finden';
@override
String get onboardingUserDiscoveryLetFriendsFindYouDesc =>
'Damit deine Freunde dich finden können, kannst du Personen vorgeschlagen werden, die gemeinsame Freunde mit dir haben.';
@override @override
String get onboardingUserDiscoveryBeRecommended => String get onboardingUserDiscoveryBeRecommended =>
'Anderen vorgeschlagen werden'; 'Anderen vorgeschlagen werden';
@ -1568,10 +1557,6 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get contactActionAccept => 'Annehmen'; String get contactActionAccept => 'Annehmen';
@override
String get userDiscoverySettingsMinImages =>
'Wähle die Mindestanzahl an Bildern, die du an eine Person gesendet haben musst, bevor du ihr deine Freunde sicher teilst.';
@override @override
String get userDiscoverySettingsMutualFriends => String get userDiscoverySettingsMutualFriends =>
'Wähle aus, wie viele gemeinsame Freunde eine Person haben muss, damit du ihr vorgeschlagen wirst.'; 'Wähle aus, wie viele gemeinsame Freunde eine Person haben muss, damit du ihr vorgeschlagen wirst.';
@ -1581,36 +1566,21 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get userDiscoveryEnabledDisableWarning => String get userDiscoveryEnabledDisableWarning =>
'Wenn du das Feature „Freunde teilen“ deaktivierst, werden dir keine Vorschläge mehr angezeigt. Du teilst neuen Kontakten dann auch nicht mehr deine Freunde.'; 'Wenn du das Feature „Gemeinsame Freunde“ deaktivierst, werden dir keine Vorschläge mehr angezeigt. Du teilst neuen Kontakten dann auch nicht mehr deine Freunde.';
@override @override
String get userDiscoveryEnabledChangeSettings => 'Einstellungen ändern'; String get userDiscoveryEnabledChangeSettings => 'Einstellungen ändern';
@override @override
String get userDiscoveryEnabledFaq => String get userDiscoveryEnabledFaq =>
'In unserem FAQ erklären wir dir wie das Feature \"Freunde teilen\" funktioniert.'; 'In unserem FAQ erklären wir dir wie das Feature \"Gemeinsame Freunde\" funktioniert.';
@override @override
String get userDiscoveryDisabledIntro => String get userDiscoveryDisabledIntro =>
'twonly kann *ohne Telefonnummer* oder den Zugriff auf dein Adressbuch verwendet werden. Stattdessen kannst du *deine Freunde über gemeinsame Freunde* finden.'; 'twonly kann *ohne Telefonnummer* oder den Zugriff auf dein Adressbuch verwendet werden. Stattdessen kannst du *deine Freunde über gemeinsame Freunde* finden.';
@override @override
String get userDiscoveryDisabledDecide => String get userDiscoverySettingsTitle => 'Gemeinsame Freunde';
'Entscheide selbst, wer deine Freunde sehen darf. Du kannst deine Meinung *jederzeit ändern* oder *bestimmte Personen verstecken*.';
@override
String get userDiscoverySettingsTitle => 'Freunde teilen';
@override
String get userDiscoverySettingsMinImagesTitle =>
'Anzahl an gesendeten Bildern';
@override
String get userDiscoverySettingsMutualFriendsTitle =>
'Anzahl an gemeinsame Freunde';
@override
String get userDiscoveryDisabledYouHaveControl => 'Du hast die Kontrolle';
@override @override
String get userDiscoveryDisabledLearnMore => 'Mehr erfahren'; String get userDiscoveryDisabledLearnMore => 'Mehr erfahren';
@ -1627,7 +1597,7 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get userDiscoverySettingsCurrentlyDisabled => String get userDiscoverySettingsCurrentlyDisabled =>
'Das Feature \"Freunde teilen\" ist derzeit deaktiviert.'; 'Das Feature \"Gemeinsame Freunde\" ist derzeit deaktiviert.';
@override @override
String get userDiscoveryEnabledNoFriendsShared => String get userDiscoveryEnabledNoFriendsShared =>

View file

@ -1295,9 +1295,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get onboardingUserDiscoveryShareFriends => 'Share your friends'; String get onboardingUserDiscoveryShareFriends => 'Share your friends';
@override
String get onboardingUserDiscoveryIncreaseTrust => 'Increase trust';
@override @override
String get onboardingUserDiscoveryShareFriendsDesc => String get onboardingUserDiscoveryShareFriendsDesc =>
'Share with your friends who you know and who you have verified. Friends can *only see mutual friends* from your friend list. You can change your mind at *any time* or *hide specific people*.'; 'Share with your friends who you know and who you have verified. Friends can *only see mutual friends* from your friend list. You can change your mind at *any time* or *hide specific people*.';
@ -1310,10 +1307,6 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingUserDiscoveryWhoIsRequesting => String get onboardingUserDiscoveryWhoIsRequesting =>
'Be informed about who is requesting'; 'Be informed about who is requesting';
@override
String get userDiscoverySettingsEnableAllContacts =>
'Enabled for all contacts';
@override @override
String get userDiscoverySettingsManualApproval => 'Manual approval'; String get userDiscoverySettingsManualApproval => 'Manual approval';
@ -1325,10 +1318,6 @@ class AppLocalizationsEn extends AppLocalizations {
String get onboardingUserDiscoveryLetFriendsFindYou => String get onboardingUserDiscoveryLetFriendsFindYou =>
'Let your friends find you'; 'Let your friends find you';
@override
String get onboardingUserDiscoveryLetFriendsFindYouDesc =>
'To help your friends find you, *you can be suggested* to people with whom you have *mutual friends*.';
@override @override
String get onboardingUserDiscoveryBeRecommended => 'Be recommended to others'; String get onboardingUserDiscoveryBeRecommended => 'Be recommended to others';
@ -1553,10 +1542,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get contactActionAccept => 'Accept'; String get contactActionAccept => 'Accept';
@override
String get userDiscoverySettingsMinImages =>
'Choose the minimum number of images you must have send to a person before you securely share your friends with them.';
@override @override
String get userDiscoverySettingsMutualFriends => String get userDiscoverySettingsMutualFriends =>
'Choose how many mutual friends a person must have for you to be suggested to them.'; 'Choose how many mutual friends a person must have for you to be suggested to them.';
@ -1566,35 +1551,21 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get userDiscoveryEnabledDisableWarning => String get userDiscoveryEnabledDisableWarning =>
'If you disable the \"Share your friends\" feature, you will no longer see suggestions. You will also stop sharing your friends with new contacts.'; 'If you disable the \"Mutual Friends\" feature, you will no longer see suggestions. You will also stop sharing your friends with new contacts.';
@override @override
String get userDiscoveryEnabledChangeSettings => 'Change settings'; String get userDiscoveryEnabledChangeSettings => 'Change settings';
@override @override
String get userDiscoveryEnabledFaq => String get userDiscoveryEnabledFaq =>
'In our FAQ we explain how the \"Share your friends\" feature works.'; 'In our FAQ we explain how the \"Mutual Friends\" feature works.';
@override @override
String get userDiscoveryDisabledIntro => String get userDiscoveryDisabledIntro =>
'twonly does *not* collect your phone number or needs access to your contacts. Instead, twonly can *find your friends through mutual friends*.'; 'twonly does *not* collect your phone number or needs access to your contacts. Instead, twonly can *find your friends through mutual friends*.';
@override @override
String get userDiscoveryDisabledDecide => String get userDiscoverySettingsTitle => 'Mutual Friends';
'Decide for yourself who can see your friends. You can change your mind at *any time* or *hide specific people*.';
@override
String get userDiscoverySettingsTitle => 'Share your friends';
@override
String get userDiscoverySettingsMinImagesTitle => 'Number of images send';
@override
String get userDiscoverySettingsMutualFriendsTitle =>
'Number of mutual friends';
@override
String get userDiscoveryDisabledYouHaveControl => 'You are in control';
@override @override
String get userDiscoveryDisabledLearnMore => 'Learn more'; String get userDiscoveryDisabledLearnMore => 'Learn more';
@ -1611,7 +1582,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get userDiscoverySettingsCurrentlyDisabled => String get userDiscoverySettingsCurrentlyDisabled =>
'The feature \"Share your friends\" is currently disabled.'; 'The feature \"Mutual Friends\" is currently disabled.';
@override @override
String get userDiscoveryEnabledNoFriendsShared => String get userDiscoveryEnabledNoFriendsShared =>

@ -1 +1 @@
Subproject commit 96fc996e06f96a7a26438bba0421cb26eb721427 Subproject commit b556f4b332d9df274ff07c606d4db3ab0353cc9a

View file

@ -172,6 +172,18 @@ class UserDiscoveryService {
} }
} }
static Future<void> removeDeletedContacts() async {
final subquery = twonlyDB.selectOnly(twonlyDB.contacts)
..addColumns([twonlyDB.contacts.userId])
..where(twonlyDB.contacts.accountDeleted.equals(true));
await (twonlyDB.update(
twonlyDB.userDiscoveryOwnPromotions,
)..where((t) => t.contactId.isInQuery(subquery))).write(
UserDiscoveryOwnPromotionsCompanion(promotion: Value(Uint8List(0))),
);
}
static Future<void> changeExclusionForContact( static Future<void> changeExclusionForContact(
int contactId, int contactId,
bool exclude, bool exclude,

View file

@ -20,6 +20,7 @@ import 'package:twonly/src/visual/components/verification_badge.comp.dart';
import 'package:twonly/src/visual/elements/better_list_title.element.dart'; import 'package:twonly/src/visual/elements/better_list_title.element.dart';
import 'package:twonly/src/visual/views/contact/contact_components/restore_flame.comp.dart'; import 'package:twonly/src/visual/views/contact/contact_components/restore_flame.comp.dart';
import 'package:twonly/src/visual/views/groups/group.view.dart'; import 'package:twonly/src/visual/views/groups/group.view.dart';
import 'package:twonly/src/visual/views/settings/privacy/user_discovery.view.dart';
class ContactView extends StatefulWidget { class ContactView extends StatefulWidget {
const ContactView(this.userId, {super.key}); const ContactView(this.userId, {super.key});
@ -337,6 +338,7 @@ class _ContactViewState extends State<ContactView> {
BetterListTile( BetterListTile(
icon: FontAwesomeIcons.usersViewfinder, icon: FontAwesomeIcons.usersViewfinder,
text: context.lang.userDiscoverySettingsTitle, text: context.lang.userDiscoverySettingsTitle,
onTap: () => context.navPush(const UserDiscoverySettingsView()),
subtitle: subtitle:
!contact.userDiscoveryExcluded && !contact.userDiscoveryExcluded &&
contact.mediaSendCounter < contact.mediaSendCounter <

View file

@ -158,7 +158,7 @@ class _UserDiscoveryEnabledCompState extends State<UserDiscoveryEnabledComp> {
context.lang.userDiscoveryEnabledFaq, context.lang.userDiscoveryEnabledFaq,
), ),
onTap: () => context.navPush( onTap: () => context.navPush(
const FaqView(questionId: 'user-discovery'), const FaqView(questionId: 'mutual-friends'),
), ),
), ),
const Divider(), const Divider(),