Skip to content

Commit f08e2e4

Browse files
committed
chore(fc): update protos; update domain layer and modeling
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 51cb85b commit f08e2e4

File tree

44 files changed

+582
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+582
-73
lines changed

definitions/flipchat/protos/src/main/proto/chat/v1/chat_service.proto

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ service Chat {
4444
// then a set of alternate suggestions may be provided
4545
rpc SetDisplayName(SetDisplayNameRequest) returns (SetDisplayNameResponse);
4646
// SetCoverCharge sets a chat's cover charge
47+
//
48+
// Deprecated: Use SetMessagingFee instead
4749
rpc SetCoverCharge(SetCoverChargeRequest) returns (SetCoverChargeResponse);
50+
// SetMessagingFee sets a chat's messaging fee
51+
rpc SetMessagingFee(SetMessagingFeeRequest) returns (SetMessagingFeeResponse);
4852
// GetMemberUpdates gets member updates for a given chat
4953
rpc GetMemberUpdates(GetMemberUpdatesRequest) returns (GetMemberUpdatesResponse);
54+
// PromoteUser promotes a user to an elevated permission state
55+
rpc PromoteUser(PromoteUserRequest) returns (PromoteUserResponse);
56+
// DemoteUser demotes a user to a lower permission state
57+
rpc DemoteUser(DemoteUserRequest) returns (DemoteUserResponse);
5058
// RemoveUser removes a user from a chat
5159
rpc RemoveUser(RemoveUserRequest) returns (RemoveUserResponse);
5260
// MuteUser mutes a user in the chat and removes their ability to send messages
@@ -294,6 +302,19 @@ message SetCoverChargeResponse {
294302
CANT_SET = 2;
295303
}
296304
}
305+
message SetMessagingFeeRequest {
306+
common.v1.ChatId chat_id = 1;
307+
common.v1.PaymentAmount messaging_fee = 2;
308+
common.v1.Auth auth = 3;
309+
}
310+
message SetMessagingFeeResponse {
311+
Result result = 1;
312+
enum Result {
313+
OK = 0;
314+
DENIED = 1;
315+
CANT_SET = 2;
316+
}
317+
}
297318
message GetMemberUpdatesRequest {
298319
common.v1.ChatId chat_id = 1;
299320
// If not provided, a full refresh is performed. Server may also choose
@@ -311,6 +332,34 @@ message GetMemberUpdatesResponse {
311332
}
312333
repeated MemberUpdate updates = 2 ;
313334
}
335+
message PromoteUserRequest {
336+
common.v1.ChatId chat_id = 1;
337+
common.v1.UserId user_id = 2;
338+
// Enables send permissions when value is true
339+
bool enable_send_permission = 3;
340+
common.v1.Auth auth = 100;
341+
}
342+
message PromoteUserResponse {
343+
Result result = 1;
344+
enum Result {
345+
OK = 0;
346+
DENIED = 1;
347+
}
348+
}
349+
message DemoteUserRequest {
350+
common.v1.ChatId chat_id = 1;
351+
common.v1.UserId user_id = 2;
352+
// Disables send permissions when value is true
353+
bool disable_send_permission = 3;
354+
common.v1.Auth auth = 100;
355+
}
356+
message DemoteUserResponse {
357+
Result result = 1;
358+
enum Result {
359+
OK = 0;
360+
DENIED = 1;
361+
}
362+
}
314363
message RemoveUserRequest{
315364
common.v1.ChatId chat_id = 1;
316365
common.v1.UserId user_id = 2;
@@ -395,8 +444,11 @@ message Metadata {
395444
// This is a super priviledge role, in which there can only be one.
396445
// This role is displayed as a 'host' currently.
397446
common.v1.UserId owner = 8;
398-
// If present, the cover charge that must be paid to join the chat
399-
common.v1.PaymentAmount cover_charge = 9;
447+
// If present, the fee that must be paid to send a message as a non-regular
448+
// chat member.
449+
//
450+
// This replaces the legacy cover charge mechanic, which is deprecated
451+
common.v1.PaymentAmount messaging_fee = 9;
400452
// The timestamp of the last activity in this chat
401453
google.protobuf.Timestamp last_activity = 10;
402454
// The status as to whether the room is open or closed. This may be
@@ -416,7 +468,7 @@ message MetadataUpdate {
416468
FullRefresh full_refresh = 1;
417469
UnreadCountChanged unread_count_changed = 2;
418470
DisplayNameChanged display_name_changed = 3;
419-
CoverChargeChanged cover_charge_changed = 4;
471+
MessagingFeeChanged messaging_fee_changed = 4;
420472
LastActivityChanged last_activity_changed = 5;
421473
OpenStatusChanged open_status_changed = 6;
422474
}
@@ -436,9 +488,9 @@ message MetadataUpdate {
436488
message DisplayNameChanged {
437489
string new_display_name = 1 ;
438490
}
439-
// The chat cover charge has been updated to a new value
440-
message CoverChargeChanged {
441-
common.v1.PaymentAmount new_cover_charge = 1;
491+
// The chat messaging fee has been updated to a new value
492+
message MessagingFeeChanged {
493+
common.v1.PaymentAmount new_messaging_fee = 1;
442494
}
443495
// The last activity timestamp has changed to a newer value
444496
message LastActivityChanged {
@@ -473,7 +525,8 @@ message Member {
473525
// messages, even if they paid for the permission.
474526
bool is_muted = 6;
475527
// Does the chat member have permission to send messages in the chat? If
476-
// not, the user is considered to be a spectator.
528+
// not, the user is considered to be a spectator or listener. Otherwise,
529+
// they are a speaker.
477530
bool has_send_permission = 7;
478531
}
479532
message MemberIdentity {
@@ -490,6 +543,8 @@ message MemberUpdate {
490543
Left left = 4;
491544
Removed removed = 5;
492545
Muted muted = 6;
546+
Promoted promoted = 7;
547+
Demoted demoted = 8;
493548
}
494549
common.v1.PagingToken paging_token = 1000;
495550
// Refreshes the state of the entire chat membership
@@ -518,4 +573,16 @@ message MemberUpdate {
518573
common.v1.UserId member = 1;
519574
common.v1.UserId muted_by = 2;
520575
}
576+
// Member was promoted in the chat via the PromoteUser RPC
577+
message Promoted {
578+
common.v1.UserId member = 1;
579+
common.v1.UserId promoted_by = 2;
580+
bool send_permission_enabled = 3;
581+
}
582+
// Member was demoted in the chat via the DemoteUser RPC
583+
message Demoted {
584+
common.v1.UserId member = 1;
585+
common.v1.UserId demoted_by = 2;
586+
bool send_permission_disabled = 3;
587+
}
521588
}

definitions/flipchat/protos/src/main/proto/messaging/v1/messaging_service.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ message SendMessageRequest {
8989
// - ReplyContent
9090
// - TipContent
9191
// - DeleteMessageContent
92+
// - ReviewContent
9293
repeated Content content = 2 ;
9394
common.v1.Auth auth = 3;
9495
// Intent ID for message contents that require a payment
@@ -104,6 +105,12 @@ message SendMessageResponse {
104105
// server-side metadata like the generated message ID and official timestamp
105106
Message message = 2;
106107
}
108+
message SendMessageAsListenerPaymentMetadata {
109+
// The chat where the message is being sent
110+
common.v1.ChatId chat_id = 1;
111+
// The user sending the message
112+
common.v1.UserId user_id = 2;
113+
}
107114
message SendTipMessagePaymentMetadata {
108115
// The chat where the message is being tipped
109116
common.v1.ChatId chat_id = 1;

definitions/flipchat/protos/src/main/proto/messaging/v1/model.proto

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ message Message {
2626
// Timestamp this message was generated at. This value is also encoded in
2727
// any time-based UUID message IDs.
2828
google.protobuf.Timestamp ts = 4;
29+
// If sender_id is provided, were they off stage at the time of sending
30+
// this message
31+
bool was_sender_off_stage = 5;
2932
}
3033
message MessageBatch {
3134
repeated Message messages = 1 ;
@@ -62,6 +65,7 @@ message Content {
6265
ReplyContent reply = 6;
6366
TipContent tip = 7;
6467
DeleteMessageContent deleted = 8;
68+
ReviewContent review = 9;
6569
}
6670
reserved 3; // ExchangeDataContent
6771
reserved 4; // NaclBoxEncryptedContent
@@ -101,3 +105,11 @@ message DeleteMessageContent {
101105
// The message ID of the message that was deleted
102106
MessageId original_message_id = 1 ;
103107
}
108+
message ReviewContent {
109+
// The message ID of the message that is being reviewed. Currently, only
110+
// off stage messages can be reviewed
111+
MessageId original_message_id = 1 ;
112+
// Whether the message has been approved. In the event of multiple reviews,
113+
// the first message in the message log takes priority.
114+
bool is_approved = 2;
115+
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/data/RoomInfo.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.compose.ui.graphics.Color
44
import com.getcode.model.ID
55
import com.getcode.model.Kin
66
import com.getcode.ui.utils.generateComplementaryColorPalette
7-
import com.getcode.utils.base58
87

98
data class RoomInfo(
109
val id: ID? = null,
@@ -14,7 +13,7 @@ data class RoomInfo(
1413
val hostId: ID? = null,
1514
val hostName: String? = null,
1615
val roomNumber: Long = 0,
17-
val coverCharge: Kin = Kin.fromQuarks(0),
16+
val messagingFee: Kin = Kin.fromQuarks(0),
1817
) {
1918
val customTitle: String = runCatching { Regex("^#\\d+:\\s*(.*)").find(title)?.groupValues?.get(1).orEmpty() }.getOrDefault("")
2019

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/conversation/ConversationViewModel.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ import xyz.flipchat.controllers.ChatsController
6969
import xyz.flipchat.controllers.ProfileController
7070
import xyz.flipchat.services.PaymentController
7171
import xyz.flipchat.services.PaymentEvent
72-
import xyz.flipchat.services.data.JoinChatPaymentMetadata
73-
import xyz.flipchat.services.data.SendTipMessagePaymentMetadata
74-
import xyz.flipchat.services.data.erased
75-
import xyz.flipchat.services.data.typeUrl
72+
import xyz.flipchat.services.data.metadata.JoinChatPaymentMetadata
73+
import xyz.flipchat.services.data.metadata.SendTipMessagePaymentMetadata
74+
import xyz.flipchat.services.data.metadata.erased
75+
import xyz.flipchat.services.data.metadata.typeUrl
7676
import xyz.flipchat.services.domain.model.chat.ConversationMember
7777
import xyz.flipchat.services.domain.model.chat.ConversationMessage
7878
import xyz.flipchat.services.domain.model.chat.ConversationWithMembersAndLastPointers
@@ -318,7 +318,7 @@ class ConversationViewModel @Inject constructor(
318318
when {
319319
isRoomClosedAsMember -> ChattableState.DisabledByClosedRoom
320320
isSpectator -> ChattableState.Spectator(
321-
Kin.fromQuarks(it.conversation.coverChargeQuarks ?: 0)
321+
Kin.fromQuarks(it.conversation.messagingFee ?: 0)
322322
)
323323

324324
isMuted -> ChattableState.DisabledByMute
@@ -740,7 +740,7 @@ class ConversationViewModel @Inject constructor(
740740
memberCount = members.count(),
741741
ownerId = room.ownerId,
742742
hostName = moderator?.identity?.displayName,
743-
coverChargeQuarks = room.coverCharge.quarks,
743+
messagingFeeQuarks = room.messagingFee.quarks,
744744
)
745745
dispatchEvent(Event.OpenJoinConfirmation(roomInfo))
746746
}
@@ -779,7 +779,7 @@ class ConversationViewModel @Inject constructor(
779779
)
780780

781781
val amount =
782-
KinAmount.fromQuarks(stateFlow.value.roomInfoArgs.coverChargeQuarks)
782+
KinAmount.fromQuarks(stateFlow.value.roomInfoArgs.messagingFeeQuarks)
783783

784784
paymentController.presentPublicPaymentConfirmation(
785785
amount = amount,
@@ -1282,7 +1282,7 @@ class ConversationViewModel @Inject constructor(
12821282
ownerId = conversation.ownerId,
12831283
hostName = host?.memberName,
12841284
memberCount = members.count(),
1285-
coverChargeQuarks = conversation.coverCharge.quarks
1285+
messagingFeeQuarks = conversation.coverCharge.quarks
12861286
)
12871287
)
12881288
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/cover/CoverChargeViewModel.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package xyz.flipchat.app.features.chat.cover
33
import androidx.lifecycle.viewModelScope
44
import com.getcode.manager.TopBarManager
55
import com.getcode.model.ID
6-
import com.getcode.model.Kin
76
import com.getcode.model.KinAmount
8-
import com.getcode.model.Rate
97
import com.getcode.ui.components.text.AmountAnimatedInputUiModel
108
import com.getcode.ui.components.text.NumberInputHelper
119
import com.getcode.util.resources.ResourceHelper

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/info/ChatInfoViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class ChatInfoViewModel @Inject constructor(
162162
hostId = args.ownerId,
163163
hostName = args.hostName,
164164
roomNumber = args.roomNumber,
165-
coverCharge = Kin.fromQuarks(args.coverChargeQuarks)
165+
messagingFee = Kin.fromQuarks(args.messagingFeeQuarks)
166166
)
167167
)
168168
}
@@ -179,7 +179,7 @@ class ChatInfoViewModel @Inject constructor(
179179
is Event.OnCoverChanged -> { state ->
180180
state.copy(
181181
roomInfo = state.roomInfo.copy(
182-
coverCharge = event.cover,
182+
messagingFee = event.cover,
183183
)
184184
)
185185
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/list/ChatListViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import xyz.flipchat.controllers.ChatsController
3131
import xyz.flipchat.controllers.ProfileController
3232
import xyz.flipchat.services.PaymentController
3333
import xyz.flipchat.services.PaymentEvent
34-
import xyz.flipchat.services.data.StartGroupChatPaymentMetadata
35-
import xyz.flipchat.services.data.erased
36-
import xyz.flipchat.services.data.typeUrl
34+
import xyz.flipchat.services.data.metadata.StartGroupChatPaymentMetadata
35+
import xyz.flipchat.services.data.metadata.erased
36+
import xyz.flipchat.services.data.metadata.typeUrl
3737
import xyz.flipchat.services.domain.model.chat.ConversationWithMembersAndLastMessage
3838
import xyz.flipchat.services.extensions.titleOrFallback
3939
import xyz.flipchat.services.user.AuthState

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/lookup/LookupRoomViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class LookupRoomViewModel @Inject constructor(
125125
memberCount = it.members.count(),
126126
ownerId = it.room.ownerId,
127127
hostName = host?.identity?.displayName,
128-
coverChargeQuarks = it.room.coverCharge.quarks
128+
messagingFeeQuarks = it.room.messagingFee.quarks
129129
)
130130
dispatchEvent(Event.OnOpenConfirmation(confirmJoinArgs))
131131
}

flipchatApp/src/main/kotlin/xyz/flipchat/app/features/chat/lookup/confirm/JoinConfirmationViewModel.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import com.getcode.model.Kin
77
import com.getcode.model.KinAmount
88
import com.getcode.navigation.RoomInfoArgs
99
import com.getcode.services.model.ExtendedMetadata
10-
import com.getcode.services.utils.onSuccessWithDelay
1110
import com.getcode.solana.keys.PublicKey
1211
import com.getcode.util.resources.ResourceHelper
1312
import com.getcode.view.BaseViewModel2
1413
import dagger.hilt.android.lifecycle.HiltViewModel
15-
import kotlinx.coroutines.delay
1614
import kotlinx.coroutines.flow.filterIsInstance
1715
import kotlinx.coroutines.flow.flatMapLatest
1816
import kotlinx.coroutines.flow.launchIn
@@ -30,12 +28,11 @@ import xyz.flipchat.controllers.ChatsController
3028
import xyz.flipchat.controllers.ProfileController
3129
import xyz.flipchat.services.PaymentController
3230
import xyz.flipchat.services.PaymentEvent
33-
import xyz.flipchat.services.data.JoinChatPaymentMetadata
34-
import xyz.flipchat.services.data.erased
35-
import xyz.flipchat.services.data.typeUrl
31+
import xyz.flipchat.services.data.metadata.JoinChatPaymentMetadata
32+
import xyz.flipchat.services.data.metadata.erased
33+
import xyz.flipchat.services.data.metadata.typeUrl
3634
import xyz.flipchat.services.user.UserManager
3735
import javax.inject.Inject
38-
import kotlin.time.Duration.Companion.seconds
3936

4037
data class LoadingSuccessState(
4138
val loading: Boolean = false,
@@ -130,7 +127,7 @@ class JoinConfirmationViewModel @Inject constructor(
130127
.mapNotNull {
131128
val destination = stateFlow.value.paymentDestination ?: return@mapNotNull null
132129
val amount =
133-
KinAmount.fromQuarks(it.coverCharge.quarks)
130+
KinAmount.fromQuarks(it.messagingFee.quarks)
134131

135132
dispatchEvent(Event.OnJoiningChanged(true))
136133
if (userManager.userId == it.hostId) {
@@ -215,7 +212,7 @@ class JoinConfirmationViewModel @Inject constructor(
215212
hostId = args.ownerId,
216213
hostName = args.hostName,
217214
roomNumber = args.roomNumber,
218-
coverCharge = Kin.fromQuarks(args.coverChargeQuarks)
215+
messagingFee = Kin.fromQuarks(args.messagingFeeQuarks)
219216
),
220217
)
221218
}

0 commit comments

Comments
 (0)