you are viewing a single comment's thread.

view the rest of the comments →

[–]teelo 6 insightful - 1 fun6 insightful - 0 fun7 insightful - 1 fun -  (7 children)

Sure I can jump in and help. Just point me to the repo?

[–]magnora7[S] 4 insightful - 1 fun4 insightful - 0 fun5 insightful - 1 fun -  (6 children)

https://github.com/libertysoft3/saidit

Here you go sir. You could probably search "removed" in the codebase to find where to start finding the code for removed comments. I think the "removed" flag is written in to the database in its own column for each comment. Good luck, let me know if I can help

[–]teelo 5 insightful - 2 fun5 insightful - 1 fun6 insightful - 2 fun -  (5 children)

So I don't really know python, so I can't write the code, but I can certainly give some direction to what I suspect should work.

modaction.py, line 346:

if hasattr(item.target, "link_id"):
  parent_link_name = item.target.link_id
  item.parent_link = parent_links[parent_link_name]

Append something like "?frommodlog=true" to that item.parent_link, so that we send a _GET parameter to the comment page signalling that we're viewing it from the moderator log.

builder.py, line 1467:

def keep_item(self, item):
   if not self.show_deleted:
       if item.deleted and not item.num_children:
           return False
   return item.keep_item(item)

If I'm reading that right, if the item is flagged deleted, it returns false. So add a check for: 1) the _GET parameter we defined before, and 2) that the commentID in the URL matches this item. If it does, return True instead.

[–]magnora7[S] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (4 children)

Very nice, I'm impressed. I think your approach is good, to send an API add-on to display the comments page in "modlog" mode. Smart.

I am not quite sure you have the right lines in builder.py, but you're very close. I think that code is for deletions, when a user deletes a comment of their own volition. We are looking for removals, which is when an admin or mod removes the comment. I think the code to filter out removed comments would probably be around that area in builder.py too. If you find that part, then we'll practically have the solution.

Then lastly we'd have to figure out how to intercept the API call and do the correct action. routing.py has most of the API handling. So somehow that switch needs to be able to be flipped by the correct API call to a comment page.

Definitely getting close... keep going and we might actually get this feature developed!

[–]teelo 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (3 children)

Theres this bit in listingcontroller.py, line 1750:

class CommentsController(SubredditListingController):
title_text = _('comments')

def keep_fn(self):
    def keep(item):
        if c.user_is_admin:
            return True

        if item._deleted:
            return False

        if isinstance(c.site, FriendsSR):
            if item.author._deleted or item.author._spam:
                return False

        if c.user_is_loggedin:
            if item.subreddit.is_moderator(c.user):
                return True

            if item.author_id == c.user._id:
                return True

        if item._spam:
            return False
        return item.keep_item(item)
    return keep

But that only checks for deleted (by the author, I presume) or if its marked spam. Do moderator removals just mark comments as spam?

I wouldn't know how to send the extra parameter or detect it. Not a python dev.

[–]magnora7[S] 4 insightful - 2 fun4 insightful - 1 fun5 insightful - 2 fun -  (2 children)

Marking spam and removing are separate operations an admin can do to remove a comment. I am not sure the difference between the two, honestly. Maybe when it's removed it does mark it as item._spam. Does item._removed exist as a classifier, I wonder?

The code bit you pointed out looks very close to what we need though, you're definitely hot on the trail

[–]teelo 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (1 child)

Does item._removed exist as a classifier

I think this will answer that question for us! test_validator.py, 237:

    def test_removed_comment(self):
    comment = self._mock_comment(_spam=True)
    result = self.validator.run('fullname', None)

    self.assertEqual(result, comment)
    self.assertTrue(self.validator.has_errors)
    self.assertIn((errors.DELETED_COMMENT, None), c.errors)

(I searched "_remove" and no results outside of the jQuery libraries)

[–]magnora7[S] 5 insightful - 2 fun5 insightful - 1 fun6 insightful - 2 fun -  (0 children)

Alright looks like a pretty promising start! I think this is about half the info needed to make this thing happen, thanks for your help so far! I'll add this thread to our to-do list so we can reference it later when we try to build the feature out fully