YunoHost-Apps / mobilizon_ynh

A federated organization and mobilization platform for YunoHost
https://joinmobilizon.org/
GNU Affero General Public License v3.0
20 stars 9 forks source link

No image after a change of url #196

Open zamentur opened 4 months ago

zamentur commented 4 months ago

Describe the bug

After a changeurl from mobilizon.sans-nuage.fr to hoplagenda.fr, all image are unreachable.

Context

Steps to reproduce

yunohost app install mobilizon --args "domain=mobilizon.sans-nuage.fr"
yunohost app change-url mobilizon -d hoplagenda.fr -p /

Expected behavior

The change-url should edit the hardcoded url inside the database.

Logs

mobilizon=# select * from medias;
   id   |                                                                                                                                                                                                                                                            file                                                                                                                                                                                                                                                            |     inserted_at     |     updated_at      | actor_id |                                                                     metadata                                                                      
--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+----------+---------------------------------------------------------------------------------------------------------------------------------------------------
  88208 | {"id": "879dc8b0-c8ef-46f6-b2de-aef31f37c071", "url": "https://hoplagenda.fr/media/537a170f4a0175b9e21e94964869a8c98614be44cd5a7c83efb7b95535520408.jpg?name=banniere%20finale.jpg", "name": "banniere finale.jpg", "size": 1243224, "updated_at": "2023-05-07T18:07:03", "inserted_at": "2023-05-07T18:07:03", "content_type": "image/jpeg"}

Solution

UPDATE  medias SET file=REPLACE(file::text, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr')::jsonb;
UPDATE resource SET url=REPLACE(url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr');
DELETE FROM actors WHERE preferred_username='anonymous' and url LIKE '%https://mobilizon.sans-nuage.fr%';
UPDATE actors SET 
url=REPLACE(url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
inbox_url=REPLACE(inbox_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
outbox_url=REPLACE(outbox_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
following_url=REPLACE(following_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
followers_url=REPLACE(followers_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
shared_inbox_url=REPLACE(shared_inbox_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
avatar=REPLACE(avatar::text, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr')::jsonb,
banner=REPLACE(banner::text, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr')::jsonb,
members_url=REPLACE(members_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
resources_url=REPLACE(resources_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
todos_url=REPLACE(todos_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
posts_url=REPLACE(posts_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
events_url=REPLACE(events_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr'),
discussions_url=REPLACE(discussions_url, 'https://mobilizon.sans-nuage.fr', 'https://hoplagenda.fr');