diff --git a/src/managers/post_actions_manager.py b/src/managers/post_actions_manager.py index 161c2a6..ba3a9b4 100644 --- a/src/managers/post_actions_manager.py +++ b/src/managers/post_actions_manager.py @@ -154,11 +154,19 @@ class PostActionsManager(QObject): return False # Check if this is user's own post - is_own_post = ( - post.account.username == active_account.username - and post.account.acct.split("@")[-1] - == active_account.instance_url.replace("https://", "").replace("http://", "") - ) + username_match = post.account.username == active_account.username + active_instance = active_account.instance_url.replace("https://", "").replace("http://", "") + + # Handle both local and federated post formats + if "@" in post.account.acct: + # Federated post: acct is "username@instance.com" + post_instance = post.account.acct.split("@")[-1] + instance_match = post_instance == active_instance + else: + # Local post: acct is just "username", assume same instance + instance_match = True + + is_own_post = username_match and instance_match if not is_own_post: self.action_failed.emit("delete", "Cannot delete: Not your post") @@ -203,11 +211,19 @@ class PostActionsManager(QObject): return False # Don't allow blocking yourself - is_own_post = ( - post.account.username == active_account.username - and post.account.acct.split("@")[-1] - == active_account.instance_url.replace("https://", "").replace("http://", "") - ) + username_match = post.account.username == active_account.username + active_instance = active_account.instance_url.replace("https://", "").replace("http://", "") + + # Handle both local and federated post formats + if "@" in post.account.acct: + # Federated post: acct is "username@instance.com" + post_instance = post.account.acct.split("@")[-1] + instance_match = post_instance == active_instance + else: + # Local post: acct is just "username", assume same instance + instance_match = True + + is_own_post = username_match and instance_match if is_own_post: self.action_failed.emit("block", "Cannot block yourself") @@ -258,11 +274,19 @@ class PostActionsManager(QObject): return False # Don't allow muting yourself - is_own_post = ( - post.account.username == active_account.username - and post.account.acct.split("@")[-1] - == active_account.instance_url.replace("https://", "").replace("http://", "") - ) + username_match = post.account.username == active_account.username + active_instance = active_account.instance_url.replace("https://", "").replace("http://", "") + + # Handle both local and federated post formats + if "@" in post.account.acct: + # Federated post: acct is "username@instance.com" + post_instance = post.account.acct.split("@")[-1] + instance_match = post_instance == active_instance + else: + # Local post: acct is just "username", assume same instance + instance_match = True + + is_own_post = username_match and instance_match if is_own_post: self.action_failed.emit("mute", "Cannot mute yourself") @@ -298,11 +322,19 @@ class PostActionsManager(QObject): return False # Check if this is user's own post - is_own_post = ( - post.account.username == active_account.username - and post.account.acct.split("@")[-1] - == active_account.instance_url.replace("https://", "").replace("http://", "") - ) + username_match = post.account.username == active_account.username + active_instance = active_account.instance_url.replace("https://", "").replace("http://", "") + + # Handle both local and federated post formats + if "@" in post.account.acct: + # Federated post: acct is "username@instance.com" + post_instance = post.account.acct.split("@")[-1] + instance_match = post_instance == active_instance + else: + # Local post: acct is just "username", assume same instance + instance_match = True + + is_own_post = username_match and instance_match if not is_own_post: self.action_failed.emit("edit", "Cannot edit: Not your post") diff --git a/src/widgets/timeline_view.py b/src/widgets/timeline_view.py index f92ae76..af8362d 100644 --- a/src/widgets/timeline_view.py +++ b/src/widgets/timeline_view.py @@ -1411,14 +1411,31 @@ class TimelineView(QTreeWidget): active_account = self.account_manager.get_active_account() is_own_post = False if active_account and hasattr(post, "account"): + # Debug logging for ownership detection + post_username = post.account.username + post_acct = post.account.acct + active_username = active_account.username + active_instance = active_account.instance_url.replace("https://", "").replace("http://", "") + post_instance = post_acct.split("@")[-1] + + self.logger.debug(f"Ownership check: post.username='{post_username}', active.username='{active_username}'") + self.logger.debug(f"Ownership check: post.acct='{post_acct}', post_instance='{post_instance}', active_instance='{active_instance}'") + # Check if this is user's own post - is_own_post = ( - post.account.username == active_account.username - and post.account.acct.split("@")[-1] - == active_account.instance_url.replace("https://", "").replace( - "http://", "" - ) - ) + username_match = post.account.username == active_account.username + + # Handle both local and federated post formats + if "@" in post.account.acct: + # Federated post: acct is "username@instance.com" + post_instance = post.account.acct.split("@")[-1] + instance_match = post_instance == active_instance + else: + # Local post: acct is just "username", assume same instance + instance_match = True + + is_own_post = username_match and instance_match + + self.logger.debug(f"Ownership check result: is_own_post={is_own_post}") # Copy to clipboard action copy_action = QAction("&Copy to Clipboard", self) @@ -1463,9 +1480,8 @@ class TimelineView(QTreeWidget): if is_own_post: menu.addSeparator() - # Edit action + # Edit action (no shortcut here - global shortcut in main window) edit_action = QAction("&Edit Post", self) - edit_action.setShortcut("Ctrl+Shift+E") edit_action.triggered.connect(lambda: self.edit_requested.emit(post)) menu.addAction(edit_action)