Partially Redact Contact Onions where Nicks are unavailable. Upgrade Cwtch
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Sarah Jamie Lewis 2023-09-25 12:05:28 -07:00
parent 526b0fffaa
commit 224642e00d
10 changed files with 31 additions and 9 deletions

View File

@ -1 +1 @@
2023-09-24-09-56-v0.0.8-1-gb80db89
2023-09-25-18-37-v0.0.9

View File

@ -3,6 +3,7 @@ import 'dart:ffi';
import 'package:cwtch/main.dart';
import 'package:cwtch/models/message_draft.dart';
import 'package:cwtch/models/profile.dart';
import 'package:cwtch/models/redaction.dart';
import 'package:cwtch/themes/opaque.dart';
import 'package:cwtch/views/contactsview.dart';
import 'package:cwtch/widgets/messagerow.dart';
@ -440,7 +441,8 @@ class ContactInfoState extends ChangeNotifier {
}
String augmentedNickname(BuildContext context) {
return this.nickname + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" + this.statusString(context) + ")");
var nick = redactedNick(context, this.onion, this.nickname);
return nick + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" + this.statusString(context) + ")");
}
// Never use this for message lookup - can be a non-indexed value

View File

@ -6,6 +6,16 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../settings.dart';
import 'package:intl/intl.dart';
String redactedNick(BuildContext context, String handle, String nick) {
var settings = Provider.of<Settings>(context, listen: false);
if (settings.streamerMode) {
if (handle == nick) {
return handle.substring(0, 7) + "...";
}
}
return nick;
}
String prettyDateString(BuildContext context, DateTime date) {
var settings = Provider.of<Settings>(context, listen: false);
if (settings.streamerMode) {

View File

@ -20,6 +20,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../config.dart';
import '../main.dart';
import '../models/message.dart';
import '../models/redaction.dart';
import '../settings.dart';
import '../themes/opaque.dart';
import 'addcontactview.dart';
@ -337,7 +338,10 @@ class _ContactsViewState extends State<ContactsView> {
width: 10,
),
Expanded(
child: Text("%1 » %2".replaceAll("%1", Provider.of<ProfileInfoState>(context).nickname).replaceAll("%2", AppLocalizations.of(context)!.titleManageContacts),
child: Text(
"%1 » %2"
.replaceAll("%1", redactedNick(context, Provider.of<ProfileInfoState>(context).onion, Provider.of<ProfileInfoState>(context).nickname))
.replaceAll("%2", AppLocalizations.of(context)!.titleManageContacts),
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Provider.of<Settings>(context).current().mainTextColor,

View File

@ -18,6 +18,7 @@ import '../main.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../models/redaction.dart';
import '../settings.dart';
import 'messagebubbledecorations.dart';
@ -126,7 +127,7 @@ class FileBubbleState extends State<FileBubble> {
if (!fromMe) {
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
senderIsContact = true;
} else {
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;

View File

@ -13,6 +13,7 @@ import '../main.dart';
import 'package:intl/intl.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../models/redaction.dart';
import '../settings.dart';
import 'messageBubbleWidgetHelpers.dart';
import 'messagebubbledecorations.dart';
@ -50,7 +51,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
if (!fromMe) {
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
} else {
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
}

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:cwtch/controllers/open_link_modal.dart';
import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/message.dart';
import 'package:cwtch/models/redaction.dart';
import 'package:cwtch/themes/opaque.dart';
import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
import 'package:cwtch/models/profile.dart';
@ -39,7 +40,7 @@ class MessageBubbleState extends State<MessageBubble> {
if (!fromMe) {
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
} else {
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
}

View File

@ -20,6 +20,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../main.dart';
import '../models/messagecache.dart';
import '../models/redaction.dart';
import '../settings.dart';
class MessageRow extends StatefulWidget {
@ -73,7 +74,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
if (!fromMe) {
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
} else {
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
}

View File

@ -9,6 +9,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../models/redaction.dart';
import '../settings.dart';
import 'messageBubbleWidgetHelpers.dart';
import 'messagebubbledecorations.dart';
@ -38,7 +39,7 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
if (!fromMe) {
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
} else {
senderDisplayStr = Provider.of<MessageMetadata>(context).senderHandle;
}

View File

@ -5,6 +5,7 @@ import 'package:cwtch/widgets/malformedbubble.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../models/redaction.dart';
import '../settings.dart';
import 'messageBubbleWidgetHelpers.dart';
import 'messagebubbledecorations.dart';
@ -33,7 +34,7 @@ class StaticMessageBubbleState extends State<StaticMessageBubble> {
if (!fromMe) {
ContactInfoState? contact = widget.profile.contactList.findContact(widget.metadata.senderHandle);
if (contact != null) {
senderDisplayStr = contact.nickname;
senderDisplayStr = redactedNick(context, contact.onion, contact.nickname);
} else {
senderDisplayStr = widget.metadata.senderHandle;
}