mirror of
https://github.com/friendica/friendica
synced 2025-04-22 09:10:10 +00:00
Merge pull request #10530 from annando/api-mail
API: Support for fetching mails with more "statuses" calls
This commit is contained in:
commit
72ab57f067
3 changed files with 34 additions and 15 deletions
|
@ -50,25 +50,39 @@ class Context extends BaseApi
|
|||
|
||||
$id = $parameters['id'];
|
||||
|
||||
$parent = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
|
||||
if (!DBA::isResult($parent)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
$parents = [];
|
||||
$children = [];
|
||||
|
||||
$posts = Post::selectPosts(['uri-id', 'thr-parent-id'],
|
||||
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]], []);
|
||||
while ($post = Post::fetch($posts)) {
|
||||
if ($post['uri-id'] == $post['thr-parent-id']) {
|
||||
continue;
|
||||
}
|
||||
$parents[$post['uri-id']] = $post['thr-parent-id'];
|
||||
$parent = Post::selectFirst(['parent-uri-id'], ['uri-id' => $id]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$posts = Post::selectPosts(['uri-id', 'thr-parent-id'],
|
||||
['parent-uri-id' => $parent['parent-uri-id'], 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]]);
|
||||
while ($post = Post::fetch($posts)) {
|
||||
if ($post['uri-id'] == $post['thr-parent-id']) {
|
||||
continue;
|
||||
}
|
||||
$parents[$post['uri-id']] = $post['thr-parent-id'];
|
||||
|
||||
$children[$post['thr-parent-id']][] = $post['uri-id'];
|
||||
$children[$post['thr-parent-id']][] = $post['uri-id'];
|
||||
}
|
||||
DBA::close($posts);
|
||||
} else {
|
||||
$parent = DBA::selectFirst('mail', ['parent-uri-id'], ['uri-id' => $id, 'uid' => $uid]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$posts = DBA::select('mail', ['uri-id', 'thr-parent-id'], ['parent-uri-id' => $parent['parent-uri-id']]);
|
||||
while ($post = DBA::fetch($posts)) {
|
||||
if ($post['uri-id'] == $post['thr-parent-id']) {
|
||||
continue;
|
||||
}
|
||||
$parents[$post['uri-id']] = $post['thr-parent-id'];
|
||||
|
||||
$children[$post['thr-parent-id']][] = $post['uri-id'];
|
||||
}
|
||||
DBA::close($posts);
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
}
|
||||
DBA::close($posts);
|
||||
|
||||
$statuses = ['ancestors' => [], 'descendants' => []];
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class Direct extends BaseApi
|
|||
$params['order'] = ['uri-id'];
|
||||
}
|
||||
|
||||
$mails = DBA::select('mail', ['id'], $condition, $params);
|
||||
$mails = DBA::select('mail', ['id', 'uri-id'], $condition, $params);
|
||||
|
||||
$statuses = [];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue