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

fix pid creation for users who have commented before voting #1928

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ String.prototype.hashCode = function () {
};

function initializePolisHelpers() {

const polisTypes = Utils.polisTypes;
const setCookie = cookies.setCookie;
const setParentReferrerCookie = cookies.setParentReferrerCookie;
Expand Down Expand Up @@ -2646,7 +2645,6 @@ Email verified! You can close this tab or hit the back button.
}

function finish(ptpt: any) {

clearCookie(req, res, COOKIES.PARENT_URL);
clearCookie(req, res, COOKIES.PARENT_REFERRER);

Expand Down Expand Up @@ -5427,7 +5425,7 @@ Email verified! You can close this tab or hit the back button.
}

async function doGetPid(): Promise<number> {
if (_.isUndefined(pid)) {
if (_.isUndefined(pid) || Number(pid) === -1) {
const newPid = await getPidPromise(zid!, uid!, true);
if (newPid === -1) {
const rows = await addParticipant(zid!, uid!);
Expand Down Expand Up @@ -5479,17 +5477,18 @@ Email verified! You can close this tab or hit the back button.
const pidPromise = (async () => {
if (xid) {
const xidUser = await getXidStuff(xid, zid!);
shouldCreateXidRecord = xidUser === "noXidRecord";
if (typeof xidUser === "object") {
shouldCreateXidRecord =
xidUser === "noXidRecord" || xidUser.pid === -1;
if (typeof xidUser === "object" && !shouldCreateXidRecord) {
uid = xidUser.uid;
pid = xidUser.pid;
return pid;
}
}
const newPid = await doGetPid();
if (shouldCreateXidRecord) {
await createXidRecordByZid(zid!, uid!, xid!, null, null, null);
}
const newPid = await doGetPid();
return newPid;
})();

Expand Down Expand Up @@ -10205,7 +10204,6 @@ Thanks for using Polis!
return Promise.all([
getSocialParticipants(zid, uid, hardLimit, mod, math_tick, authorUids),
]).then(function (stuff: never[][]) {

let participantsWithSocialInfo: any[] = stuff[0] || [];

participantsWithSocialInfo = participantsWithSocialInfo.map(
Expand Down
Loading