Skip to content

Commit

Permalink
Merge pull request #498 from xmtp/rygine/pppp-rename
Browse files Browse the repository at this point in the history
Rename `pppp` => `user-preferences`
  • Loading branch information
rygine authored Dec 5, 2023
2 parents fc36363 + 1804bff commit ae74d4b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class Contacts {
this.addresses = new Set<string>()
this.consentList = new ConsentList(client)
this.client = client
this.jobRunner = new JobRunner('pppp', client.keystore)
this.jobRunner = new JobRunner('user-preferences', client.keystore)
}

async loadConsentList(startTime?: Date) {
Expand Down
4 changes: 2 additions & 2 deletions src/conversations/JobRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dateToNs, nsToDate } from '../utils'

const CLOCK_SKEW_OFFSET_MS = 10000

type JobType = 'v1' | 'v2' | 'pppp'
type JobType = 'v1' | 'v2' | 'user-preferences'

type UpdateJob<T> = (lastRun: Date | undefined) => Promise<T>

Expand Down Expand Up @@ -73,7 +73,7 @@ function getProtoJobType(jobType: JobType): keystore.JobType {
const protoJobType = {
v1: keystore.JobType.JOB_TYPE_REFRESH_V1,
v2: keystore.JobType.JOB_TYPE_REFRESH_V2,
pppp: keystore.JobType.JOB_TYPE_REFRESH_PPPP,
'user-preferences': keystore.JobType.JOB_TYPE_REFRESH_PPPP,
}[jobType]

if (!protoJobType) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ export const buildUserPrivateStoreTopic = (addrPrefixedKey: string): string => {
}

export const buildUserPrivatePreferencesTopic = (identifier: string) =>
buildContentTopic(`pppp-${identifier}`)
buildContentTopic(`user-preferences-${identifier}`)
24 changes: 13 additions & 11 deletions test/conversations/JobRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,23 @@ describe('JobRunner', () => {
})

it('resets the last run time', async () => {
const ppppRunner = new JobRunner('pppp', keystore)
await ppppRunner.run(async () => {})
const userPreferencesRunner = new JobRunner('user-preferences', keystore)
await userPreferencesRunner.run(async () => {})

const { lastRunNs: ppppLastRunNs } = await keystore.getRefreshJob({
jobType: keystoreProto.JobType.JOB_TYPE_REFRESH_PPPP,
})
const { lastRunNs: userPreferencesLastRunNs } =
await keystore.getRefreshJob({
jobType: keystoreProto.JobType.JOB_TYPE_REFRESH_PPPP,
})

expect(ppppLastRunNs.gt(0)).toBeTruthy()
expect(userPreferencesLastRunNs.gt(0)).toBeTruthy()

await ppppRunner.resetLastRunTime()
await userPreferencesRunner.resetLastRunTime()

const { lastRunNs: ppppLastRunNs2 } = await keystore.getRefreshJob({
jobType: keystoreProto.JobType.JOB_TYPE_REFRESH_PPPP,
})
const { lastRunNs: userPreferencesLastRunNs2 } =
await keystore.getRefreshJob({
jobType: keystoreProto.JobType.JOB_TYPE_REFRESH_PPPP,
})

expect(ppppLastRunNs2.eq(0)).toBeTruthy()
expect(userPreferencesLastRunNs2.eq(0)).toBeTruthy()
})
})

0 comments on commit ae74d4b

Please sign in to comment.