• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

divviup / divviup-api / 7226558048

15 Dec 2023 08:18PM UTC coverage: 56.347% (+0.03%) from 56.316%
7226558048

push

github

GitHub
upgrade deps and add type: module for new version of vite (#690)

3542 of 6286 relevant lines covered (56.35%)

128.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.5
/src/queue/job/v1/send_invitation_email.rs
1
use crate::{
2
    entity::*,
3
    queue::{EnqueueJob, Job, JobError, SharedJobState, V1},
4
};
5
use sea_orm::{ConnectionTrait, EntityTrait};
6
use serde::{Deserialize, Serialize};
7
use serde_json::json;
8
use url::Url;
9
use uuid::Uuid;
10

11
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
28✔
12
pub struct SendInvitationEmail {
13
    pub membership_id: Uuid,
14
    pub action_url: Url,
15
    pub message_id: Uuid,
16
}
17

18
impl SendInvitationEmail {
19
    pub async fn perform(
2✔
20
        &mut self,
2✔
21
        job_state: &SharedJobState,
2✔
22
        db: &impl ConnectionTrait,
2✔
23
    ) -> Result<Option<EnqueueJob>, JobError> {
2✔
24
        let (membership, account) = Memberships::find_by_id(self.membership_id)
2✔
25
            .find_also_related(Accounts)
2✔
26
            .one(db)
2✔
27
            .await?
×
28
            .ok_or_else(|| {
2✔
29
                JobError::MissingRecord(String::from("membership"), self.membership_id.to_string())
×
30
            })?;
2✔
31

32
        let account = account.ok_or_else(|| {
2✔
33
            JobError::MissingRecord(String::from("account"), membership.account_id.to_string())
×
34
        })?;
2✔
35

36
        job_state
2✔
37
            .postmark_client
2✔
38
            .send_email_template(
2✔
39
                &membership.user_email,
2✔
40
                "user-invitation",
2✔
41
                &json!({
2✔
42
                    "email": membership.user_email,
2✔
43
                    "account_name": &account.name,
2✔
44
                    "action_url": self.action_url
2✔
45
                }),
2✔
46
                Some(self.message_id.to_string()),
2✔
47
            )
2✔
48
            .await?;
1✔
49

50
        Ok(None)
2✔
51
    }
2✔
52
}
53

54
impl From<SendInvitationEmail> for Job {
55
    fn from(value: SendInvitationEmail) -> Self {
3✔
56
        Self::V1(V1::SendInvitationEmail(value))
3✔
57
    }
3✔
58
}
59
impl PartialEq<Job> for SendInvitationEmail {
60
    fn eq(&self, other: &Job) -> bool {
×
61
        matches!(other, Job::V1(V1::SendInvitationEmail(j)) if j == self)
×
62
    }
×
63
}
64

65
impl PartialEq<SendInvitationEmail> for Job {
66
    fn eq(&self, other: &SendInvitationEmail) -> bool {
×
67
        matches!(self, Job::V1(V1::SendInvitationEmail(j)) if j == other)
×
68
    }
×
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc