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

Move admin flag from person to local_user (fixes #3060) #3403

Merged
merged 11 commits into from
Aug 24, 2023

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Jun 29, 2023

The person table is for federated data, but admin flag can only apply to local users. Thats why it really belongs in the local_user table. This will also prevent the federation code from accidentally overwriting the admin flag

The person table is for federated data, but admin flag can only
apply to local users. Thats why it really belongs in the local_user
table. This will also prevent the federation code from accidentally
overwriting the admin flag
@Nutomic Nutomic requested a review from dessalines as a code owner June 29, 2023 11:01
@Nutomic
Copy link
Member Author

Nutomic commented Jun 30, 2023

This is not a breaking change, the API is unchanged.

let added = data.added;
let added_person_id = data.person_id;
let added_admin = Person::update(
let target = LocalUserView::read_person(context.pool(), data.person_id).await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

If its a breaking change anyway I might as well change these data.person_id to data.local_user_id to avoid unnecessary db reads.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, might as well do this change across the board. Might mean fewer DB calls.

@Nutomic Nutomic requested a review from phiresky as a code owner August 1, 2023 13:42
@Nutomic
Copy link
Member Author

Nutomic commented Aug 1, 2023

Resolved conflicts. For some reason api tests are failing with this error, no idea why:


$ jest -i follow.spec.ts && jest -i src/post.spec.ts && jest -i comment.spec.ts && jest -i private_message.spec.ts && jest -i user.spec.ts && jest -i community.spec.ts
FAIL  src/follow.spec.ts
✕ Follow federated community

● Follow federated community

thrown: "unknown"

10 | } from "./shared";
11 |
> 12 | beforeAll(async () => {
| ^
13 |   await setupLogins();
14 | });
15 |

at Object.<anonymous> (src/follow.spec.ts:12:1)

@dessalines
Copy link
Member

I'll test it out now

@dessalines
Copy link
Member

The admin column on the source table was in the wrong order. It needs to match the order in schema.rs. This was hard to find because they were both boolean columns.

@dessalines
Copy link
Member

dessalines commented Aug 2, 2023

This test started failing all the sudden.

Here's the failing line

I don't understand why its suddenly unable to resolve a banned person.

@Nutomic Nutomic force-pushed the move-admin-flag-to-local-user branch from a43be04 to 8554465 Compare August 16, 2023 11:15
@dessalines dessalines enabled auto-merge (squash) August 22, 2023 13:13
@dessalines dessalines merged commit 6047257 into main Aug 24, 2023
Bazsalanszky pushed a commit to Bazsalanszky/Eternity that referenced this pull request Oct 6, 2023
… of Lemmy

See: LemmyNet/lemmy#3403

For now, I guess we can try parsing the flag if it's present, and fall
back on assuming the associated user is *not* an admin.
Bazsalanszky pushed a commit to Bazsalanszky/Eternity that referenced this pull request Oct 19, 2023
… of Lemmy

See: LemmyNet/lemmy#3403

For now, I guess we can try parsing the flag if it's present, and fall
back on assuming the associated user is *not* an admin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants