Merge branch 'dev' into release

This commit is contained in:
nobody 2022-03-17 17:08:34 -07:00
commit 73c1e57619
7 changed files with 812 additions and 785 deletions

View file

@ -201,7 +201,7 @@ class Import extends Controller
logger('import step 2'); logger('import step 2');
if (array_key_exists('channel', $data)) { if (array_key_exists('channel', $data)) {
if ($data['photo']) { if (isset($data['photo']) && $data['photo']) {
import_channel_photo(base64url_decode($data['photo']['data']), $data['photo']['type'], $account_id, $channel['channel_id']); import_channel_photo(base64url_decode($data['photo']['data']), $data['photo']['type'], $account_id, $channel['channel_id']);
} }

View file

@ -16,7 +16,7 @@ class Cover_photo
$o = ''; $o = '';
if (App::$module == 'channel' && $_REQUEST['mid']) { if (App::$module === 'channel' && $_REQUEST['mid']) {
return ''; return '';
} }
@ -83,19 +83,18 @@ class Cover_photo
$subtitle = ''; $subtitle = '';
} }
$c = Channel::get_cover_photo($channel_id, 'html'); $c = Channel::get_cover_photo($channel_id, 'array');
if ($c) { if ($c) {
$c = str_replace('src=', 'data-src=', $c); $o = replace_macros(Theme::get_template('cover_photo_widget.tpl'), [
$photo_html = (($style) ? str_replace('alt=', ' style="' . $style . '" alt=', $c) : $c); '$photo' => $c,
'$style' => $style,
$o = replace_macros(Theme::get_template('cover_photo_widget.tpl'), array( '$alt' => t('cover photo'),
'$photo_html' => $photo_html,
'$title' => $title, '$title' => $title,
'$subtitle' => $subtitle, '$subtitle' => $subtitle,
'$hovertitle' => t('Click to show more'), '$hovertitle' => t('Click to show more'),
'$hide_cover' => $hide_cover '$hide_cover' => $hide_cover
)); ]);
} }
return $o; return $o;
} }

View file

@ -1452,7 +1452,7 @@ function sync_files($channel, $files)
if (! $f) { if (! $f) {
continue; continue;
} }
$is_profile_photo = false;
$fetch_url = $f['fetch_url']; $fetch_url = $f['fetch_url'];
$oldbase = dirname($fetch_url); $oldbase = dirname($fetch_url);
@ -1660,6 +1660,7 @@ function sync_files($channel, $files)
logger('attachment store failed', LOGGER_NORMAL, LOG_ERR); logger('attachment store failed', LOGGER_NORMAL, LOG_ERR);
} }
if ($f['photo']) { if ($f['photo']) {
$is_profile_photo = false;
foreach ($f['photo'] as $p) { foreach ($f['photo'] as $p) {
unset($p['id']); unset($p['id']);
$p['aid'] = $channel['channel_account_id']; $p['aid'] = $channel['channel_account_id'];
@ -1674,6 +1675,7 @@ function sync_files($channel, $files)
// for any other photo which previously held it. // for any other photo which previously held it.
if ($p['photo_usage'] == PHOTO_PROFILE) { if ($p['photo_usage'] == PHOTO_PROFILE) {
$is_profile_photo = true;
$e = q( $e = q(
"update photo set photo_usage = %d where photo_usage = %d "update photo set photo_usage = %d where photo_usage = %d
and resource_id != '%s' and uid = %d ", and resource_id != '%s' and uid = %d ",
@ -1748,6 +1750,7 @@ function sync_files($channel, $files)
} }
} }
if (!isset($p['display_path'])) { if (!isset($p['display_path'])) {
$p['display_path'] = ''; $p['display_path'] = '';
} }
@ -1778,7 +1781,16 @@ function sync_files($channel, $files)
} }
} }
} }
if ($is_profile_photo) {
// set this or the next channel refresh will wipe out the profile photo with one that's fetched remotely
// and lacks the file context; as we probably didn't receive an xchan record in the sync packet
q("update xchan set xchan_photo_date = '%s' where xchan_hash = '%s'",
dbesc(datetime_convert()),
dbesc($channel['channel_hash'])
);
}
Run::Summon([ 'Thumbnail' , $att['hash'] ]); Run::Summon([ 'Thumbnail' , $att['hash'] ]);
if ($f['item']) { if ($f['item']) {

View file

@ -516,7 +516,8 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
} }
$post = item_store($arr,$allow_code,$deliver); $post = item_store($arr,$allow_code,$deliver);
$post_id = 0;
if($post['success']) { if($post['success']) {
$post_id = $post['item_id']; $post_id = $post['item_id'];
$ret['success'] = true; $ret['success'] = true;
@ -529,14 +530,13 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
* * \e array - the item returned from item_store() * * \e array - the item returned from item_store()
*/ */
Hook::call('post_local_end', $ret['activity']); Hook::call('post_local_end', $ret['activity']);
} sync_an_item($channel ? $channel['channel_id'] : $arr['uid'], $post_id);
}
if($post_id && $deliver) { if($post_id && $deliver) {
Run::Summon([ 'Notifier','activity',$post_id ]); Run::Summon([ 'Notifier','activity',$post_id ]);
} }
$ret['success'] = true;
return $ret; return $ret;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,2 @@
<?php <?php
define ( 'STD_VERSION', '22.03.15' ); define ( 'STD_VERSION', '22.03.18' );

View file

@ -16,7 +16,7 @@
} }
$('#cover-photo').removeClass('d-none'); $('#cover-photo').removeClass('d-none');
cover_height = Math.ceil($(window).width()/1.77777778); cover_height = calc_height();
$('#cover-photo').css('height', cover_height + 'px'); $('#cover-photo').css('height', cover_height + 'px');
datasrc2src('#cover-photo > img'); datasrc2src('#cover-photo > img');
@ -52,7 +52,7 @@
}); });
$(window).resize(function () { $(window).resize(function () {
cover_height = Math.ceil($(window).width()/1.77777778) cover_height = calc_height();
$('#cover-photo').css('height', cover_height + 'px'); $('#cover-photo').css('height', cover_height + 'px');
if($(window).width() < 755) { if($(window).width() < 755) {
$('#cover-photo').remove(); $('#cover-photo').remove();
@ -63,6 +63,11 @@
}); });
function calc_height() {
if (! ({{$photo.height}} && {{$photo.height}} )) return Math.ceil($(window).width()/1.77777778);
return Math.ceil( $(window).width() / ( {{$photo.width}} / {{$photo.height}}));
}
function slideUpCover() { function slideUpCover() {
if(coverSlid) { if(coverSlid) {
return; return;
@ -95,7 +100,7 @@
</script> </script>
<div class="d-none" id="cover-photo" title="{{$hovertitle}}"> <div class="d-none" id="cover-photo" title="{{$hovertitle}}">
{{$photo_html}} <img class="zrl" width="{{$photo.width}}" height="{{$photo.height}}" data-src="{{$photo.url}}" alt="{{$alt}}" style="{{$style}}" >;
<div id="cover-photo-caption"> <div id="cover-photo-caption">
<h1>{{$title}}</h1> <h1>{{$title}}</h1>
<h3>{{$subtitle}}</h3> <h3>{{$subtitle}}</h3>