forked from GNUsocial/gnu-social
Move inbox initialization to upgrade.php
Move the inbox initialization code to upgrade.php. Might not catch group messages, but maybe that's not a big deal.
This commit is contained in:
45
scripts/upgrade.php
Executable file → Normal file
45
scripts/upgrade.php
Executable file → Normal file
@@ -42,6 +42,7 @@ function main()
|
||||
fixupNoticeConversation();
|
||||
initConversation();
|
||||
fixupGroupURI();
|
||||
initInbox();
|
||||
}
|
||||
|
||||
function tableDefs()
|
||||
@@ -183,4 +184,48 @@ function initConversation()
|
||||
printfnq("DONE.\n");
|
||||
}
|
||||
|
||||
function initInbox()
|
||||
{
|
||||
printfnq("Ensuring all users have an inbox...");
|
||||
|
||||
$user = new User();
|
||||
$user->whereAdd('not exists (select user_id from inbox where user_id = user.id)');
|
||||
$user->orderBy('id');
|
||||
|
||||
if ($user->find()) {
|
||||
|
||||
while ($user->fetch()) {
|
||||
|
||||
try {
|
||||
$notice = new Notice();
|
||||
|
||||
$notice->selectAdd();
|
||||
$notice->selectAdd('id');
|
||||
$notice->joinAdd(array('profile_id', 'subscription:subscribed'));
|
||||
$notice->whereAdd('subscription.subscriber = ' . $user->id);
|
||||
$notice->whereAdd('notice.created >= subscription.created');
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ($notice->find()) {
|
||||
while ($notice->fetch()) {
|
||||
$ids[] = $notice->id;
|
||||
}
|
||||
}
|
||||
|
||||
$notice = null;
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->user_id = $user->id;
|
||||
$inbox->pack($ids);
|
||||
$inbox->insert();
|
||||
} catch (Exception $e) {
|
||||
printv("Error initializing inbox: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printfnq("DONE.\n");
|
||||
}
|
||||
|
||||
main();
|
||||
|
Reference in New Issue
Block a user