mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-01 18:31:35 +00:00
Automatically update whether profiles are private
This commit is contained in:
parent
3cbe4647e1
commit
a8ca233027
2 changed files with 19 additions and 13 deletions
|
|
@ -1,6 +1,6 @@
|
|||
const {Feed} = require("feed")
|
||||
const constants = require("../constants")
|
||||
const config = require("../../../config")
|
||||
const db = require("../db")
|
||||
const TimelineEntry = require("./TimelineEntry")
|
||||
const InstaCache = require("../cache")
|
||||
const collectors = require("../collectors")
|
||||
|
|
@ -50,6 +50,15 @@ class Timeline {
|
|||
}
|
||||
|
||||
addPage(page) {
|
||||
// update whether the user should be private
|
||||
if (this.pages.length === 0 && page.count > 0) { // this is the first page, and user has posted
|
||||
const shouldBePrivate = page.edges.length === 0
|
||||
if (shouldBePrivate !== this.user.data.is_private) {
|
||||
db.prepare("UPDATE Users SET is_private = ? WHERE user_id = ?").run(+shouldBePrivate, this.user.data.id)
|
||||
this.user.data.is_private = shouldBePrivate
|
||||
}
|
||||
}
|
||||
// add the page
|
||||
this.pages.push(transformEdges(page.edges))
|
||||
this.page_info = page.page_info
|
||||
this.user.posts = page.count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue