added nodeinfo 2.1
This commit is contained in:
parent
4cb185569b
commit
5cd6279da8
12 changed files with 168 additions and 84 deletions
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BirdsiteLive.Common.Settings;
|
using BirdsiteLive.Common.Settings;
|
||||||
using BirdsiteLive.Models;
|
using BirdsiteLive.Models;
|
||||||
|
using BirdsiteLive.Models.WellKnownModels;
|
||||||
using BirdsiteLive.Twitter;
|
using BirdsiteLive.Twitter;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
@ -35,44 +36,85 @@ namespace BirdsiteLive.Controllers
|
||||||
{
|
{
|
||||||
rel = "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
rel = "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
||||||
href = $"https://{_settings.Domain}/nodeinfo/2.0.json"
|
href = $"https://{_settings.Domain}/nodeinfo/2.0.json"
|
||||||
|
},
|
||||||
|
new Link()
|
||||||
|
{
|
||||||
|
rel = "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
||||||
|
href = $"https://{_settings.Domain}/nodeinfo/2.1.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return new JsonResult(nodeInfo);
|
return new JsonResult(nodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/nodeinfo/2.0.json")]
|
[Route("/nodeinfo/{id}.json")]
|
||||||
public IActionResult NodeInfo()
|
public IActionResult NodeInfo(string id)
|
||||||
{
|
{
|
||||||
var nodeInfo = new NodeInfo
|
if (id == "2.0")
|
||||||
{
|
{
|
||||||
version = "2.0",
|
var nodeInfo = new NodeInfoV20
|
||||||
usage = new Usage()
|
|
||||||
{
|
{
|
||||||
localPosts = 0,
|
version = "2.0",
|
||||||
users = new Users()
|
usage = new Usage()
|
||||||
{
|
{
|
||||||
total = 0
|
localPosts = 0,
|
||||||
|
users = new Users()
|
||||||
|
{
|
||||||
|
total = 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
software = new Software()
|
||||||
|
{
|
||||||
|
name = "birdsitelive",
|
||||||
|
version = "0.1.0"
|
||||||
|
},
|
||||||
|
protocols = new[]
|
||||||
|
{
|
||||||
|
"activitypub"
|
||||||
|
},
|
||||||
|
openRegistrations = false,
|
||||||
|
services = new Models.WellKnownModels.Services()
|
||||||
|
{
|
||||||
|
inbound = new object[0],
|
||||||
|
outbound = new object[0]
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
software = new Software()
|
return new JsonResult(nodeInfo);
|
||||||
|
}
|
||||||
|
if (id == "2.1")
|
||||||
|
{
|
||||||
|
var nodeInfo = new NodeInfoV21
|
||||||
{
|
{
|
||||||
name = "birdsitelive",
|
version = "2.1",
|
||||||
version = "0.1.0"
|
usage = new Usage()
|
||||||
},
|
{
|
||||||
protocols = new []
|
localPosts = 0,
|
||||||
{
|
users = new Users()
|
||||||
"activitypub"
|
{
|
||||||
},
|
total = 0
|
||||||
openRegistrations = false,
|
}
|
||||||
services = new Services()
|
},
|
||||||
{
|
software = new SoftwareV21()
|
||||||
inbound = new object[0],
|
{
|
||||||
outbound = new object[0]
|
name = "birdsitelive",
|
||||||
}
|
version = "0.1.0",
|
||||||
};
|
repository = "https://github.com/NicolasConstant/BirdsiteLive"
|
||||||
|
},
|
||||||
|
protocols = new[]
|
||||||
|
{
|
||||||
|
"activitypub"
|
||||||
|
},
|
||||||
|
openRegistrations = false,
|
||||||
|
services = new Models.WellKnownModels.Services()
|
||||||
|
{
|
||||||
|
inbound = new object[0],
|
||||||
|
outbound = new object[0]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return new JsonResult(nodeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
return new JsonResult(nodeInfo);
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/.well-known/webfinger")]
|
[Route("/.well-known/webfinger")]
|
||||||
|
@ -135,63 +177,4 @@ namespace BirdsiteLive.Controllers
|
||||||
return new JsonResult(result);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WebFingerResult
|
|
||||||
{
|
|
||||||
public string subject { get; set; }
|
|
||||||
public string[] aliases { get; set; }
|
|
||||||
public List<WebFingerLink> links { get; set; } = new List<WebFingerLink>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WebFingerLink
|
|
||||||
{
|
|
||||||
public string rel { get; set; }
|
|
||||||
public string type { get; set; }
|
|
||||||
public string href { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WellKnownNodeInfo
|
|
||||||
{
|
|
||||||
public Link[] links { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Link
|
|
||||||
{
|
|
||||||
public string href { get; set; }
|
|
||||||
public string rel { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NodeInfo
|
|
||||||
{
|
|
||||||
public string version { get; set; }
|
|
||||||
public string[] protocols { get; set; }
|
|
||||||
public Software software { get; set; }
|
|
||||||
public Usage usage { get; set; }
|
|
||||||
public bool openRegistrations { get; set; }
|
|
||||||
public Services services { get; set; }
|
|
||||||
//public object metadata { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Services
|
|
||||||
{
|
|
||||||
public object[] inbound { get; set; }
|
|
||||||
public object[] outbound { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Software
|
|
||||||
{
|
|
||||||
public string name { get; set; }
|
|
||||||
public string version { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Usage
|
|
||||||
{
|
|
||||||
public int localPosts { get; set; }
|
|
||||||
public Users users { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Users
|
|
||||||
{
|
|
||||||
public int total { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
8
src/BirdsiteLive/Models/WellKnownModels/Link.cs
Normal file
8
src/BirdsiteLive/Models/WellKnownModels/Link.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class Link
|
||||||
|
{
|
||||||
|
public string href { get; set; }
|
||||||
|
public string rel { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
src/BirdsiteLive/Models/WellKnownModels/NodeInfoV20.cs
Normal file
13
src/BirdsiteLive/Models/WellKnownModels/NodeInfoV20.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class NodeInfoV20
|
||||||
|
{
|
||||||
|
public string version { get; set; }
|
||||||
|
public string[] protocols { get; set; }
|
||||||
|
public Software software { get; set; }
|
||||||
|
public Usage usage { get; set; }
|
||||||
|
public bool openRegistrations { get; set; }
|
||||||
|
public Services services { get; set; }
|
||||||
|
//public object metadata { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
src/BirdsiteLive/Models/WellKnownModels/NodeInfoV21.cs
Normal file
13
src/BirdsiteLive/Models/WellKnownModels/NodeInfoV21.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class NodeInfoV21
|
||||||
|
{
|
||||||
|
public string version { get; set; }
|
||||||
|
public string[] protocols { get; set; }
|
||||||
|
public Usage usage { get; set; }
|
||||||
|
public bool openRegistrations { get; set; }
|
||||||
|
public SoftwareV21 software { get; set; }
|
||||||
|
public Services services { get; set; }
|
||||||
|
//public object metadata { get; set; }
|
||||||
|
}
|
||||||
|
}
|
8
src/BirdsiteLive/Models/WellKnownModels/Services.cs
Normal file
8
src/BirdsiteLive/Models/WellKnownModels/Services.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class Services
|
||||||
|
{
|
||||||
|
public object[] inbound { get; set; }
|
||||||
|
public object[] outbound { get; set; }
|
||||||
|
}
|
||||||
|
}
|
8
src/BirdsiteLive/Models/WellKnownModels/Software.cs
Normal file
8
src/BirdsiteLive/Models/WellKnownModels/Software.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class Software
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string version { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
src/BirdsiteLive/Models/WellKnownModels/SoftwareV21.cs
Normal file
9
src/BirdsiteLive/Models/WellKnownModels/SoftwareV21.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class SoftwareV21
|
||||||
|
{
|
||||||
|
public string name { get; set; }
|
||||||
|
public string repository { get; set; }
|
||||||
|
public string version { get; set; }
|
||||||
|
}
|
||||||
|
}
|
8
src/BirdsiteLive/Models/WellKnownModels/Usage.cs
Normal file
8
src/BirdsiteLive/Models/WellKnownModels/Usage.cs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class Usage
|
||||||
|
{
|
||||||
|
public int localPosts { get; set; }
|
||||||
|
public Users users { get; set; }
|
||||||
|
}
|
||||||
|
}
|
7
src/BirdsiteLive/Models/WellKnownModels/Users.cs
Normal file
7
src/BirdsiteLive/Models/WellKnownModels/Users.cs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class Users
|
||||||
|
{
|
||||||
|
public int total { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
src/BirdsiteLive/Models/WellKnownModels/WebFingerLink.cs
Normal file
9
src/BirdsiteLive/Models/WellKnownModels/WebFingerLink.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class WebFingerLink
|
||||||
|
{
|
||||||
|
public string rel { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
public string href { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
src/BirdsiteLive/Models/WellKnownModels/WebFingerResult.cs
Normal file
11
src/BirdsiteLive/Models/WellKnownModels/WebFingerResult.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class WebFingerResult
|
||||||
|
{
|
||||||
|
public string subject { get; set; }
|
||||||
|
public string[] aliases { get; set; }
|
||||||
|
public List<WebFingerLink> links { get; set; } = new List<WebFingerLink>();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace BirdsiteLive.Models.WellKnownModels
|
||||||
|
{
|
||||||
|
public class WellKnownNodeInfo
|
||||||
|
{
|
||||||
|
public Link[] links { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue