From 6bd8371f8629bba8edaeb10e2648a5cf0177cd2b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 20 Aug 2021 12:20:03 +0300 Subject: ActivityPub: Handle Flag activity --- .../java/com/juick/www/api/activity/Profile.java | 6 ++++++ .../com/juick/www/api/activity/model/Context.java | 1 + .../www/api/activity/model/activities/Flag.java | 24 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 src/main/java/com/juick/www/api/activity/model/activities/Flag.java (limited to 'src/main/java/com/juick/www/api/activity') diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java index e261c2e8..72cc849e 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -30,6 +30,7 @@ import com.juick.www.api.activity.model.Context; import com.juick.www.api.activity.model.activities.Announce; import com.juick.www.api.activity.model.activities.Create; import com.juick.www.api.activity.model.activities.Delete; +import com.juick.www.api.activity.model.activities.Flag; import com.juick.www.api.activity.model.activities.Follow; import com.juick.www.api.activity.model.activities.Like; import com.juick.www.api.activity.model.activities.Undo; @@ -401,6 +402,11 @@ public class Profile { applicationEventPublisher.publishEvent(new AnnounceEvent(this, activity.getActor(), messageUri)); return new ResponseEntity<>(CommandResult.fromString("Like/announce request accepted"), HttpStatus.OK); } + if (activity instanceof Flag) { + URI actor = URI.create(activity.getActor()); + logger.info("{} flag some objects: {}", actor, activity.getObject()); + return new ResponseEntity<>(CommandResult.fromString("Report accepted"), HttpStatus.ACCEPTED); + } logger.warn("Unknown activity: {}", jsonMapper.writeValueAsString(activity)); return new ResponseEntity<>(CommandResult.fromString("Unknown activity"), HttpStatus.NOT_IMPLEMENTED); } diff --git a/src/main/java/com/juick/www/api/activity/model/Context.java b/src/main/java/com/juick/www/api/activity/model/Context.java index e75f2440..5d945749 100644 --- a/src/main/java/com/juick/www/api/activity/model/Context.java +++ b/src/main/java/com/juick/www/api/activity/model/Context.java @@ -35,6 +35,7 @@ import java.util.List; @JsonSubTypes.Type(value = Create.class, name = "Create"), @JsonSubTypes.Type(value = Update.class, name = "Update"), @JsonSubTypes.Type(value = Delete.class, name = "Delete"), + @JsonSubTypes.Type(value = Flag.class, name = "Flag"), @JsonSubTypes.Type(value = Follow.class, name = "Follow"), @JsonSubTypes.Type(value = Accept.class, name = "Accept"), @JsonSubTypes.Type(value = Undo.class, name = "Undo"), diff --git a/src/main/java/com/juick/www/api/activity/model/activities/Flag.java b/src/main/java/com/juick/www/api/activity/model/activities/Flag.java new file mode 100644 index 00000000..2c61d344 --- /dev/null +++ b/src/main/java/com/juick/www/api/activity/model/activities/Flag.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2008-2021, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.juick.www.api.activity.model.activities; + +import com.juick.www.api.activity.model.Activity; + +public class Flag extends Activity { + +} -- cgit v1.2.3