···3131 })
3232 const result = await likesUtil.unlikeAPackageAndReturnLikes(body.packageName, loggedInUsersDid)
3333 return result
3434+ } else {
3535+ // Always unlike in the cache if this endpoint is called. May be a mismatch
3636+ await likesUtil.setUnlikeInCache(body.packageName, loggedInUsersDid)
3437 }
35383639 console.warn(
+13-3
server/utils/atproto/utils/likes.ts
···168168 let totalLikes = await this.cache.get<number>(totalLikesKey)
169169 if (!totalLikes) {
170170 totalLikes = await this.constellationLikes(subjectRef)
171171- totalLikes = totalLikes + 1
172172- await this.cache.set(totalLikesKey, totalLikes, CACHE_MAX_AGE)
173171 }
172172+ totalLikes = totalLikes + 1
173173+ await this.cache.set(totalLikesKey, totalLikes, CACHE_MAX_AGE)
174174+174175 // We already know the user has not liked the package before so set in the cache
175176 await this.cache.set(CACHE_USER_LIKES_KEY(packageName, usersDid), true, CACHE_MAX_AGE)
176177 return {
···213214 }
214215215216 /**
217217+ * Access to unlike a package for a user in the cache.
218218+ * @param packageName
219219+ * @param usersDid
220220+ */
221221+ async setUnlikeInCache(packageName: string, usersDid: string) {
222222+ await this.cache.set(CACHE_USER_LIKES_KEY(packageName, usersDid), false, CACHE_MAX_AGE)
223223+ }
224224+225225+ /**
216226 * At this point you should have checked if the user had a record for the package on the network and removed it before updating the cache
217227 * @param packageName
218228 * @param usersDid
···230240 await this.cache.set(totalLikesKey, totalLikes, CACHE_MAX_AGE)
231241232242 //Clean up
233233- await this.cache.set(CACHE_USER_LIKES_KEY(packageName, usersDid), false, CACHE_MAX_AGE)
243243+ await this.setUnlikeInCache(packageName, usersDid)
234244 await this.cache.delete(CACHE_USERS_BACK_LINK(packageName, usersDid))
235245236246 return {