Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiry date #99

Open
rehacan opened this issue Apr 27, 2023 · 1 comment
Open

Expiry date #99

rehacan opened this issue Apr 27, 2023 · 1 comment

Comments

@rehacan
Copy link

rehacan commented Apr 27, 2023

Hi,

I'm using this script in my poll. Generating poll address for customers auto login and text message to mobile. Everything ok when i create new one. But when the expire the link, i need to update sometimes the link lifetime.. I research the database and i found in magic_links table, available_at column. I tried update this column data but still cannot open the poll. Bcos, the link is dead. What should i do?

edit: i checked again for available_at column change:
first; i created new link for poll. Expire date 40 days later and i changed date today and i gave 1 hour for expire and work again. when i change it expired time, its forwarded to expired page and i changed 1 hour later again but its not working. I mean, if any link expired and visited expired link, then its not working anymore..

@rehacan
Copy link
Author

rehacan commented Apr 28, 2023

I found the solution.

src\MagicLink.php

change this function
public static function deleteMagicLinkExpired() { static::where(function ($query) { $query ->where('available_at', '<', Carbon::now()) ->orWhere(function ($query) { $query ->whereNotNull('max_visits') ->whereRaw('max_visits <= num_visits'); }); }) ->delete(); }

to this

`public static function deleteMagicLinkExpired()
{
$expiredMagicLinks = static::where(function ($query) {
$query
->where('available_at', '<', Carbon::now())
->orWhere(function ($query) {
$query
->whereNotNull('max_visits')
->whereRaw('max_visits <= num_visits');
});
})->get();

    foreach ($expiredMagicLinks as $magiclink) {
        // Delete from scroll short_urls containing control_id before magic link delete
        $controlId = substr($magiclink->id, 0, 10); // First 10 characters of magic link id contain control_id
        ShortUrl::where('destination_url', 'like', '%' . $controlId . '%')->delete();

        // Magic linki sil
        $magiclink->delete();
    }
}`

and the solution, if expired magic links is deleting, then have to delete short_urls too..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant