apply label
This commit is contained in:
parent
60eb4a61b9
commit
f224aa8506
@ -66,6 +66,7 @@ namespace ttrss_co_client.ttrss
|
|||||||
//???? = 7
|
//???? = 7
|
||||||
//???? = 8
|
//???? = 8
|
||||||
//1.14 = 9
|
//1.14 = 9
|
||||||
|
//1.15 = 10
|
||||||
assertInitialized();
|
assertInitialized();
|
||||||
return await getOneValue<int>("getApiLevel", "level");
|
return await getOneValue<int>("getApiLevel", "level");
|
||||||
}
|
}
|
||||||
@ -580,7 +581,7 @@ namespace ttrss_co_client.ttrss
|
|||||||
|
|
||||||
return apiResponse.ContainsKey("status") && apiResponse["status"]?.ToLower() == "ok";
|
return apiResponse.ContainsKey("status") && apiResponse["status"]?.ToLower() == "ok";
|
||||||
}
|
}
|
||||||
public async Task<IEnumerable<Label>> GetLabels(int? article_id)
|
public async Task<IEnumerable<Label>> GetLabels(int? article_id = null)
|
||||||
{
|
{
|
||||||
assertInitialized();
|
assertInitialized();
|
||||||
|
|
||||||
@ -600,11 +601,49 @@ namespace ttrss_co_client.ttrss
|
|||||||
}
|
}
|
||||||
return labels;
|
return labels;
|
||||||
}
|
}
|
||||||
public async Task SetArticleLabel(int label_id, bool assign, params int[] article_ids)
|
public async Task<int> SetArticleLabel(int label_id, bool assign, params int[] article_ids)
|
||||||
{
|
{
|
||||||
//there's a label "cache", i guess?
|
if (article_ids == null || article_ids.Length == 0)
|
||||||
|
{
|
||||||
|
throw new System.ArgumentNullException("ids", "need to specify at least one id");
|
||||||
|
}
|
||||||
assertInitialized();
|
assertInitialized();
|
||||||
throw new NotImplementedException();
|
|
||||||
|
var json = JsonContent.Create(new
|
||||||
|
{
|
||||||
|
op = "setArticleLabel",
|
||||||
|
sid = this.SessionId,
|
||||||
|
article_ids = string.Join(',', article_ids),
|
||||||
|
label_id = label_id,
|
||||||
|
assign = assign
|
||||||
|
});
|
||||||
|
|
||||||
|
var apiResponse = await get<Dictionary<string, string>>(json);
|
||||||
|
|
||||||
|
if (!apiResponse.ContainsKey("status") && apiResponse["status"]?.ToLower() == "ok")
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.api_level <= 10)
|
||||||
|
{
|
||||||
|
//update label cache
|
||||||
|
var tasks = new List<Task>();
|
||||||
|
foreach (var id in article_ids)
|
||||||
|
{
|
||||||
|
tasks.Add(GetLabels(id));
|
||||||
|
}
|
||||||
|
Task.WaitAll(tasks.ToArray());
|
||||||
|
}
|
||||||
|
int toReturn;
|
||||||
|
if (int.TryParse(apiResponse["updated"], out toReturn))
|
||||||
|
{
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("update ostensibly ok, but couldn't parse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public async Task ShareToPublished(string title, Uri url, string content, bool sanitize = true)
|
public async Task ShareToPublished(string title, Uri url, string content, bool sanitize = true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user