Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78654025
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
Thu, Aug 22, 05:14
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Aug 24, 05:14 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20079769
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