federate votersCount #1116
No reviewers
Labels
No labels
approved, awaiting change
broken setup
bug
cannot reproduce
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs change/feedback
needs docs
needs tests
not a bug
not our bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AkkomaGang/akkoma!1116
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Yonle/akkoma:fed_votersCount"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
note: some patches are retrieved from upstream pleroma, so there might be some logic errors.
todo:
votersCountgetting bumped on every answersvotersCountcorrectly 26843656d7WIP: try to federate votersCountto try to federate votersCountvoters_count. e19e948eecalright should be good to address #485 . Only test script hasn't being polished, as
poll_viewnow readsvotersCountfrom the object first before counting local voters manually.@ -341,0 +343,4 @@object.data["votersCount"] + 1elselength(voters)endthis seems very wrong. If
votersCountexists, it will just bump the count on each vote, including multiple votes from the same actor making it just a redundant copy of the sum of all option’sreplies.totalItemsWithout having checked, I’m guessing this function only runs on either local polls or local answers of remote polls *(else we wouldn’t know about voter identity), so you’ll want to merge this with the
votersupdate and before both first check whether there’s already a vote from this actor.Also add a test for this
ok, damn. just noticed that once you pointed it out.
initially, i am thinking of doing
but then realized that local post also had votersCount, so i wonder how do we get this though. whenever we had to check that whenever this is a local object or not, and then use different logic for remote ones (given we
votershere only have local voters)For remote polls,
votersonly has local voters. For local polls,votershas actually all voters.For remote polls though, we also only ever known about and process local vote(r)s anyway, so just
should probably work
@ -84,3 +80,1 @@# only count local voters here; see https://akkoma.dev/AkkomaGang/akkoma/issues/190nilenddefp voters_count(%{data: %{"votersCount" => voters}}), do: votersThe comment clearly explains why removing the
nilreturn for single-selection polls here is plain wrong and will (re)introduce bugsYou restored the
nilwhich is good, but(a) you forgot to fix the test again
(b) the explaining comment is now gone and
(c) the whole change of the
voters_countfunction is wholly unnecessary in the first place and just extra noiseThe git log is not a diary, the state of the repo should be correct after each single commit and each commit be on logically cohesive, atomic change. Rebasing to drop misguided bits and sqaushing the actually sensible and logically interlocked bits down is much preferable
0b324eb9e428eb65f0b3will need to replace test on poll_view later on.
@ -813,1 +813,4 @@defp set_voters_count(%{"voters" => [_ | _] = voters} = obj) doMap.merge(obj, %{"votersCount" => length(voters)})endshouldn’t this keep the existing
votersCountvalue, if one exists?huh, yea
well, then
as we're going to only set it if
votersCountdidn't exists in the original object (remote ones always exists, or didn't (eg. misskey))that seems doing well now...
but then will do test files next
time to fix tests....
somehow i am stuck on writing the test
putting some safety first
Checks for
is_integer(votersCount)in processing ought to be unnecessary I believe. Either the object predatesfield(:votersCOunt, :integer)having been added tp the validator in which case the field got dropped (and thus is nownil), or it was added afterwards and thus is already guaranteed to be an integer. It just makes everything more complicated than it needs to be an harder to read.If it was an actual concern, I think it would be better to run a migration to ensure all old object conform to the expect type or omit it entirely.
The new Pleroma commit you cherry-picked seems thus of little value except for tests (which it seems you haven’t run though, given there’s a misplaced, sure-to-fail test in there). Moreover, you kept the commit message from Pleroma, describing the state in Pleroma prior to any changes. But this description is wrong and actively misleading/confusing for the state of Akkoma prior to the cherry-pick.
Unrelated to this: I think it would be good to add a
"votersCout" => 0initialisation immediately to newly created local polls. This needs to be done inlib/pleroma/web/common_api/utils.ex::make_poll_data/1.Furthermore, the new
votersCountproperty must be defined in the JSON-LD context too; else JSON-LD processing implementation will get confused.Conceptually this also needs a counterpart ot decrease voter count if a voter retracts all their votes. However, it seems we currently fully ignore vote retractions (
Deleteof the answer), so... out of scope for this PR ig@ -193,0 +203,4 @@result = PollView.render("show.json", %{object: object})assert result[:pleroma][:non_anonymous] == trueendA test with this purpose already exists. It also has nothing to do with the changes of this patch series. This does not belong here and this test case will fail both because it’s relying on a non-existing mock and because its testing the wrong API
damn, that slipped thru.
I guess i will probably revert and then take some gists of the commits later, There's stuffs going on here.
@Oneric wrote in #1116 (comment):
better be prepared than nothing i guess. Will write about it later
will add it.
right, i forgot we haven't dealt with that one, so will do it.
as of now we haven't seen a server that did exactly that, so it's safe for now. but i think it's a good idea to add that later on, but however not on this PR of course. probably opening issues to track about it later
79e755d790dbb06b4115dbb06b41156d5b1b936b6d5b1b936b3ea4b60c003ea4b60c00f694c7e081f694c7e0817704e4a32b7704e4a32be13f025e22try to federate votersCountto federate votersCount