diff options
author | Mario Vavti <mario@mariovavti.com> | 2021-10-06 09:36:14 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2021-10-06 09:36:14 +0200 |
commit | c33660a015ff4a2ed387caa4064fc8c4d8655419 (patch) | |
tree | 42a3bf620a54713ffc584efeb7d0006e94189b13 /Zotlabs/Lib/Apps.php | |
parent | 16281e0e7fbc4ff691f6190ddc80632b411d2801 (diff) | |
download | volse-hubzilla-c33660a015ff4a2ed387caa4064fc8c4d8655419.tar.gz volse-hubzilla-c33660a015ff4a2ed387caa4064fc8c4d8655419.tar.bz2 volse-hubzilla-c33660a015ff4a2ed387caa4064fc8c4d8655419.zip |
move sync logic for apps to mod appman. this way we can re-use the functions without creating sync loops.
Diffstat (limited to 'Zotlabs/Lib/Apps.php')
-rw-r--r-- | Zotlabs/Lib/Apps.php | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 99c8144a6..2c5b8a546 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -3,7 +3,6 @@ namespace Zotlabs\Lib; use App; -use Zotlabs\Lib\Libsync; require_once('include/plugin.php'); require_once('include/channel.php'); @@ -627,10 +626,12 @@ class Apps { $app['uid'] = $uid; - if(self::app_installed($uid,$app,true)) + if(self::app_installed($uid,$app,true)) { $x = self::app_update($app); - else + } + else { $x = self::app_store($app); + } if($x['success']) { $r = q("select * from app where app_id = '%s' and app_channel = %d limit 1", @@ -645,12 +646,6 @@ class Apps { intval($r[0]['id']) ); } - if (intval($r[0]['app_system'])) { - Libsync::build_sync_packet($uid, ['sysapp' => $r]); - } - else { - Libsync::build_sync_packet($uid, ['app' => $r]); - } } } return $x['app_id']; @@ -690,45 +685,35 @@ class Apps { dbesc($app['guid']), intval($uid) ); - if($x) { - if(! intval($x[0]['app_deleted'])) { - $x[0]['app_deleted'] = 1; - if(self::can_delete($uid,$app)) { - q("delete from app where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); - q("delete from term where otype = %d and oid = %d", - intval(TERM_OBJ_APP), - intval($x[0]['id']) - ); - /** - * @hooks app_destroy - * Called after app entry got removed from database - * and provide app array from database. - */ - call_hooks('app_destroy', $x[0]); - } - else { - q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", - dbesc($app['guid']), - intval($uid) - ); - } - // unset the id before sync - unset($x[0]['id']); + if($x && intval($x[0]['app_deleted'])) { + self::app_undestroy($uid, $app); + return; + } - if (intval($x[0]['app_system'])) { - Libsync::build_sync_packet($uid, ['sysapp' => $x]); - } - else { - Libsync::build_sync_packet($uid, ['app' => $x]); - } - } - else { - self::app_undestroy($uid,$app); - } + if(self::can_delete($uid,$app)) { + q("delete from app where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); + + q("delete from term where otype = %d and oid = %d", + intval(TERM_OBJ_APP), + intval($x[0]['id']) + ); + + /** + * @hooks app_destroy + * Called after app entry got removed from database + * and provide app array from database. + */ + call_hooks('app_destroy', $x[0]); + } + else { + q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", + dbesc($app['guid']), + intval($uid) + ); } } } @@ -750,8 +735,6 @@ class Apps { dbesc($app['guid']), intval($uid) ); - $x[0]['app_deleted'] = 0; - Libsync::build_sync_packet($uid, ['sysapp' => $x]); } } } |