mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Fix blinded ID moderator checks in emoji reaction popup (#964)
* fix: emoji popup now uses blinded ID as well * fix: add conversation menu handling for ban and delete all actions, as well as add placeholder icons
This commit is contained in:
parent
29124f36b6
commit
bdc4f5aebe
@ -989,7 +989,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
Log.e("Loki", "Failed to show emoji picker", e)
|
||||
return
|
||||
}
|
||||
ViewUtil.hideKeyboard(this, visibleMessageView);
|
||||
ViewUtil.hideKeyboard(this, visibleMessageView)
|
||||
binding?.reactionsShade?.isVisible = true
|
||||
showOrHidScrollToBottomButton(false)
|
||||
binding?.conversationRecyclerView?.suppressLayout(true)
|
||||
@ -1020,7 +1020,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
message.isOutgoing,
|
||||
visibleMessageView.messageContentView
|
||||
)
|
||||
reactionDelegate.show(this, message, selectedConversationModel)
|
||||
reactionDelegate.show(this, message, selectedConversationModel, viewModel.blindedPublicKey)
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
||||
@ -1802,6 +1802,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
ConversationReactionOverlay.Action.VIEW_INFO -> showMessageDetail(selectedItems)
|
||||
ConversationReactionOverlay.Action.SELECT -> selectMessages(selectedItems)
|
||||
ConversationReactionOverlay.Action.DELETE -> deleteMessages(selectedItems)
|
||||
ConversationReactionOverlay.Action.BAN_AND_DELETE_ALL -> banAndDeleteAll(selectedItems)
|
||||
ConversationReactionOverlay.Action.BAN_USER -> banUser(selectedItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,15 @@ internal class ConversationReactionDelegate(private val overlayStub: Stub<Conver
|
||||
fun show(
|
||||
activity: Activity,
|
||||
messageRecord: MessageRecord,
|
||||
selectedConversationModel: SelectedConversationModel
|
||||
selectedConversationModel: SelectedConversationModel,
|
||||
blindedPublicKey: String?
|
||||
) {
|
||||
resolveOverlay().show(
|
||||
activity,
|
||||
messageRecord,
|
||||
lastSeenDownPoint,
|
||||
selectedConversationModel
|
||||
selectedConversationModel,
|
||||
blindedPublicKey
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
||||
private Activity activity;
|
||||
private MessageRecord messageRecord;
|
||||
private SelectedConversationModel selectedConversationModel;
|
||||
private String blindedPublicKey;
|
||||
private OverlayState overlayState = OverlayState.HIDDEN;
|
||||
private RecentEmojiPageModel recentEmojiPageModel;
|
||||
|
||||
@ -142,7 +143,8 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
||||
public void show(@NonNull Activity activity,
|
||||
@NonNull MessageRecord messageRecord,
|
||||
@NonNull PointF lastSeenDownPoint,
|
||||
@NonNull SelectedConversationModel selectedConversationModel)
|
||||
@NonNull SelectedConversationModel selectedConversationModel,
|
||||
@Nullable String blindedPublicKey)
|
||||
{
|
||||
if (overlayState != OverlayState.HIDDEN) {
|
||||
return;
|
||||
@ -150,6 +152,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
||||
|
||||
this.messageRecord = messageRecord;
|
||||
this.selectedConversationModel = selectedConversationModel;
|
||||
this.blindedPublicKey = blindedPublicKey;
|
||||
overlayState = OverlayState.UNINITAILIZED;
|
||||
selected = -1;
|
||||
recentEmojiPageModel = new RecentEmojiPageModel(activity);
|
||||
@ -668,16 +671,16 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
||||
items.add(new ActionItem(R.attr.menu_copy_icon, getContext().getResources().getString(R.string.activity_conversation_menu_copy_session_id), () -> handleActionItemClicked(Action.COPY_SESSION_ID)));
|
||||
}
|
||||
// Delete message
|
||||
if (ConversationMenuItemHelper.userCanDeleteSelectedItems(getContext(), message, openGroup, userPublicKey)) {
|
||||
if (ConversationMenuItemHelper.userCanDeleteSelectedItems(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||
items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.delete), () -> handleActionItemClicked(Action.DELETE)));
|
||||
}
|
||||
// Ban user
|
||||
if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey)) {
|
||||
items.add(new ActionItem(0, getContext().getResources().getString(R.string.conversation_context__menu_ban_user), () -> handleActionItemClicked(Action.BAN_USER)));
|
||||
if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||
items.add(new ActionItem(R.attr.menu_block_icon, getContext().getResources().getString(R.string.conversation_context__menu_ban_user), () -> handleActionItemClicked(Action.BAN_USER)));
|
||||
}
|
||||
// Ban and delete all
|
||||
if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey)) {
|
||||
items.add(new ActionItem(0, getContext().getResources().getString(R.string.conversation_context__menu_ban_and_delete_all), () -> handleActionItemClicked(Action.BAN_AND_DELETE_ALL)));
|
||||
if (ConversationMenuItemHelper.userCanBanSelectedUsers(getContext(), message, openGroup, userPublicKey, blindedPublicKey)) {
|
||||
items.add(new ActionItem(R.attr.menu_trash_icon, getContext().getResources().getString(R.string.conversation_context__menu_ban_and_delete_all), () -> handleActionItemClicked(Action.BAN_AND_DELETE_ALL)));
|
||||
}
|
||||
// Message detail
|
||||
if (message.isFailed()) {
|
||||
|
@ -8,17 +8,17 @@ import org.thoughtcrime.securesms.groups.OpenGroupManager
|
||||
object ConversationMenuItemHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun userCanDeleteSelectedItems(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String): Boolean {
|
||||
fun userCanDeleteSelectedItems(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String, blindedPublicKey: String?): Boolean {
|
||||
if (openGroup == null) return message.isOutgoing || !message.isOutgoing
|
||||
if (message.isOutgoing) return true
|
||||
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey)
|
||||
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun userCanBanSelectedUsers(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String): Boolean {
|
||||
fun userCanBanSelectedUsers(context: Context, message: MessageRecord, openGroup: OpenGroup?, userPublicKey: String, blindedPublicKey: String?): Boolean {
|
||||
if (openGroup == null) return false
|
||||
if (message.isOutgoing) return false // Users can't ban themselves
|
||||
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey)
|
||||
return OpenGroupManager.isUserModerator(context, openGroup.groupId, userPublicKey, blindedPublicKey)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user