forked from jmug/stoatchat
chore: update es code to lapin
Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -16,11 +15,7 @@ pub struct AckConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for AckConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -17,11 +16,7 @@ pub struct DmCallConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for DmCallConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -17,11 +16,7 @@ pub struct FRAcceptedConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for FRAcceptedConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -17,11 +16,7 @@ pub struct FRReceivedConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for FRReceivedConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -17,11 +16,7 @@ pub struct GenericConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for GenericConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -4,13 +4,13 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use crate::utils::{render_notification_content, Consumer};
|
||||
use crate::utils::render_notification_content;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use revolt_database::{
|
||||
events::rabbit::*, util::bulk_permissions::BulkDatabasePermissionQuery, Database, Member,
|
||||
MessageFlagsValue,
|
||||
amqp::consumer::Consumer, events::rabbit::*,
|
||||
util::bulk_permissions::BulkDatabasePermissionQuery, Database, Member, MessageFlagsValue,
|
||||
};
|
||||
use revolt_models::v0::{MessageFlags, PushNotification};
|
||||
use revolt_result::ToRevoltError;
|
||||
@@ -29,11 +29,7 @@ impl MassMessageConsumer {
|
||||
push: &PushNotification,
|
||||
users: &[String],
|
||||
) -> Result<()> {
|
||||
if let Ok(sessions) = self
|
||||
.db
|
||||
.fetch_sessions_with_subscription(users)
|
||||
.await
|
||||
{
|
||||
if let Ok(sessions) = self.db.fetch_sessions_with_subscription(users).await {
|
||||
let config = revolt_config::config().await;
|
||||
for session in sessions {
|
||||
if let Some(sub) = session.subscription {
|
||||
@@ -72,11 +68,7 @@ impl MassMessageConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for MassMessageConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::{render_notification_content, Consumer};
|
||||
use crate::utils::render_notification_content;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use lapin::{message::Delivery, Channel, Connection};
|
||||
use log::debug;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[allow(unused)]
|
||||
@@ -17,11 +17,7 @@ pub struct MessageConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for MessageConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<Channel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<Channel>, _: ()) -> Self {
|
||||
Self {
|
||||
db,
|
||||
connection,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{borrow::Cow, collections::BTreeMap, io::Cursor, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use base64::{
|
||||
@@ -15,7 +14,7 @@ use revolt_a2::{
|
||||
},
|
||||
Client, ClientConfig, Endpoint, Error, ErrorBody, ErrorReason, Priority, PushType, Response,
|
||||
};
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
use revolt_models::v0::{Channel, Message, PushNotification};
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -123,11 +122,7 @@ impl ApnsOutboundConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for ApnsOutboundConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<AMQPChannel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<AMQPChannel>, _: ()) -> Self {
|
||||
let config = revolt_config::config().await;
|
||||
|
||||
if config.pushd.apn.pkcs8.is_empty()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{collections::HashMap, sync::Arc, time::Duration};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
use anyhow::{bail, Result};
|
||||
use async_trait::async_trait;
|
||||
use fcm_v1::{
|
||||
@@ -10,7 +9,7 @@ use fcm_v1::{
|
||||
};
|
||||
use lapin::{message::Delivery, Channel as AMQPChannel, Connection};
|
||||
use revolt_config::config;
|
||||
use revolt_database::{events::rabbit::*, Database};
|
||||
use revolt_database::{amqp::consumer::Consumer, events::rabbit::*, Database};
|
||||
use serde_json::Value;
|
||||
|
||||
/// Custom notification data
|
||||
@@ -126,11 +125,7 @@ pub struct FcmOutboundConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for FcmOutboundConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<AMQPChannel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<AMQPChannel>, _: ()) -> Self {
|
||||
let config = revolt_config::config().await;
|
||||
|
||||
Self {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::utils::Consumer;
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use async_trait::async_trait;
|
||||
use base64::{
|
||||
@@ -9,7 +7,9 @@ use base64::{
|
||||
Engine as _,
|
||||
};
|
||||
use lapin::{message::Delivery, Channel as AMQPChannel, Connection};
|
||||
use revolt_database::{events::rabbit::*, util::format_display_name, Database};
|
||||
use revolt_database::{
|
||||
amqp::consumer::Consumer, events::rabbit::*, util::format_display_name, Database,
|
||||
};
|
||||
use web_push::{
|
||||
ContentEncoding, IsahcWebPushClient, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder,
|
||||
WebPushClient, WebPushError, WebPushMessageBuilder,
|
||||
@@ -27,11 +27,7 @@ pub struct VapidOutboundConsumer {
|
||||
|
||||
#[async_trait]
|
||||
impl Consumer for VapidOutboundConsumer {
|
||||
async fn create(
|
||||
db: Database,
|
||||
connection: Arc<Connection>,
|
||||
channel: Arc<AMQPChannel>,
|
||||
) -> Self {
|
||||
async fn create(db: Database, connection: Arc<Connection>, channel: Arc<AMQPChannel>, _: ()) -> Self {
|
||||
let config = revolt_config::config().await;
|
||||
|
||||
if config.pushd.vapid.private_key.is_empty() || config.pushd.vapid.public_key.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user