-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature Addition: Account Linker/Switcher && Bugfix: Enable staff to see hidden threads #209
base: master
Are you sure you want to change the base?
Conversation
Missing return statement in cancan.js, rendering deleted threads gone forever
Added SQL query for staff to retrieve hidden topics. Had the bonus effect of coalescing two different queries that otherwise had to be synchronized, now managed by one function.
Added check to see if user was staff, and if so, expose hidden threads on /forums/:forumSlug
I don't have registration enabled on my test instance due to lack of CAPTCHA key. This was a pretty simple query, but please verify that it works properly.
Major caveat: This commit requires an addition to the DB schema. Specifically, a two-column table for account alts and pre-populating that table with all user accounts. The two queries I added to schema and dev_seeds should get everything set up. Reproduced below for clarity: CREATE TABLE alts ( INSERT INTO alts (id, ownerId) Additional notes: I did some onclick JS in macros.html to support the dropdown menu, and left it inline since it was pretty much a one-liner. If you want me to break it into its own function in the JS file, let me know and I'll modify it. There's a lot of code to verify here, so feel free to ping me on Discord with any questions—I think most of it should be pretty straightforward. I do need to double check that the alts table is updated on registration. The query was super simple and seemed to work when I pasted it into Postgres, but since I haven't messed around with the test environment to get CAPTCHAs working (or bypass the requirement) I wasn't able to verify that one piece of functionality within the environment context. |
I think all of that put together is this: CREATE TABLE alts (
id integer PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
owner_id integer NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at timestamptz NOT NULL DEFAULT NOW() -- useful for these bridge tables, esp debugging
);
-- There's already an index on primary keys but lets add one for the foreign key.
CREATE INDEX idx_alts_owner_id ON alts(owner_id);
-- Initialize with existing users
INSERT INTO alts (id, owner_id)
SELECT id, id
FROM users; |
Hiding a thread is no longer permanent, preventing 1-click errors (as appears to be the original intent).
Remaining TODO: Threads still show up on the homepage in the Latest section after deletion. If mods wipe a thread, that should trigger an update.