Skip to content

Commit 6b0ae7d

Browse files
alltheseasclaude
andcommitted
Add member_for_more_than_three_years account attribute
Return the new member_for_more_than_three_years boolean in the account attributes response. Uses the same 360-day-year convention as the existing one-year check (3 × 360 = 1080 days). The total membership time is now computed once and reused for both thresholds. Companion to damus-io/damus#3592. Signed-off-by: alltheseas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 9ec225e commit 6b0ae7d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/user_management.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ function get_account_info_payload(subscriber_number, account, authenticated = fa
179179
const account_active = (account.expiry && current_time() < account.expiry) ? true : false
180180
// We consider one year to be 360 days, to be a bit lenient with users who might have a few days of downtime in their subscription, and make sure everyone who roughly got a year of service gets the benefit during the announcement.
181181
const one_year_in_seconds = 360 * 24 * 60 * 60
182+
const three_years_in_seconds = 3 * one_year_in_seconds
182183
// Performance optimization: We only calculate the total membership time if the account is active
183-
const member_for_more_than_one_year = account_active ? total_active_membership_time(account) > one_year_in_seconds : false
184+
const total_membership_time = account_active ? total_active_membership_time(account) : 0
185+
const member_for_more_than_one_year = total_membership_time > one_year_in_seconds
186+
const member_for_more_than_three_years = total_membership_time > three_years_in_seconds
184187

185188

186189
return {
@@ -192,6 +195,7 @@ function get_account_info_payload(subscriber_number, account, authenticated = fa
192195
testflight_url: (authenticated && account_active) ? process.env.TESTFLIGHT_URL : null,
193196
attributes: {
194197
member_for_more_than_one_year: member_for_more_than_one_year,
198+
member_for_more_than_three_years: member_for_more_than_three_years,
195199
}
196200
}
197201
}

test/router_config.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ test('config_router - Account management routes', async (t) => {
9292
active: true,
9393
testflight_url: null,
9494
attributes: {
95-
member_for_more_than_one_year: false
95+
member_for_more_than_one_year: false,
96+
member_for_more_than_three_years: false
9697
}
9798
};
9899
t.same(res.body, expectedData, 'Response should match expected value');

0 commit comments

Comments
 (0)