/*
* Copyright (C) 2008-2020, 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.service;
import com.juick.model.Message;
import com.juick.model.Reaction;
import com.juick.model.User;
import com.juick.model.ResponseReply;
import com.juick.model.Tag;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.lang.NonNull;
import java.net.URI;
import java.util.*;
/**
* Created by aalexeev on 11/13/16.
*/
public interface MessagesService {
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
int createMessage(int uid, String txt, String attachment, @NonNull Set tags);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
int createReply(int mid, int rid, User user, String txt, String attachment);
enum RecommendStatus {
Error,
Added,
Deleted
}
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
RecommendStatus recommendMessage(int mid, int vuid, String userUri);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
RecommendStatus recommendMessage(int mid, int vuid);
List listReactions();
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
RecommendStatus likeMessage(int mid, int vuid, Integer reaction);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
RecommendStatus likeMessage(int mid, int vuid, Integer reaction, String userUri);
boolean canViewThread(int mid, int uid);
boolean isReadOnly(int mid);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
void setReadOnly(int mid, boolean readonly);
boolean isSubscribed(int uid, int mid);
int getMessagePrivacy(int mid);
Optional getMessage(int mid);
Message getReply(int mid, int rid);
Message getReplyByUri(String replyUri);
List> getMessagesRecommendations(Collection mids);
@Cacheable(value = "discover", key="{ #visitorUid, #before }")
List getAll(int visitorUid, int before);
List getTag(int tid, int visitorUid, int before, int cnt);
List getTags(String tids, int visitorUid, int before, int cnt);
List getPlace(int placeId, int visitorUid, int before);
List getMyFeed(int uid, int before, boolean recommended);
List getPrivate(int uid, int before);
@Cacheable(value = "discussions", key="{ #uid, #to }")
List getDiscussions(int uid, Long to);
/**
* Get messages recommended by friends
* @param uid visitor id
* @param before
* @return recommended message ids
*/
List getRecommended(int uid, int before);
List getPhotos(int visitorUid, int before);
List getSearch(User visitor, String search, int page);
List getUserBlog(int uid, int privacy, int before);
List getUserTag(int uid, int tid, int privacy, int before);
List getUserBlogAtDay(int uid, int privacy, int daysback);
List getUserBlogWithRecommendations(User user, User visitor, int privacy, int before);
List getUserRecommendations(int uid, int before);
List getUserPhotos(int uid, int privacy, int before);
List getUserSearch(User visitor, int UID, String search, int privacy, int page);
@Cacheable(value = "messages", key="{ #visitor.uid, #mids.hashCode() }")
List getMessages(User visitor, List mids);
@Cacheable(value = "replies", key="{ #user.uid, #mid }")
List getReplies(User user, int mid);
boolean setMessagePrivacy(int mid);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean deleteMessage(int uid, int mid);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean deleteReply(int uid, int mid, int rid);
List getLastMessages(int hours);
List getLastReplies(int hours);
List getPopularCandidates();
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true, condition = "{ #user.uid != 0 }")
void setLastReadComment(User user, Integer mid, Integer rid);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true, condition = "{ #user.uid != 0 }")
void setRead(User user, Integer mid);
List getUnread(User user);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean updateMessage(Integer mid, Integer rid, String body, boolean foreign);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean updateReplyUri(Message reply, URI replyUri);
boolean replyExists(URI replyUri);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true)
boolean deleteReply(URI userUri, URI replyUri);
String getMessageProperty(Integer mid, Integer rid, String key);
void setMessageProperty(Integer mid, Integer rid, String key, String value);
Optional> findMessageByProperty(String key, String value);
}