Skip to content

WIP: Notify user when DMing a guest #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/icons/ZulipIcons.ttf
Binary file not shown.
3 changes: 3 additions & 0 deletions assets/icons/remove.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,21 @@
"others": {"type": "String", "example": "Alice, Bob"}
}
},
"guestUserDmWarningOne": "{guestUser} is a guest in this organization.",
"@guestUserDmWarningOne": {
"description": "Warning shown when composing a DM to one guest user",
"placeholders": {
"guestUser": {"type": "String", "example": "Alice"}
}
},

"guestUserDmWarningMany": "{guestUsers} are guests in this organization.",
"@guestUserDmWarningMany": {
"description": "Warning shown when composing DMs to multiple guest users",
"placeholders": {
"guestUsers": {"type": "String", "example": "Alice, Bob, and Charlie"}
}
},
"messageListGroupYouWithYourself": "Messages with yourself",
"@messageListGroupYouWithYourself": {
"description": "Message list recipient header for a DM group that only includes yourself."
Expand Down
45 changes: 45 additions & 0 deletions lib/api/model/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ sealed class Event {
case 'submessage': return SubmessageEvent.fromJson(json);
case 'typing': return TypingEvent.fromJson(json);
case 'reaction': return ReactionEvent.fromJson(json);
case 'realm':
switch(json['op'] as String){
case 'update': return RealmUpdateEvent.fromJson(json);
default: return UnexpectedEvent.fromJson(json);
}
case 'heartbeat': return HeartbeatEvent.fromJson(json);
// TODO add many more event types
default: return UnexpectedEvent.fromJson(json);
Expand Down Expand Up @@ -1151,6 +1156,46 @@ enum ReactionOp {
remove,
}

/// A Zulip event of type `realm`, with op `update`.
///
/// This is the simpler of two possible event types sent when realm configuration changes.
/// It updates a single realm setting at a time.
///
/// See: https://zulip.com/api/get-events#realm-update
@JsonSerializable(fieldRename: FieldRename.snake)
class RealmUpdateEvent extends Event {
@override
@JsonKey(includeToJson: true)
String get type => 'realm';

@JsonKey(includeToJson: true)
String get op => 'update';

@JsonKey(unknownEnumValue: JsonKey.nullForUndefinedEnumValue)
final RealmPropertyName? property;

final dynamic value;

RealmUpdateEvent({
required super.id,
required this.property,
required this.value,
});

factory RealmUpdateEvent.fromJson(Map<String, dynamic> json) =>
_$RealmUpdateEventFromJson(json);

@override
Map<String, dynamic> toJson() => _$RealmUpdateEventToJson(this);
}

/// As in [RealmUpdateEvent.property].
@JsonEnum(fieldRename: FieldRename.snake)
enum RealmPropertyName {
@JsonValue('enable_guest_user_dm_warning')
realmEnableGuestUserDmWarning,
}

/// A Zulip event of type `heartbeat`: https://zulip.com/api/get-events#heartbeat
@JsonSerializable(fieldRename: FieldRename.snake)
class HeartbeatEvent extends Event {
Expand Down
25 changes: 25 additions & 0 deletions lib/api/model/events.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/api/model/initial_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class InitialSnapshot {

final int maxFileUploadSizeMib;

@JsonKey(defaultValue: false) // TODO(server-10): Remove default
final bool realmEnableGuestUserDmWarning;

final Uri? serverEmojiDataUrl; // TODO(server-6)

final String? realmEmptyTopicDisplayName; // TODO(server-10)
Expand Down Expand Up @@ -144,6 +147,7 @@ class InitialSnapshot {
required this.realmMessageContentEditLimitSeconds,
required this.realmDefaultExternalAccounts,
required this.maxFileUploadSizeMib,
required this.realmEnableGuestUserDmWarning,
required this.serverEmojiDataUrl,
required this.realmEmptyTopicDisplayName,
required this.realmUsers,
Expand Down
80 changes: 42 additions & 38 deletions lib/api/model/initial_snapshot.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,18 @@ abstract class ZulipLocalizations {
/// **'DMs with {others}'**
String dmsWithOthersPageTitle(String others);

/// Warning shown when composing a DM to one guest user
///
/// In en, this message translates to:
/// **'{guestUser} is a guest in this organization.'**
String guestUserDmWarningOne(String guestUser);

/// Warning shown when composing DMs to multiple guest users
///
/// In en, this message translates to:
/// **'{guestUsers} are guests in this organization.'**
String guestUserDmWarningMany(String guestUsers);

/// Message list recipient header for a DM group that only includes yourself.
///
/// In en, this message translates to:
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
return 'DMs with $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Messages with yourself';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
return 'DMs with $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Messages with yourself';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
return 'DMs with $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Messages with yourself';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_nb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
return 'DMs with $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Messages with yourself';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
return 'DM z $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Zapiski na własne konto';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
return 'ЛС с $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Сообщения с собой';

Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n/zulip_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
return 'DMs with $others';
}

@override
String guestUserDmWarningOne(String guestUser) {
return '$guestUser is a guest in this organization.';
}

@override
String guestUserDmWarningMany(String guestUsers) {
return '$guestUsers are guests in this organization.';
}

@override
String get messageListGroupYouWithYourself => 'Messages with yourself';

Expand Down
Loading
Loading