Merge pull request #3275 from pixelfed/staging

Staging
pull/3293/head
daniel 3 years ago committed by GitHub
commit 33eecb46e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,7 @@
- Updated ProfileController, redirect profile view for authed users to Metro 2.0 UI. ([7f8129a7](https://github.com/pixelfed/pixelfed/commit/7f8129a7)) - Updated ProfileController, redirect profile view for authed users to Metro 2.0 UI. ([7f8129a7](https://github.com/pixelfed/pixelfed/commit/7f8129a7))
- Updated SpaController, fix variable typo. Fixes #3268. ([8d1af1d6](https://github.com/pixelfed/pixelfed/commit/8d1af1d6)) - Updated SpaController, fix variable typo. Fixes #3268. ([8d1af1d6](https://github.com/pixelfed/pixelfed/commit/8d1af1d6))
- Updated ComposeModal, fix post redirect on old UI. ([160e32a5](https://github.com/pixelfed/pixelfed/commit/160e32a5)) - Updated ComposeModal, fix post redirect on old UI. ([160e32a5](https://github.com/pixelfed/pixelfed/commit/160e32a5))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - Updated LikeService, improve caching logic and add profile id to likedBy method to fix #3271. ([6af842eb](https://github.com/pixelfed/pixelfed/commit/6af842eb))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)

@ -14,22 +14,23 @@ class LikeService {
public static function add($profileId, $statusId) public static function add($profileId, $statusId)
{ {
$key = self::CACHE_KEY . $profileId . ':' . $statusId; $key = self::CACHE_KEY . $profileId . ':' . $statusId;
$ttl = now()->addHours(2); Cache::increment('pf:services:likes:count:'.$statusId);
return Cache::put($key, true, $ttl); Cache::forget('pf:services:likes:liked_by:'.$statusId);
return Cache::put($key, true, 86400);
} }
public static function remove($profileId, $statusId) public static function remove($profileId, $statusId)
{ {
$key = self::CACHE_KEY . $profileId . ':' . $statusId; $key = self::CACHE_KEY . $profileId . ':' . $statusId;
$ttl = now()->addHours(2); Cache::decrement('pf:services:likes:count:'.$statusId);
return Cache::put($key, false, $ttl); Cache::forget('pf:services:likes:liked_by:'.$statusId);
return Cache::put($key, false, 86400);
} }
public static function liked($profileId, $statusId) public static function liked($profileId, $statusId)
{ {
$key = self::CACHE_KEY . $profileId . ':' . $statusId; $key = self::CACHE_KEY . $profileId . ':' . $statusId;
$ttl = now()->addMinutes(30); return Cache::remember($key, 86400, function() use($profileId, $statusId) {
return Cache::remember($key, $ttl, function() use($profileId, $statusId) {
return Like::whereProfileId($profileId)->whereStatusId($statusId)->exists(); return Like::whereProfileId($profileId)->whereStatusId($statusId)->exists();
}); });
} }
@ -45,44 +46,36 @@ class LikeService {
return $empty; return $empty;
} }
if(!$status->likes_count) { $res = Cache::remember('pf:services:likes:liked_by:' . $status->id, 86400, function() use($status, $empty) {
return $empty; $like = Like::whereStatusId($status->id)->first();
}
$user = request()->user();
if($user) {
$like = Like::whereStatusId($status->id)
->where('profile_id', '!=', $user->profile_id)
->first();
} else {
$like = Like::whereStatusId($status->id)
->first();
}
if(!$like) { if(!$like) {
return $empty; return $empty;
} }
$id = $like->profile_id; $id = $like->profile_id;
$profile = ProfileService::get($id); $profile = ProfileService::get($id);
$profileUrl = $profile['local'] ? $profile['url'] : '/i/web/profile/_/' . $profile['id']; $profileUrl = "/i/web/profile/{$profile['id']}";
$res = [ $res = [
'id' => (string) $profile['id'],
'username' => $profile['username'], 'username' => $profile['username'],
'url' => $profileUrl, 'url' => $profileUrl,
'others' => $status->likes_count >= 3, 'others' => $status->likes_count >= 3,
]; ];
return $res;
});
if(!isset($res['id']) || !isset($res['url'])) {
return $empty;
}
if(request()->user() && request()->user()->profile_id == $status->profile_id) {
$res['total_count'] = ($status->likes_count - 1); $res['total_count'] = ($status->likes_count - 1);
$res['total_count_pretty'] = number_format($res['total_count']); $res['total_count_pretty'] = number_format($res['total_count']);
}
return $res; return $res;
} }
public static function count($id) public static function count($id)
{ {
return Like::whereStatusId($id)->count(); return Cache::get('pf:services:likes:count:'.$id, 0);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
(()=>{"use strict";var e,r,t,n={},o={};function s(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={id:e,loaded:!1,exports:{}};return n[e].call(t.exports,t,t.exports,s),t.loaded=!0,t.exports}s.m=n,e=[],s.O=(r,t,n,o)=>{if(!t){var a=1/0;for(c=0;c<e.length;c++){for(var[t,n,o]=e[c],i=!0,d=0;d<t.length;d++)(!1&o||a>=o)&&Object.keys(s.O).every((e=>s.O[e](t[d])))?t.splice(d--,1):(i=!1,o<a&&(a=o));if(i){e.splice(c--,1);var l=n();void 0!==l&&(r=l)}}return r}o=o||0;for(var c=e.length;c>0&&e[c-1][2]>o;c--)e[c]=e[c-1];e[c]=[t,n,o]},s.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return s.d(r,{a:r}),r},s.d=(e,r)=>{for(var t in r)s.o(r,t)&&!s.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((r,t)=>(s.f[t](e,r),r)),[])),s.u=e=>489===e?"js/home-chunk.js":680===e?"js/compose-chunk.js":214===e?"js/post-chunk.js":177===e?"js/profile-chunk.js":202===e?"js/dmym-chunk.js":931===e?"js/dmyh-chunk.js":554===e?"js/daci-chunk.js":895===e?"js/dffc-chunk.js":996===e?"js/dsfc-chunk.js":98===e?"js/dssc-chunk.js":void 0,s.miniCssF=e=>({138:"css/spa",170:"css/app",242:"css/appdark",703:"css/admin",994:"css/landing"}[e]+".css"),s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="pixelfed:",s.l=(e,n,o,a)=>{if(r[e])r[e].push(n);else{var i,d;if(void 0!==o)for(var l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var u=l[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==t+o){i=u;break}}i||(d=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,s.nc&&i.setAttribute("nonce",s.nc),i.setAttribute("data-webpack",t+o),i.src=e),r[e]=[n];var f=(t,n)=>{i.onerror=i.onload=null,clearTimeout(p);var o=r[e];if(delete r[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(n))),t)return t(n)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=f.bind(null,i.onerror),i.onload=f.bind(null,i.onload),d&&document.head.appendChild(i)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.p="/",(()=>{var e={929:0,242:0,170:0,138:0,703:0,994:0};s.f.j=(r,t)=>{var n=s.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(138|170|242|703|929|994)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=s.p+s.u(r),i=new Error;s.l(a,(t=>{if(s.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+o+": "+a+")",i.name="ChunkLoadError",i.type=o,i.request=a,n[1](i)}}),"chunk-"+r,r)}},s.O.j=r=>0===e[r];var r=(r,t)=>{var n,o,[a,i,d]=t,l=0;if(a.some((r=>0!==e[r]))){for(n in i)s.o(i,n)&&(s.m[n]=i[n]);if(d)var c=d(s)}for(r&&r(t);l<a.length;l++)o=a[l],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return s.O(c)},t=self.webpackChunkpixelfed=self.webpackChunkpixelfed||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})(); (()=>{"use strict";var e,t,r,s={},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={id:e,loaded:!1,exports:{}};return s[e].call(r.exports,r,r.exports,o),r.loaded=!0,r.exports}o.m=s,e=[],o.O=(t,r,s,n)=>{if(!r){var a=1/0;for(c=0;c<e.length;c++){for(var[r,s,n]=e[c],i=!0,d=0;d<r.length;d++)(!1&n||a>=n)&&Object.keys(o.O).every((e=>o.O[e](r[d])))?r.splice(d--,1):(i=!1,n<a&&(a=n));if(i){e.splice(c--,1);var l=s();void 0!==l&&(t=l)}}return t}n=n||0;for(var c=e.length;c>0&&e[c-1][2]>n;c--)e[c]=e[c-1];e[c]=[r,s,n]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,r)=>(o.f[r](e,t),t)),[])),o.u=e=>911===e?"js/home-chunk-1rptst.js":115===e?"js/compose-chunk-1rptst.js":2===e?"js/post-chunk-1rptst.js":100===e?"js/profile-chunk-1rptst.js":336===e?"js/dmym-chunk-1rptst.js":566===e?"js/dmyh-chunk-1rptst.js":270===e?"js/daci-chunk-1rptst.js":506===e?"js/dffc-chunk-1rptst.js":827===e?"js/dsfc-chunk-1rptst.js":319===e?"js/dssc-chunk-1rptst.js":void 0,o.miniCssF=e=>({138:"css/spa",170:"css/app",242:"css/appdark",703:"css/admin",994:"css/landing"}[e]+".css"),o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="pixelfed:",o.l=(e,s,n,a)=>{if(t[e])t[e].push(s);else{var i,d;if(void 0!==n)for(var l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var u=l[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+n){i=u;break}}i||(d=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,o.nc&&i.setAttribute("nonce",o.nc),i.setAttribute("data-webpack",r+n),i.src=e),t[e]=[s];var p=(r,s)=>{i.onerror=i.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),n&&n.forEach((e=>e(s))),r)return r(s)},f=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),d&&document.head.appendChild(i)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),o.p="/",(()=>{var e={929:0,242:0,170:0,138:0,703:0,994:0};o.f.j=(t,r)=>{var s=o.o(e,t)?e[t]:void 0;if(0!==s)if(s)r.push(s[2]);else if(/^(138|170|242|703|929|994)$/.test(t))e[t]=0;else{var n=new Promise(((r,n)=>s=e[t]=[r,n]));r.push(s[2]=n);var a=o.p+o.u(t),i=new Error;o.l(a,(r=>{if(o.o(e,t)&&(0!==(s=e[t])&&(e[t]=void 0),s)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",i.name="ChunkLoadError",i.type=n,i.request=a,s[1](i)}}),"chunk-"+t,t)}},o.O.j=t=>0===e[t];var t=(t,r)=>{var s,n,[a,i,d]=r,l=0;if(a.some((t=>0!==e[t]))){for(s in i)o.o(i,s)&&(o.m[s]=i[s]);if(d)var c=d(o)}for(t&&t(r);l<a.length;l++)n=a[l],o.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return o.O(c)},r=self.webpackChunkpixelfed=self.webpackChunkpixelfed||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})()})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
public/js/spa.js vendored

File diff suppressed because one or more lines are too long

@ -20,19 +20,19 @@
"/js/admin.js": "/js/admin.js?id=84492883e1542f8438b48dcf187fc07b", "/js/admin.js": "/js/admin.js?id=84492883e1542f8438b48dcf187fc07b",
"/js/rempro.js": "/js/rempro.js?id=995a5afd9188be6ad2b41114d3a8e7ee", "/js/rempro.js": "/js/rempro.js?id=995a5afd9188be6ad2b41114d3a8e7ee",
"/js/rempos.js": "/js/rempos.js?id=0685e23f4bbfbcb99bb30ecabb837270", "/js/rempos.js": "/js/rempos.js?id=0685e23f4bbfbcb99bb30ecabb837270",
"/js/spa.js": "/js/spa.js?id=b6352f409e13c6367ad27f023e6fa43c", "/js/spa.js": "/js/spa.js?id=d7e932b30fdc4dcd5938563473ed2983",
"/js/stories.js": "/js/stories.js?id=048de600ee6dfccaeaf06070999cb892", "/js/stories.js": "/js/stories.js?id=048de600ee6dfccaeaf06070999cb892",
"/js/manifest.js": "/js/manifest.js?id=20ea2cd21e0b2ff06bad51215622a3c9", "/js/manifest.js": "/js/manifest.js?id=ab3ea8cc790ab95efb8d1e7cb6b7e385",
"/js/home-chunk.js": "/js/home-chunk.js?id=993a77c1df59059d03e994a606925b73", "/js/home-chunk-1rptst.js": "/js/home-chunk-1rptst.js?id=f472cd5312f25b13df9374ed399ef06d",
"/js/compose-chunk.js": "/js/compose-chunk.js?id=92c04b1086da61beb3e91a84ffc62341", "/js/compose-chunk-1rptst.js": "/js/compose-chunk-1rptst.js?id=f94df76eb01a4bec45bb8a3cadbfca21",
"/js/post-chunk.js": "/js/post-chunk.js?id=2da4520782ee4a1e2f20e52fa21da7a8", "/js/post-chunk-1rptst.js": "/js/post-chunk-1rptst.js?id=b5a855eabf5e1dfa69888b2f41d925be",
"/js/profile-chunk.js": "/js/profile-chunk.js?id=d8c43c8d9128269b166dfc9ef652f764", "/js/profile-chunk-1rptst.js": "/js/profile-chunk-1rptst.js?id=1949385bb758bb31cb6c23c4669b080d",
"/js/dmym-chunk.js": "/js/dmym-chunk.js?id=9c5dc1bf2f995b3da03280b0930277ee", "/js/dmym-chunk-1rptst.js": "/js/dmym-chunk-1rptst.js?id=b5663f0c6c5da994e323b2fbc608cedb",
"/js/dmyh-chunk.js": "/js/dmyh-chunk.js?id=dc6db286cabdc3b182ab90a49d919fd5", "/js/dmyh-chunk-1rptst.js": "/js/dmyh-chunk-1rptst.js?id=f3e372ec2cd55c40acffbb5aa9b76434",
"/js/daci-chunk.js": "/js/daci-chunk.js?id=e3b891be64726f5e83934769acf5c28f", "/js/daci-chunk-1rptst.js": "/js/daci-chunk-1rptst.js?id=c6db7a179ee257fb39283830ab52f9bb",
"/js/dffc-chunk.js": "/js/dffc-chunk.js?id=ee6d25f960df2f0c93308c488aa925e1", "/js/dffc-chunk-1rptst.js": "/js/dffc-chunk-1rptst.js?id=788a70be93fa5e360a626c521bb60969",
"/js/dsfc-chunk.js": "/js/dsfc-chunk.js?id=b02562d84709ef6933f39d1577161d2c", "/js/dsfc-chunk-1rptst.js": "/js/dsfc-chunk-1rptst.js?id=769b84e2ce37d42a2edf7767953f7e4c",
"/js/dssc-chunk.js": "/js/dssc-chunk.js?id=8f415c9302c65ab132f6cb50fc26a13c", "/js/dssc-chunk-1rptst.js": "/js/dssc-chunk-1rptst.js?id=413aba99458230f1a753a168183ca1fc",
"/css/appdark.css": "/css/appdark.css?id=a661085d048e4e6b953ba58086d34007", "/css/appdark.css": "/css/appdark.css?id=a661085d048e4e6b953ba58086d34007",
"/css/app.css": "/css/app.css?id=ef378884d2b1cf81e12851d2aab5089a", "/css/app.css": "/css/app.css?id=ef378884d2b1cf81e12851d2aab5089a",
"/css/spa.css": "/css/spa.css?id=c1320213cd53b5dbb38057e8054bb0db", "/css/spa.css": "/css/spa.css?id=c1320213cd53b5dbb38057e8054bb0db",

Loading…
Cancel
Save