Fix type and name on Mail::send sender ID argument
This commit is contained in:
parent
0a5e3c75dc
commit
3d4e11045a
1 changed files with 9 additions and 8 deletions
|
@ -117,6 +117,7 @@ class Mail
|
||||||
/**
|
/**
|
||||||
* Send private message
|
* Send private message
|
||||||
*
|
*
|
||||||
|
* @param integer $sender_uid the user id of the sender, default 0
|
||||||
* @param integer $recipient recipient id, default 0
|
* @param integer $recipient recipient id, default 0
|
||||||
* @param string $body message body, default empty
|
* @param string $body message body, default empty
|
||||||
* @param string $subject message subject, default empty
|
* @param string $subject message subject, default empty
|
||||||
|
@ -124,7 +125,7 @@ class Mail
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function send(string $uid, int $recipient = 0, string $body = '', string $subject = '', string $replyto = ''): int
|
public static function send(int $sender_uid = 0, int $recipient = 0, string $body = '', string $subject = '', string $replyto = ''): int
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
|
||||||
|
@ -136,12 +137,12 @@ class Mail
|
||||||
$subject = DI::l10n()->t('[no subject]');
|
$subject = DI::l10n()->t('[no subject]');
|
||||||
}
|
}
|
||||||
|
|
||||||
$me = DBA::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
|
$me = DBA::selectFirst('contact', [], ['uid' => $sender_uid, 'self' => true]);
|
||||||
if (!DBA::isResult($me)) {
|
if (!DBA::isResult($me)) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contacts = ACL::getValidMessageRecipientsForUser($uid);
|
$contacts = ACL::getValidMessageRecipientsForUser($sender_uid);
|
||||||
|
|
||||||
$contactIndex = array_search($recipient, array_column($contacts, 'id'));
|
$contactIndex = array_search($recipient, array_column($contacts, 'id'));
|
||||||
if ($contactIndex === false) {
|
if ($contactIndex === false) {
|
||||||
|
@ -150,7 +151,7 @@ class Mail
|
||||||
|
|
||||||
$contact = $contacts[$contactIndex];
|
$contact = $contacts[$contactIndex];
|
||||||
|
|
||||||
Photo::setPermissionFromBody($body, $uid, $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
Photo::setPermissionFromBody($body, $sender_uid, $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
||||||
|
|
||||||
$guid = System::createUUID();
|
$guid = System::createUUID();
|
||||||
$uri = Item::newURI($guid);
|
$uri = Item::newURI($guid);
|
||||||
|
@ -163,7 +164,7 @@ class Mail
|
||||||
if (strlen($replyto)) {
|
if (strlen($replyto)) {
|
||||||
$reply = true;
|
$reply = true;
|
||||||
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
||||||
$uid, $replyto, $replyto];
|
$sender_uid, $replyto, $replyto];
|
||||||
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
||||||
if (DBA::isResult($mail)) {
|
if (DBA::isResult($mail)) {
|
||||||
$convid = $mail['convid'];
|
$convid = $mail['convid'];
|
||||||
|
@ -176,7 +177,7 @@ class Mail
|
||||||
$conv_guid = System::createUUID();
|
$conv_guid = System::createUUID();
|
||||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||||
|
|
||||||
$fields = ['uid' => $uid, 'guid' => $conv_guid, 'creator' => $me['addr'],
|
$fields = ['uid' => $sender_uid, 'guid' => $conv_guid, 'creator' => $me['addr'],
|
||||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||||
if (DBA::insert('conv', $fields)) {
|
if (DBA::insert('conv', $fields)) {
|
||||||
|
@ -195,7 +196,7 @@ class Mail
|
||||||
|
|
||||||
$post_id = self::insert(
|
$post_id = self::insert(
|
||||||
[
|
[
|
||||||
'uid' => $uid,
|
'uid' => $sender_uid,
|
||||||
'guid' => $guid,
|
'guid' => $guid,
|
||||||
'convid' => $convid,
|
'convid' => $convid,
|
||||||
'from-name' => $me['name'],
|
'from-name' => $me['name'],
|
||||||
|
@ -232,7 +233,7 @@ class Mail
|
||||||
foreach ($images as $image) {
|
foreach ($images as $image) {
|
||||||
$image_rid = Photo::ridFromURI($image);
|
$image_rid = Photo::ridFromURI($image);
|
||||||
if (!empty($image_rid)) {
|
if (!empty($image_rid)) {
|
||||||
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => $uid]);
|
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => $sender_uid]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue