humhub / legal

3 stars 8 forks source link

WIP Implementation of Jobs #71

Closed ArchBlood closed 1 month ago

ArchBlood commented 7 months ago

This is currently a WIP for implementing the Export into a Job

resolves #70

ArchBlood commented 7 months ago

The more I look at this, if I implement an ActiveJob it would be better to do this through a service and have the controller be the in between entry point for both, I'll look into this more later this weekend.

luke- commented 7 months ago

If you want, Yura or I could also have a look at the topic. However, I'm a bit short on time at the moment. But I would like to push this feature... :-)

ArchBlood commented 7 months ago

If you want, Yura or I could also have a look at the topic. However, I'm a bit short on time at the moment. But I would like to push this feature... :-)

That would be of great help, currently with services being new to HumHub I haven't had much time to look over the possibilities of implementation for such a thing, but the more help the better for all. 👍🏻

ArchBlood commented 7 months ago

I've moved all methods to get user data over to the service class which cleans up the controller class, the current method still works as it did before, overall this method should make it much easier to implement an active job as well as preparing everything to be achieved in a ZIP format.

ArchBlood commented 7 months ago

There seems to be no simple way of removing the comments data from getPostData() that I've found, I've tried usinga unset() method and an array_filter() and neither worked. 🤔

ArchBlood commented 7 months ago

@luke- would it be okay if we made metadata from the Content API configurable?

I was thinking about something like this;

    public static function getContent($content, $options = [])
    {
        $defaults = [
            'includeComments' => true,
            'includeLikes' => true,
            'includeTopics' => true,
            'includeFiles' => true,
        ];

        $options = array_merge($defaults, $options);

        $contentData = [
            'id' => $content->id,
            'metadata' => static::getContentMetadata($content),
        ];

        if ($options['includeComments']) {
            $contentData['comments'] = CommentDefinitions::getCommentsSummary($content);
        }

        if ($options['includeLikes']) {
            $contentData['likes'] = LikeDefinitions::getLikesSummary($content);
        }

        if ($options['includeTopics']) {
            $contentData['topics'] = static::getTopics($content);
        }

        if ($options['includeFiles']) {
            $contentData['files'] = FileDefinitions::getFiles($content);
        }

        return $contentData;
    }
luke- commented 7 months ago

@ArchBlood I'm not sure here, I would prefer that the legal export module to filter out the comments & links at the end.

ArchBlood commented 7 months ago

@ArchBlood I'm not sure here, I would prefer that the legal export module to filter out the comments & links at the end.

I've created the following possibilities;

As for the ActiveJob I'm still unable to create this possibility so I'd like to hand that part off to someone else that has more experience with implementing such a function if possible.

Note: I didn't touch total as I don't think it needs to be filtered just known

ArchBlood commented 7 months ago

@luke- I've implemented logic into the Job, it now creates the userdata.json in @runtime\exportedData\user_{id}, all that's needed is to update the controller, specifically the actionDownload() function, so that it works as needed.

All userdata.json files are set to be deleted after a month, but this can be changed to a preferred date.

ArchBlood commented 6 months ago

@yurabakhtin whenever you have the time, can you look over the Job class implementation to see if you're able to get the exporting to work? I'm still unable to get this part in working order. 😅

ArchBlood commented 1 month ago

@luke- I presume that I can close this?

luke- commented 1 month ago

@ArchBlood Yes, thanks! Great approach using the REST API data definitions!