Skip to content
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

More things for 2024 #254

Merged
merged 19 commits into from
Feb 13, 2024
Merged

More things for 2024 #254

merged 19 commits into from
Feb 13, 2024

Conversation

cohoe
Copy link
Member

@cohoe cohoe commented Jan 18, 2024

Fixed Issues:

Touched Issues:

Misc:

  • Fix regression with database migrations on a fresh database
  • De-duplicated LFG links in Trunk
  • Fix Create Announcement button text
  • Update forum field references based on guidance from last PR
  • Commentary on internal app connection settings
  • Remove Twarrt locust tests
  • Account creation now forces users through Code of Conduct first
  • Login/Password/etc pages now have more useful titles

@cohoe cohoe marked this pull request as ready for review January 23, 2024 18:06
Copy link
Member

@hendricksond hendricksond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of comments that can be no-op.

Copy link
Collaborator

@challfry challfry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments; big thing is the pinning.

Bulk of this looks good, but it reminds me why, while I'm not a stickler for one-issue-per-PR, mixing search-and-replace with substantive changes in one PR makes my eyes bleed.

Sources/swiftarr/Controllers/ForumController.swift Outdated Show resolved Hide resolved
.filter(\.$forum.$id == forum.requireID())
.filter(\.$pinned == true)
.all()
return try await buildPostData(query, userID: user.userID, on: req)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that the forum creator can pin posts in their forum greatly increases the likelihood that someone makes a forum with more than a page of pinned posts. Mods aren't likely to do it, but thread creators just might.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if they do they risk pissing off their readers, which could also attract moderator attention. Do you think we should restrict pinning posts to just moderators? I feel like that'll make the feature significantly less effective.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm just saying that I'd prefer a solution that doesn't buckle with a ton of pinned posts.

///
/// - Parameter forumID: In the URL path.
/// - Returns array of `PostData`.
func forumPinnedPostsHandler(_ req: Request) async throws -> [PostData] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bunch of stuff that buildForumData does that this method doesn't, besides pagination. It appears that this fn doesn't respect blocks, mutes, or mutewords, and because it returns an array of PostData instead of a ForumData, this call is difficult to use by itself without also calling GET /api/v3/forum/ID. Not that big of a deal by itself, but if you're getting to a forum via GET /api/v3/forum/post/ID/forum (the call that is used to get from a search results post to the forum containing that post), you'd have to call the post-to-forum call first, and then use that to get the forum ID you need to get the pinned posts in that forum.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call regarding the blocks/mutes/words and buildForumData. I'll add that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok i've added blocks/mutes/muteword support.

Unless I'm totally high: buildForumData doesn't apply here. That function as currently designed starts from a Forum and does its own query to build posts from there. IMO adding a pinsOnly = true mode adds excessive complexity to an already complex function. Going through the major features:

  • blocks/mutes/mutewords can already be done in the request handler query and matches patterns done elsewher.e
  • start/limit doesn't really apply since this usage really shouldn't support pagination. If someone has paginated the number of pinned posts in a thread, jezus lord we're off the rails. I'd rather institute a "no more than 5 pins per thread" sort of limit on the pin create handler at that point.
  • lastPostID and event data is irrelevant for this use.

As for the call being difficult to use by itself, I'd say "sort-of".

In the web UI we display pinned posts in the normal "thread view" and in the "thread from post view". In the former case, the forumID is in the URL so that's an easy async GET to both /forum/:forum_ID /forum/:forum_ID/pinnedposts. In the latter case, it's a [not-A]sync GET since we have to wait for the ForumData response in the /forum/post/:postID/forum call to then do the /forum/:forum_ID/pinnedposts call. IMO this minor sub-optimization is acceptable.

Tricordarr doesn't even go this far. There is a dedicated "pinned posts" button in the header of the /forum/:forum_ID and /forum/post/:post_ID/forum screens that takes you to the /forum/:forum_ID/pinnedposts screen. Either one doesn't execute until the user does something anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waxing poetically here for a moment: I'm not even sure the pinned posts at the top of the screen should remain in the "long term" in the Web UI. It could rapidly get overwhelmed and should likely end up in a sub view. At which point perhaps buildForumData returns a pinnedPostCount that can give the user a more useful hint that there's pinned content elsewhere. And a button will take them there. But either way it still requires a dedicated API call that IMO should not take in any more info than it needs to.

Sources/swiftarr/Models/Forum.swift Outdated Show resolved Hide resolved
Sources/swiftarr/Models/Forum.swift Outdated Show resolved Hide resolved
@cohoe
Copy link
Member Author

cohoe commented Feb 13, 2024

Chall and I had a good phone call involving lobsters and pinned posts. Good to merge.

@cohoe cohoe merged commit 435d448 into jocosocial:master Feb 13, 2024
1 check passed
@cohoe cohoe deleted the 2024part2 branch February 13, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants