diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 32ac2f4..3e86306 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,11 @@
-
+
+
+
+
+
@@ -149,7 +153,6 @@
-
@@ -174,7 +177,8 @@
-
+
+
true
diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go
index 0e97601..13f2c4b 100644
--- a/pkg/internal/server/api/index.go
+++ b/pkg/internal/server/api/index.go
@@ -35,6 +35,7 @@ func MapAPIs(app *fiber.App) {
me.Post("/confirm", doRegisterConfirm)
+ me.Get("/status", getStatus)
me.Post("/status", setStatus)
me.Put("/status", editStatus)
me.Delete("/status", clearStatus)
diff --git a/pkg/internal/server/api/statuses_api.go b/pkg/internal/server/api/statuses_api.go
index e503046..3a11c71 100644
--- a/pkg/internal/server/api/statuses_api.go
+++ b/pkg/internal/server/api/statuses_api.go
@@ -33,6 +33,24 @@ func getStatus(c *fiber.Ctx) error {
})
}
+func getMyselfStatus(c *fiber.Ctx) error {
+ user := c.Locals("user").(models.Account)
+ if err := exts.EnsureAuthenticated(c); err != nil {
+ return err
+ }
+
+ status, err := services.GetStatus(user.ID)
+ disturbable := services.GetStatusDisturbable(user.ID) == nil
+ online := services.GetStatusOnline(user.ID) == nil
+
+ return c.JSON(fiber.Map{
+ "status": lo.Ternary(err == nil, &status, nil),
+ "last_seen_at": user.Profile.LastSeenAt,
+ "is_disturbable": disturbable,
+ "is_online": online,
+ })
+}
+
func setStatus(c *fiber.Ctx) error {
user := c.Locals("user").(models.Account)
if err := exts.EnsureAuthenticated(c); err != nil {