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

Skip logged-in user for sending emails #117

Open
fabiodrg opened this issue Apr 1, 2022 · 0 comments
Open

Skip logged-in user for sending emails #117

fabiodrg opened this issue Apr 1, 2022 · 0 comments
Labels
enhancement New feature or request extractor::mailto

Comments

@fabiodrg
Copy link
Collaborator

fabiodrg commented Apr 1, 2022

Motivation

No, I don't want to email myself 😄

image

Testing if a user is logged in?

document.querySelector('a.nomelogin')

If null, it is not. Otherwise, the returned element will be <a>. Get the href attribute and parse the query parameter pct_id=<other_id>. The complete URL looks like this: https://sigarra.up.pt/feup/pt/vld_entidades_geral.entidade_pagina?pct_id=<other_id>
image

Getting the real user-id

For whatever reason, the ID used in the logged in user does not match the actual user identifier. It will be necessary to make a GET request for that hyperlink. The response is actually a redirect, notice the <meta http-equiv="Refresh">:

For students:

<html><head>
<meta http-equiv="Refresh" content="0;url=https://sigarra.up.pt/feup/pt/fest_geral.cursos_list?pv_num_unico=<id>">
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta name="ROBOTS" content="NOINDEX">

<a href="https://sigarra.up.pt/feup/pt/fest_geral.cursos_list?pv_num_unico=<id>"></a>
</head><body></body></html>

For staff:

<html><head>
<meta http-equiv="Refresh" content="0;url=https://sigarra.up.pt/feup/pt/func_geral.formview?p_codigo=<id>">
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta name="ROBOTS" content="NOINDEX">

<a href="https://sigarra.up.pt/feup/pt/func_geral.formview?p_codigo=<id>"></a>
</head><body></body></html>

Given the response, perhaps use the DOMParser and then make a query selector for <a> and parse the href.

Caching

It will be helpful to store a mapping of other_id to id to prevent requests on every new page load.

@fabiodrg fabiodrg added enhancement New feature or request extractor::mailto labels Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request extractor::mailto
Projects
None yet
Development

No branches or pull requests

1 participant