Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93896270
PhabricatorAuthInviteWorker.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 2, 08:25
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 08:25 (2 d)
Engine
blob
Format
Raw Data
Handle
22674425
Attached To
rPH Phabricator
PhabricatorAuthInviteWorker.php
View Options
<?php
final
class
PhabricatorAuthInviteWorker
extends
PhabricatorWorker
{
protected
function
doWork
()
{
$data
=
$this
->
getTaskData
();
$viewer
=
PhabricatorUser
::
getOmnipotentUser
();
$address
=
idx
(
$data
,
'address'
);
$author_phid
=
idx
(
$data
,
'authorPHID'
);
$author
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$author_phid
))
->
executeOne
();
if
(!
$author
)
{
throw
new
PhabricatorWorkerPermanentFailureException
(
pht
(
'Invite has invalid author PHID ("%s").'
,
$author_phid
));
}
$invite
=
id
(
new
PhabricatorAuthInviteQuery
())
->
setViewer
(
$viewer
)
->
withEmailAddresses
(
array
(
$address
))
->
executeOne
();
if
(
$invite
)
{
// If we're inviting a user who has already been invited, we just
// regenerate their invite code.
$invite
->
regenerateVerificationCode
();
}
else
{
// Otherwise, we're creating a new invite.
$invite
=
id
(
new
PhabricatorAuthInvite
())
->
setEmailAddress
(
$address
);
}
// Whether this is a new invite or not, tag this most recent author as
// the invite author.
$invite
->
setAuthorPHID
(
$author_phid
);
$code
=
$invite
->
getVerificationCode
();
$invite_uri
=
'/auth/invite/'
.
$code
.
'/'
;
$invite_uri
=
PhabricatorEnv
::
getProductionURI
(
$invite_uri
);
$template
=
idx
(
$data
,
'template'
);
$template
=
str_replace
(
'{$INVITE_URI}'
,
$invite_uri
,
$template
);
$invite
->
save
();
$mail
=
id
(
new
PhabricatorMetaMTAMail
())
->
addRawTos
(
array
(
$invite
->
getEmailAddress
()))
->
setForceDelivery
(
true
)
->
setSubject
(
pht
(
'[Phabricator] %s has invited you to join Phabricator'
,
$author
->
getFullName
()))
->
setBody
(
$template
)
->
saveAndSend
();
}
}
Event Timeline
Log In to Comment