Merge branch 'dev' of ../p3 into dev

This commit is contained in:
nobody 2020-09-14 19:23:58 -07:00
commit b24e0140af
3 changed files with 54 additions and 39 deletions

View file

@ -174,27 +174,10 @@ class Poller {
}
}
if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
$r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last <= '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ",
intval(UPDATE_FLAGS_UPDATED),
dbesc(NULL_DATE),
db_utcnow(), db_quoteinterval('7 DAY')
);
if($r) {
foreach($r as $rr) {
// migrate a few photos - eventually we'll migrate them all but without killing somebody's site
// trying to do them all at once
// If they didn't respond when we attempted before, back off to once a day
// After 7 days we won't bother anymore
if($rr['ud_last'] > NULL_DATE)
if($rr['ud_last'] > datetime_convert('UTC','UTC', 'now - 1 day'))
continue;
Run::Summon(array('Onedirsync',$rr['ud_id']));
if($interval)
@time_sleep_until(microtime(true) + (float) $interval);
}
}
}
migrate_xchan_photos(5);
set_config('system','lastpoll',datetime_convert());

View file

@ -422,25 +422,29 @@ class Libprofile {
if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] );
$ob_hash = get_observer_hash();
if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) {
$profile['canlike'] = true;
$profile['likethis'] = t('Like this channel');
$profile['profile_guid'] = App::$profile['profile_guid'];
}
$likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'",
intval(App::$profile['profile_uid']),
dbesc(ACTIVITY_OBJ_PROFILE),
dbesc(ACTIVITY_LIKE)
);
$profile['likers'] = array();
$profile['like_count'] = count($likers);
$profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun');
if($likers) {
foreach($likers as $l)
$profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url']));
}
$ob_hash = get_observer_hash();
// this may not work at all any more, but definitely won't work correctly if the liked profile belongs to a group
// comment out until we are able to look at it much closer
// if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) {
// $profile['canlike'] = true;
// $profile['likethis'] = t('Like this channel');
// $profile['profile_guid'] = App::$profile['profile_guid'];
// }
// $likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'",
// intval(App::$profile['profile_uid']),
// dbesc(ACTIVITY_OBJ_PROFILE),
// dbesc(ACTIVITY_LIKE)
// );
// $profile['likers'] = array();
// $profile['like_count'] = count($likers);
// $profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun');
// if($likers) {
// foreach($likers as $l)
// $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url']));
// }
if((App::$profile['dob']) && (App::$profile['dob'] != '0000-00-00')) {

View file

@ -298,6 +298,34 @@ function xchan_change_key($oldx,$newx,$data) {
}
function migrate_xchan_photos($limit = 100) {
$r = q("select xchan_photo_l, xchan_hash, photo.xchan, photo.resource_id from photo left join xchan on photo.xchan = xchan_hash where photo.xchan != '' and uid = 0 and imgscale = 4 and photo_usage = 2 and xchan_photo_l like ('%s') limit %d",
dbesc(z_root() . '/photo/%'),
intval($limit)
);
if ($r) {
foreach ($r as $rv) {
logger('migrating xchan_photo for ' . $rv['xchan_hash']);
$photos = import_remote_xchan_photo($rv['xchan_photo_l'], $rv['xchan_hash']);
if ($photos) {
$r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
where xchan_hash = '%s'",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
dbesc($photos[3]),
dbesc($rv['xchan_hash'])
);
}
}
}
}
function cleanup_xchan_photos() {
$r = q("select photo.xchan, photo.resource_id from photo left join xchan on photo.xchan = xchan_hash where photo.xchan != '' and uid = 0 and imgscale = 4 and photo_usage = 2 and xchan_photo_l like ('%s') limit 500",