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

Newly subscribed federated communities have incorrect post_aggregates.published and newest_comment_time from outbox #1402

Closed
dessalines opened this issue Jan 31, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@dessalines
Copy link
Member

https://lemmy.ml/post/51497

On a subscribe to a federated community, it fetches the outbox. That outbox correctly sets the post.published, but our actual post sorting uses post_aggregates.published and post_aggregates.newest_comment_time, both of which have default inserts of now().

The best way might be to alter this table trigger, to make sure it doesn't use those defaults:

create function post_aggregates_post()
returns trigger language plpgsql
as $$
begin
  IF (TG_OP = 'INSERT') THEN
    insert into post_aggregates (post_id) values (NEW.id);
  ELSIF (TG_OP = 'DELETE') THEN
    delete from post_aggregates where post_id = OLD.id;
  END IF;
  return null;
end $$;

But that is contingent on the original post insert in the federated code using correct values, and not setting them after the fact.

@dessalines dessalines added the bug Something isn't working label Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant